2.4 KiB
2.4 KiB
LFCA 1.2: Command line
Directories, finding files, reading the SSH log, permissions, archives,
two editors, and a script of your own on the PATH.
Before you start
Work as root (sudo -i), so ~ is /root. Answers go in
/root/lab-answers/<task>. The lab creates ~/editme.txt for task 6 and
saves your ~/.bashrc and sshd's settings so reset can put them back.
Files in /tmp don't survive a reboot, so do the tasks in one go and run
le-lab check before you reboot.
Tasks
- Make
~/practice/a/bwith one command, move intob, and get back home three different ways. - Find every file under
/etcwhose name ends in.conf, save the list to~/conf-files.txt, count its lines, and write the count to/root/lab-answers/2. - Make sure the SSH server is running and allows password logins (turn
them on if not), run
ssh localhostand type a wrong password. Count the failures in sshd's journal and write the count to/root/lab-answers/3. - Make a file
/tmp/private.txtthat only you can read and write, check it withls -l, then create userbobwith a home directory and trysudo -u bob cat /tmp/private.txt. - Archive
~/practiceto~/practice.tar.gzwithtar -czf, delete~/practice, and restore it from the archive. - Open
~/editme.txtin vi, changebeforetoafteron the first line, save and quit. Then do the same on the second line in nano (install it if it's missing). - Add
~/scriptstoPATHin~/.bashrc, put a scripthelloin it with a#!/bin/bashfirst line, make it executable withchmod u+x, and run it ashelloin a new shell.
Hints
mkdir -p,cd,cd ~,cd ../../..,cd -andpwd.find /etc -name '*.conf' > ~/conf-files.txt,wc -l.systemctl status sshd(sshon Ubuntu).sshd -T | grep passwordauthshould sayyes; many cloud images set it tono, on Ubuntu in/etc/ssh/sshd_config.d/50-cloud-init.conf. Change it there andsystemctl restart sshd(sshon Ubuntu).journalctl -u sshd | grep -c "Failed password"(-u sshon Ubuntu).chmod 600,useradd -m bob; thecatshould fail.tar -czf ~/practice.tar.gz -C ~ practice,rm -r,tar -xzf,tar -tzfto look inside.- vi:
ito insert, Esc,:wq. nano: Ctrl-O to save, Ctrl-X to quit.dnf install nanoon the RHEL family. export PATH="$HOME/scripts:$PATH"in~/.bashrc,bashor a new login to get a new shell,type hello.