010-160 Linux Filesystem & File Management 4 — Questions and Answers
Question 1: What does the `touch` command do when used on a file that already exists?
- Deletes the file and recreates it empty
- Updates the file's access and modification timestamps (Correct answer)
- Locks the file from being modified
- Displays the file's metadata
Correct answer: Updates the file's access and modification timestamps
When `touch` is used on an existing file, it updates the access and modification timestamps without changing the file's content.
Question 2: What is the inode in a Linux filesystem?
- A type of directory for system files
- A data structure storing file metadata excluding the filename (Correct answer)
- The first block of data in every file
- An index of all mounted filesystems
Correct answer: A data structure storing file metadata excluding the filename
An inode is a data structure that stores file metadata (permissions, owner, timestamps, data block pointers) but not the filename itself.
Question 3: Which `find` command option is used to search by file size?
- -name
- -type
- -size (Correct answer)
- -perm
Correct answer: -size
The `-size` option in `find` allows you to search for files matching a specific size (e.g., `find . -size +1M`).
Question 4: What does `cat file1 file2 > output.txt` do?
- Compares file1 and file2 and writes differences to output.txt
- Concatenates file1 and file2 and writes the result to output.txt (Correct answer)
- Copies file1 to file2 and then to output.txt
- Creates output.txt from the filenames of file1 and file2
Correct answer: Concatenates file1 and file2 and writes the result to output.txt
`cat` concatenates files and `>` redirects the combined output to output.txt, overwriting it.
Question 5: Which file contains a list of all filesystems to be mounted at boot time?
- /etc/mtab
- /etc/fstab (Correct answer)
- /proc/mounts
- /etc/mounts.conf
Correct answer: /etc/fstab
/etc/fstab (filesystem table) defines which filesystems are automatically mounted at system boot.
Question 6: What does the `mv` command do when the destination is on the same filesystem?
- Copies the file and deletes the original
- Renames the directory entry without moving data blocks (Correct answer)
- Creates a hard link and removes the source
- Compresses and moves the file
Correct answer: Renames the directory entry without moving data blocks
On the same filesystem, `mv` simply renames the directory entry pointing to the inode — no actual data is copied.
Question 7: What does the wildcard `?` match in a Linux shell glob pattern?
- Zero or more characters
- Exactly one character (Correct answer)
- Any digit
- Any alphabetic character
Correct answer: Exactly one character
The `?` wildcard matches exactly one single character, while `*` matches zero or more characters.
What does the `touch` command do when used on a file that already exists?