RHCSA 1.1: The shell and redirection
Sending output and errors to different files, appending, counting with a pipe, and writing to a root-owned file with sudo.
Before you start
The lab removes the files the tasks write in /tmp, and any
test.example.com line in /etc/hosts. Do tasks 1 to 3 as your normal
user, not as root.
Tasks
- Run
ls /etc/hostname /nonexistentso that normal output goes to/tmp/ok.txtand the error goes to/tmp/errors.txt. - Append the current date to
/tmp/log.txtthree times without opening an editor. - Save a list of every file under
/etcwhose name ends in.confto/tmp/confs.txt, with no error messages in it, and show the number of files on the screen. - As a normal user, add the line
192.0.2.50 test.example.comto/etc/hostswithsudobut without opening an editor.
Hints
>and2>send the two streams to different files.>>appends;date >>file.find /etc -name '*.conf',2>/dev/null,tee,wc -l.sudo echo ... >>/etc/hostsfails: the shell opens the file, not sudo.| sudo tee -a.