Podcast
Questions and Answers
Match the following commands with their primary function:
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:
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:
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:
Match the following deletion commands with their specific use cases:
Signup and view all the answers
Match the following options with their corresponding command purpose:
Match the following options with their corresponding command purpose:
Signup and view all the answers
Match the following directory creation commands with their descriptions:
Match the following directory creation commands with their descriptions:
Signup and view all the answers
Match the following file operation examples with their commands:
Match the following file operation examples with their commands:
Signup and view all the answers
Match the following commands with their outcomes:
Match the following commands with their outcomes:
Signup and view all the answers
Match the following command syntax with their descriptions:
Match the following command syntax with their descriptions:
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
-
- Examples:
-
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
-
- Examples:
-
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
-
- Examples:
-
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
-
- Examples:
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.
- Example:
-
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
: Copiesfile1
to thedir1
directory -
cp file1 file2
: Creates a copy offile1
with the namefile2
-
cp -r dir1 dir2
: Recursively copiesdir1
todir2
-
- The
-
rm: Removes a file or directory.
-
-i
: Prompts before removing. -
-f
: Forces removal without prompting. -
-r
: Removes directories recursively. - Examples:
-
rm -i file1
: Removesfile1
-
rm -rf dir1
: Recursively removesdir1
-
-
-
mv: Renames or moves files/directories.
-
-i
: Prompts before overwriting. -
-f
: Forces overwriting without prompting. - Examples:
-
mv file1 file2
: Renamesfile1
tofile2
-
mv file1 dir1
: Movesfile1
todir1
-
-
- 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
Using Symbolic Links
- 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 linkitslink
to the filesource_file
.
Hard and Soft Links
- 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.
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.