Linux File Management Basics
- "Do I Know This Already?" Quiz
- Foundation Topics
- Exam Preparation Tasks
This chapter covers the following topics:
- Filesystem Overview
- File Management Commands
- Where Are Those Files?
- Backup Commands
This chapter covers the following objectives:
- Perform basic file management: 103.3
- Create and change hard and symbolic links: 104.6
- Find system files and place files in the correct location: 104.7
Most of what you do on a Linux machine involves manipulating files in some manner. You have to know where certain files go, such as binaries, configuration, and user data. You also need to be able to manipulate files from the command line rather than a GUI.
“Do I Know This Already?” Quiz
The “Do I Know This Already?” quiz enables you to assess whether you should read this entire chapter or simply jump to the “Exam Preparation Tasks” section for review. If you are in doubt, read the entire chapter. Table 5-1 outlines the major headings in this chapter and the corresponding “Do I Know This Already?” quiz questions. You can find the answers in Appendix A, “Answers to the ‘Do I Know This Already?’ Quizzes and Review Questions.”
Table 5-1 “Do I Know This Already?” Foundation Topics Section-to-Question Mapping
Foundation Topics Section |
Questions Covered in This Section |
Filesystem Overview |
1, 3 |
File Management Commands |
2, 4-6 |
Where Are Those Files? |
7-8 |
Backup Commands |
9-11 |
Files that change often should go under:
- /usr
- /proc
- /root
- /var
Your shell is in /usr/local. You type cd ../bin. Which directory is shown when you type pwd?
- /bin
- /usr/bin
- /usr/local/bin
- Nothing, this command returns an error.
Which of the following directories should be on the same partition as the root?
- /boot
- /usr
- /home
- /sbin
You happen across a file in a directory called foo. What is a good way to find out what the file is or does?
- file foo
- /foo
- cat foo
- which foo
What command would be used to update the date on a file?
- tar
- file
- date
- touch
You are trying to create a new series of nested directories: /a/b/c/d/. What is the fastest way to create this nested directory set?
- mkdir /a; mkdir /a/b; mkdir /a/b/c; mkdir /a/b/c/d
- mkdir /a/b/c/d
- mkdir -p /a/b/c/d
- md /a/b/c/d
You know that you have multiple copies of the doit command on your system. How do you find which one you will run if you type doit at the command line?
- whereis doit
- locate doit
- find doit
- which doit
You know that you downloaded a file called backup.tar.gz this morning but can’t remember where you put it. Which is the most appropriate command to find the file?
- find / -name backup.tar.gz
- find backup.tar.gz
- locate backup.tar.gz
- whereis backup.tar.gz
You want to package up Fred’s home directory on a USB stick to send with him as he’s leaving your company. Which command is the best? Hurry, because there’s cake!
- find /home/fred | tar -czf > /media/removable/fred.tar.gz
- tar -czf /home/fred > /media/removable/fred.tar.gz
- cd /home/; tar -cjf /media/removable/fred.tar.bz2 fred
- cd /home/fred tar -cjf /media/removable/fred.tar.bz2 *
What does the command tar -tf archive.tar etc/pine.conf do?
- Makes a new archive called archive.tar containing /etc/pine.conf
- Adds etc/pine.conf to archive.tar
- Checks to see whether etc/pine.conf is inside the archive
- Extracts etc/pine.conf from archive.tar
Which compression utility offers the highest level of compression?
- bzip2
- gzip
- compress
- cpio