Essential Command Line Fundamentals Quiz Quiz

Explore key concepts of command line basics and essential CLI tools with this quiz, designed for beginners aiming to improve navigation, file management, and command usage skills. Strengthen your foundational understanding of terminal commands, command arguments, and common utilities in the tools ecosystem.

  1. Directory Navigation

    Which command allows you to change your current working directory to a folder named 'projects' located in your home directory?

    1. cd ~/projects
    2. ls ~/projects
    3. pwd ~/projects
    4. mv ~/projects

    Explanation: The 'cd' command is used to change directories, and '~/projects' refers to the 'projects' folder in your home directory. 'ls' lists files and directories but does not change the directory. 'pwd' prints the current directory's path, not change it. 'mv' moves or renames files and directories rather than allowing navigation.

  2. Listing Files

    If you want to list all files, including hidden ones, in your current directory using the command line, which command would you use?

    1. ls -a
    2. pwd -a
    3. dir -h
    4. ls /hidden

    Explanation: The 'ls -a' command displays all files and directories, including those that are hidden (which start with a dot). 'pwd -a' is invalid as 'pwd' does not have an '-a' option for listing. 'dir -h' shows file sizes in human-readable format but does not necessarily reveal hidden files. 'ls /hidden' incorrectly assumes a directory named 'hidden', not showing actual hidden files.

  3. File Content Viewing

    Which command displays the contents of a file named 'notes.txt' in your current directory without editing it?

    1. cat notes.txt
    2. rm notes.txt
    3. touch notes.txt
    4. cd notes.txt

    Explanation: The 'cat' command is used for displaying the contents of a file directly in the terminal. 'rm notes.txt' deletes the file instead of showing its contents. 'touch notes.txt' is used to create or update a file's timestamp, not to read its content. 'cd notes.txt' would attempt to change into 'notes.txt' as if it were a directory, which is incorrect.

  4. Copying Files

    Suppose you want to create a duplicate of 'summary.doc' in the same directory and name it 'summary_backup.doc'; which command accomplishes this?

    1. cp summary.doc summary_backup.doc
    2. mv summary.doc summary_backup.doc
    3. rm summary_backup.doc summary.doc
    4. cat summary.doc summary_backup.doc

    Explanation: The 'cp' command copies files, allowing you to make a duplicate with a new name. 'mv' moves or renames files but does not keep the original. 'rm' removes files, and using it as shown here is neither practical nor correct. 'cat summary.doc summary_backup.doc' displays the contents of both files, not copying them.

  5. Command Arguments and Options

    In the command 'ls -l /home/user', what does the '-l' option specifically change about the output?

    1. It provides a detailed, long-format listing of the files and directories.
    2. It lists only files larger than 1 megabyte.
    3. It limits the number of results to the first 10 files.
    4. It displays all files except those starting with 'l'.

    Explanation: The '-l' option in 'ls' switches the output to a long-format, showing file details like permissions, size, and dates. It does not filter by file size, so it does not list only files larger than 1 megabyte. The command does not limit results to a specific number of files, nor does it exclude files that begin with 'l'; those are common misunderstandings.