Module 3
9 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Match the following commands with their primary function:

mkdir = Create a directory cd = Change a directory pwd = Print working directory rmdir = Remove a directory

Match the following file operations with their corresponding commands:

Copying files = cp Removing a file = rm Renaming a file = mv Viewing a file = cat

Match the following directory navigation concepts with their descriptions:

cd .. = Go to the parent directory cd - = Go to the previous directory cd /usr/share = Go to a specific directory cd = Go to the default directory

Match the following deletion commands with their specific use cases:

<p>rmdir = Remove a single directory if empty rm -r = Remove a directory recursively rm = Remove a file or a directory touch = Create an empty file</p> Signup and view all the answers

Match the following options with their corresponding command purpose:

<p>-i = Ask before overwriting or removing -f = Force overwriting or removing -r = Recursively remove a non-empty directory -a = Display all objects' names including hidden</p> Signup and view all the answers

Match the following directory creation commands with their descriptions:

<p>mkdir single = Create a single directory mkdir dir1 dir2 = Create multiple directories mkdir -p grandfather/father/son = Create path of directories mkdir .. = Create a parent directory (invalid command)</p> Signup and view all the answers

Match the following file operation examples with their commands:

<p>cp file1 file2 = Create a copy of the file file1 with a new name file2 rm -rf dir1 = Remove the directory dir1 and all its contents mv file1 dir1 = Move file1 into the directory dir1 touch filename = Create an empty file or update the timestamp of filename</p> Signup and view all the answers

Match the following commands with their outcomes:

<p>ls -R = Display current directory content recursively ls -i = Display objects' names with inode numbers cp -r dir1 dir2 = Copy directory dir1 recursively to dir2 cat = Display the whole content of one or more files</p> Signup and view all the answers

Match the following command syntax with their descriptions:

<p>cp [options] source destination = Copy files or directories rm -[options] f1 f2 ... fn = Remove specified files mv -[options] source destination = Rename or move files/directories touch filename = Create or update a file's timestamp</p> Signup and view all the answers

Study Notes

Working with Files and Directories

  • This module covers commands for interacting with files and directories via command-line mode.
  • Upon completion, users should be able to copy, move/rename, create, remove files/directories, and use symbolic links.

Working with Directories

  • mkdir: Creates a directory. Can create multiple directories or a path of directories using the -p option.
    • Examples:
      • mkdir single
      • mkdir dir1 dir2
      • mkdir -p grandfather/father/son
  • rmdir: Removes a directory. The directory must be empty. Non-empty directories can be removed using rm -r for recursive deletion.
    • Examples:
      • rmdir directory
      • rm -r directory
  • cd: Changes the current directory.
    • Examples:
      • cd: Moves to the default directory
      • cd ..: Moves to the parent directory
      • cd -: Moves to the previous directory
      • cd /usr/share: Changes to the /usr/share directory
  • pwd: Prints the current working directory (full path name).
    • Examples:
      • pwd: Shows the current directory
      • cd /usr/share; pwd: Shows /usr/share after changing to that directory
      • cd ..; pwd: Shows the parent directory after changing

Specific Directories

  • ./: Represents the current directory.
  • ../: Represents the parent directory.
  • Specific directory names (e.g., /share/).

Working with Files

  • ls: Displays directory content. Flags like -a, -l, -i, -R allow more detailed view, including hidden files, long list, inode numbers & recursive view.
    • Example: ls -l - for a long listing.
  • cp: Copies files or directories from a source to a destination.
    • The -i option prompts before overwriting existing files.
    • The -f option forces overwriting existing files.
    • Examples:
      • cp file1 dir1: Copies file1 to the dir1 directory
      • cp file1 file2: Creates a copy of file1 with the name file2
      • cp -r dir1 dir2: Recursively copies dir1 to dir2
  • rm: Removes a file or directory.
    • -i: Prompts before removing.
    • -f: Forces removal without prompting.
    • -r: Removes directories recursively.
    • Examples:
      • rm -i file1: Removes file1
      • rm -rf dir1: Recursively removes dir1
  • mv: Renames or moves files/directories.
    • -i: Prompts before overwriting.
    • -f: Forces overwriting without prompting.
    • Examples:
      • mv file1 file2: Renames file1 to file2
      • mv file1 dir1: Moves file1 to dir1
  • touch: Creates an empty file. Modifies the last access time if the file exists.
  • cat: Displays the content of an ASCII file. Support CTL+C and CTL+S to break and resume on large file display.
  • more: Displays a text file, one screen at a time. Allows using space to move to the next screen and return to move to the next line or use commands like / to search and q to quit.
  • tail: Displays the last part of a file. Default is 10 lines. Includes -n option to specify number lines.
  • head: Displays the first part of a file; similar to tail but displays the first few lines instead of the last few.
  • wc: Counts lines, words, and characters in a file(s). Includes -l (lines), -w (words), -c (byte count), and -m (character count) options.

File System Structure

  • The file system is hierarchical and organized.
  • Rooted at "/".
  • First-level directories exist under the root directory (e.g., /home, /bin).
  • Subsequent levels contain folders and files.
  • The filesystem structures and organization define the location of files, directories, etc. (e.g., path information).

Paths to Objects

  • Paths are sets of directories leading to a specific object.

  • Separated by /.

  • Absolute paths start with /, specifying the full path to an object. - e.g. /usr/share/doc/gnuplot.

  • Relative paths start with a directory name, giving information about the relative location from the current directory to the object. - e.g., ../../var/log/messages

  • Symbolic links are shortcuts to files/directories in different file systems. They do not take up extra disk space.
  • ln -s source_file itslink: Creates a symbolic link itslink to the file source_file.
  • Hard links point to the same data on a storage device. Deleting the original leaves only secondary hard link in place.
  • Soft links point to another filename that in turn points to the data. Deleting the original breaks the symbolic link.
  • Links use a ln command to create the link.

List of Commands

  • Command examples useful for administering file systems (log in, create/delete user, install app, update repository, etc.) are provided.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

Description

This quiz covers essential commands for working with files and directories in command-line mode. Participants will test their knowledge on operations like creating, removing, and navigating through directories and files. Gain confidence in managing your file system effectively.

More Like This

Command Line Navigation Quiz
3 questions
Basic Command Line Operations
10 questions
Module 3 Quiz
10 questions

Module 3 Quiz

SuppleTigerSEye1117 avatar
SuppleTigerSEye1117
Use Quizgecko on...
Browser
Browser