Using Linux Terminal 1.2: Searching, comparing and changing files
grep and regular expressions, find with errors thrown away, sed with a backup, and diff.
Before you start
The lab creates user student (password Lab-Pass-1). Work as student
(sudo -iu student), so ~ is /home/student. The lab removes the files
the tasks create if they exist, and le-lab reset removes them again.
Tasks
- Write the names of all users whose shell is
/bin/bashto~/bash-users.txt, one per line, and nothing else. - As
student, find every regular file under/etcbigger than 100 KiB and save the list in~/big-etc.txt, with any permission errors thrown away: none on the screen and none in the file. - Copy
/etc/ssh/sshd_configto~/sshd.copy, then usesedto change#Port 22toPort 2222in the copy, keeping a.bakof it.diff ~/sshd.copy.bak ~/sshd.copyshows just that one line changed.
Hints
grep '/bin/bash$' /etc/passwd, thencut -d: -f1; comparewc -lwithgrep -c.find /etc -type f -size +100k, and2>/dev/nullfor the errors.sed -i.bak 's/^#Port 22$/Port 2222/'; diff shows acchange.