Chapter 3: Essential File Management - QUIZ
Which directory would you go to if you were looking for configuration files?
/etc contains configuration files.
What is the safe option to remove a symbolic link to a directory?
Use rm symlink to safely remove a symbolic link to a directory. If rm is aliased to rm -i and you do not want to answer yes for every individual file, use \rm instead.
3. Which of the following directories would typically not be mounted on its own dedicated device? a. /etc b. /boot c. /home d. /usr
a. /etc A. The /etc/ directory contains configuration files that are needed while your server boots. Putting /etc on a dedicated device would make your server unbootable.
7. Which command enables you to rename the file myfile to mynewfile? a. mv myfile mynewfile b. rm myfile mynewfile c. rn myfile mynewfile d. ren myfile mynewfile
a. mv myfile mynewfile
10. Which tar option enables you to add one single file to a tar archive? a. -a b. -A c. -r d. -u
c. -r C. Use the option -r to add one single file to an archive you have created with tar.
2. Under which directory would you expect to find log files? a. /proc b. /run c. /var d. /usr
c. /var
6. Which command enables you to copy hidden files as well as regular files from /home/$USER to the current directory? a. cp -a /home/$USER . b. cp -a /home/$USER/* . c. cp -a /home/$USER/. . d. cp -a home/$USER. .
c. cp -a /home/$USER/. . C. To copy hidden files as well as regular files, you need to put a . after the name of the directory the files are in. Answer A copies hidden files as well, but it creates a subdirectory $USER in the current directory.
4. Which of the following commands would give the most accurate overview of mounted disk devices (without showing much information about mounted system devices as well)? a. mount b. mount -a c. df -hT d. du -h
c. df -hT C. The df -h command shows mounted devices and the amount of disk space currently in use on these devices. The -T option helps in recognizing real file systems (as opposed to kernel interfaces) because it shows the file system type as well.
9. Which command creates a symbolic link to the directory /home in the directory /tmp? a. ln /tmp /home b. ln /home /tmp c. ln -s /home /tmp d. ln -s /tmp /home
c. ln -s /home /tmp C. The option -s is used to create a symbolic link. While creating a link, you first have to specify the source, and next you specify the destination.
5. Which command enables you to show all files in the current directory so that the newest files are listed last? a. ls -lRt b. ls -lrt c. ls -alrt d. ls -alr
c. ls -alrt C. The option -a shows hidden files, -l gives a long listing, -t sorts on modification time, which by default shows newest files first, and -r reverts the sorting so that newest files are shown last.
How would you copy all files that have a name that starts with a, b, or c from the directory /etc to your current directory?
cp /etc/[abc]* . copies all files that have a name that starts with a, b, or c from the directory /etc to your current directory.
1. Under which directory would you expect to find non essential program files? a. /boot b. /bin c. /sbin d. /usr
d. /usr D. Program files that are not required to boot a system are typically stored in a subdirectory below the /usr directory. In old versions of RHEL, essential binaries and system binaries were stored in /bin and /sbin, but on modern versions of RHEL, these directories are a symbolic link to /usr/bin and /usr/sbin.
8. Which statement about hard links is not true? a. Hard links cannot be created to directories. b. Hard links cannot refer to files on other devices. c. The inode keeps a hard link counter. d. If the original hard link is removed, all other hard links become invalid.
d. If the original hard link is removed, all other hard links become invalid. D. In hard links, no difference exists between the first hard link and subsequent hard links.
Which command enables you to create a link to the directory /etc in your home directory?
ln -s /etc ~ creates in your home directory a link to /etc.
How do you create a link to the directory /tmp in your home directory?
ln -s /tmp ~ creates in your home directory a link to /tmp.
Which command enables you to display a list of current directory contents, with the newest files listed first?
ls -alt displays a list of current directory contents, with the newest files listed first. (-a also shows files that have a name that starts with a dot.)
Which command enables you to rename the file myfile to yourfile?
mv myfile yourfile renames myfile to yourfile.
Which command enables you to wipe an entire directory structure, including all of its contents?
rm -rf /directory wipes an entire directory structure, including all of its contents.
How would you extract the file /etc/passwd from /tmp/etchome.tgz that you have created in the previous step?
tar xvf /tmp/etchome.tgz /etc/passwd extracts /etc/passwd from /tmp/etchome.tgz.
How do you create a compressed archive of the directories /etc and /home and write that archive to /tmp/etchome.tgz?
tar zcvf /tmp/etchome.tgz /etc /home creates a compressed archive of /etc and /home and writes it to /tmp/etchome.tgz.