NDG Linux Essentials 2.21 | Managing Files and Directories Module 8 | Chapter 08 Exam Answers Full 100% 2023 and 2024

These are questions of Cisco NDG Linux Essentials 2.21 Managing Files and Directories Chapter 08 Exam Answers full 100% with the latest version and updated in 2023 and 2024. All answers are verified by experts with explanations.

  1. When using the cp command, you must provide both a source and a destination.

    True or False?

    • True
    • False
    • Answers Explanation & Hint:

      When using the cp command (which stands for “copy”), you must provide both a source and a destination. The cp command is used to copy files or directories from a source location to a destination location. The source is the file or directory that you want to copy, and the destination is the location where you want to place the copied file or directory.

      The basic syntax of the cp command is as follows:

      cp [options] source destination

      For example, to copy a file named file.txt from the current directory to a directory called backup, you would use:

      cp file.txt backup/

      Here, file.txt is the source, and backup/ is the destination.

  2. Which option(s) can be used to prevent cp from overwriting an existing file?

    (choose two)

    • -i
    • -z
    • -n
    • -N
    • Answers Explanation & Hint:

      The option(s) that can be used to prevent cp from overwriting an existing file are:

      1. -i: This option stands for “interactive,” and when used, cp will prompt you before overwriting any existing file in the destination location. It gives you the chance to confirm if you want to proceed with the overwrite.
      2. -n: This option stands for “no clobber,” and when used, cp will not overwrite an existing file in the destination location. If a file with the same name already exists, cp will not copy the source file to the destination.

      So, the correct options are -i and -n. The options -z and -N are not relevant to preventing overwriting in the context of the cp command.

  3. The command rm -r will…

    • generate an error; -r isn’t a valid option.
    • remove a directory along with any files or subdirectories.
    • prompt for each confirmation before deleting each file in a directory.
    • remove only empty directories.
    • Answers Explanation & Hint:

      The command rm -r will remove a directory along with any files or subdirectories contained within it.

      The -r option (recursive) tells the rm command to perform a recursive deletion, meaning it will remove directories and their contents, including any files or subdirectories within them. It is commonly used to delete directories and their entire contents, recursively removing all files and subdirectories in the specified directory.

      However, it is essential to exercise caution when using the rm -r command, as it will not prompt for confirmation before deleting each file or directory. Once the command is executed, the deletion is irreversible, and the files and directories will be permanently removed from the file system. Always double-check the command and be sure of the target directory before using the rm -r command.

  4. Which option can be used with the rm command to prompt before deleting?

    • -P
    • l
    • -i
    • A
    • Answers Explanation & Hint:

      The option that can be used with the rm command to prompt before deleting each file is -i.

      When you use the -i option with rm, the command will interactively prompt you for confirmation before deleting each file or directory. This way, you have the chance to confirm whether you want to proceed with the deletion or not.

      For example, if you want to delete a file named example.txt with confirmation, you would use:

      rm -i example.txt

      The command will then prompt you to confirm the deletion of example.txt, and you need to type ‘y’ (yes) and press Enter to proceed or ‘n’ (no) and press Enter to skip the deletion.

      rm: remove regular file 'example.txt'? y

      This interactive mode provides an extra layer of safety, helping to prevent accidental deletions.

  5. The rm command can delete multiple files at once.

    True or False?

    • True
    • False
    • Answers Explanation & Hint:

      The rm command in Linux can indeed delete multiple files at once. You can provide multiple file names as arguments to the rm command, and it will delete all the specified files in one go.

      For example, to delete three files named file1.txt, file2.txt, and file3.txt, you can use the following command:

      rm file1.txt file2.txt file3.txt

      This will remove all three files simultaneously. It’s essential to be cautious when using the rm command with multiple files, as it does not provide any confirmation by default. If you want to be prompted for each file’s deletion, you can use the -i option with rm, as explained in the previous response.

  6. Which of the following commands can be used to rename a file?

    • name
    • rm
    • mv
    • cp
    • Answers Explanation & Hint:

      The command that can be used to rename a file is mv.

      The mv command (short for “move”) is not only used to move files but also to rename them. When you use mv with a source file and a destination file, and the destination is a different name (not an existing directory), it effectively renames the source file to the destination name.

      For example, to rename a file named oldfile.txt to newfile.txt, you would use the mv command as follows:

      mv oldfile.txt newfile.txt

      This command will rename oldfile.txt to newfile.txt.

      On the other hand:

      • rm is used to remove/delete files, not to rename them.
      • cp is used to copy files, not to rename them.
      • There is no built-in command called name for renaming files; it’s done with mv.
  7. The touch command can be used to:

    (choose two)

    • Create new files
    • Change a file’s name
    • Change ownership of a file
    • Update the timestamp of existing files
  8. Which of the following are glob characters?

    (choose three)

    • The square brackets [ and ]
    • The asterisk *
    • The question mark ?
    • The dash character -
  9. The main purpose of using glob characters is to be able to provide a list of filenames to a command.

    True or False?

    • True
    • False
  10. The asterisk character is used to represent zero or more of any character in a filename.

    True or False?

    • True
    • False
  11. Which of these commands will return /etc/gai.conf /etc/pam.conf /etc/ucf.conf?

    (choose two)

    • ls /etc/p???.**
    • echo /etc/???.*f
    • ls /etc/???.????
    • echo /etc/*?.*o?
  12. Brackets cannot be used to a represent a range of characters.

    True or False?

    • True
    • False
  13. Which command would list files that do not begin with a T or a W?

    • echo /etc/[*TW]!
    • echo /etc/!TW
    • echo /etc/*[TW!]
    • echo /etc/[!TW]*
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments