Explore key concepts of Linux directory navigation and file manipulation with practical questions designed to boost understanding of command-line tools and techniques. Strengthen your skills in moving, copying, listing, and locating files within the Linux filesystem.
Which command would you use to move from your current directory to the parent directory in Linux?
Explanation: The command 'cd ..' moves you one level up to the parent directory. 'ls ../' lists the contents of the parent directory but does not move you. 'cd /parent' would only work if there is an absolute path named '/parent', which is uncommon. 'pwd ..' is incorrect; 'pwd' prints the current working directory without accepting navigation arguments.
If you want a detailed list of all files, including hidden files, in your current directory, which command should you use?
Explanation: 'ls -la' provides a long listing format of all files, including hidden files that start with a dot. 'ls all' is not a valid option. 'ls -lh' displays human-readable file sizes but does not show hidden files unless combined with the '-a' flag. 'ls /hidden' would look for a directory named '/hidden', which does not fulfill the requirement.
Suppose you want to copy a file named notes.txt from the current directory to the /tmp directory. Which command accurately accomplishes this?
Explanation: 'cp notes.txt /tmp/' copies the file to the /tmp directory. 'mv notes.txt /tmp/' moves rather than copies the file. 'cat notes.txt /tmp/' would try to display the contents of notes.txt, possibly redirecting output, but not copying the file. 'copy' is not a standard Linux command for this purpose.
Which command will move an entire directory named data and its contents into a directory called backup?
Explanation: 'mv data backup/' moves the 'data' directory and all its contents into the 'backup' directory. 'cp -r data backup/' would copy, not move, the directory. 'move data backup/' is not a recognized command in Linux. 'rm -r data backup/' would attempt to remove both directories and does not perform a move.
To search for a file named report.pdf in your current directory and its subdirectories, which command should you execute?
Explanation: 'find . -name report.pdf' will search for the file named 'report.pdf' starting from the current directory and including all subdirectories. 'grep report.pdf' searches for text within files, not for file locations. 'search report.pdf' is not a standard Linux command. 'locate report.pdf .' is an incorrect usage of 'locate', which does not accept a directory as its argument in this manner.