Module 3 Quiz
10 Questions
2 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

What command would you use to create a directory called 'projects'?

You would use the command mkdir projects.

How can you remove a non-empty directory?

You can remove a non-empty directory with the command rm -r directory_name.

What are the commands to navigate to the parent directory and print the working directory?

Use cd .. to go to the parent directory and pwd to print the working directory.

Which command allows you to view the contents of a text file in a paginated format?

<p>The command <code>more filename.txt</code> allows you to view the contents in a paginated format.</p> Signup and view all the answers

What command is used to copy a file named 'report.txt' to a directory called 'archives'?

<p>You would use the command <code>cp report.txt archives/</code>.</p> Signup and view all the answers

What command would you use to view all files, including hidden ones, in a long list format?

<p>You would use the command <code>ls -al</code>.</p> Signup and view all the answers

Which option with the rm command would allow you to recursively remove a non-empty directory?

<p>You would use the <code>-r</code> option.</p> Signup and view all the answers

How can you copy a file called 'file1' to a directory named 'dir1'?

<p>You would use the command <code>cp file1 dir1</code>.</p> Signup and view all the answers

What is the purpose of the touch command in file management?

<p>The <code>touch</code> command creates an empty file or updates the last access date of an existing file.</p> Signup and view all the answers

What command should be used to rename 'file1' to 'file2'?

<p>You should use the command <code>mv file1 file2</code>.</p> Signup and view all the answers

Study Notes

Working with Files and Directories

  • The module introduces commands for interacting with files and directories via command-line mode.
  • Students should be able to copy, move/rename, create, remove files and directories, and use symbolic links after completing the module.

Working with Directories

  • mkdir: creates a directory
  • rmdir: removes an empty directory
  • cd: changes the current directory
  • pwd: prints the current working directory
  • mkdir single creates a directory called "single"
  • mkdir dir1 dir2 creates two directories: "dir1" and "dir2"
  • mkdir -p grandfather/father/son creates a series of directories, including intermediate ones if they don't exist.
  • Non-empty directories can be removed using the rm command with the -r option (recursive).
  • rmdir directory removes a directory named "directory" (only if empty).
  • rm -r directory removes a non-empty directory named "directory".
  • cd changes to the default directory.
  • cd .. changes to the parent directory.
  • cd - changes to the previous directory.
  • cd /usr/share changes to the /usr/share directory.

Specific Directories

  • . represents the current directory.
  • .. represents the parent directory.
  • cd share/ navigates to the share directory.
  • cd ../usr/include/ navigates to the usr/include directory.

Working with Files

  • ls: views directory content
  • cp: copies files or directories from a source to a destination
  • rm: removes files or directories
  • mv: renames or moves files or directories
    • mv names.txt fullnames.txt renames names.txt to fullnames.txt
    • mv [filename] [dest-dir] moves a file to a different directory
  • touch: creates an empty file
  • cat: displays the contents of an ASCII file
  • more: displays the contents of a text file one screen at a time
  • tail, head: view the tail (last lines) or head (first lines) of an ASCII file
  • ls -I displays all objects (hidden and non-hidden)
  • ls -a displays all objects, including hidden ones
  • ls -l displays a long listing of objects (including permissions details)
  • ls -al displays a long listing of all objects, including hidden ones
  • ls -i displays the objects along with their inode numbers.
  • ls -R displays the contents of the current directory recursively

Working with Files (cp)

  • cp: copies files or directories
  • The -i option prompts before overwriting an existing file
  • The -f option forces overwriting, without prompts
  • cp file1 dir1 copies file1 into the dir1 directory
  • cp file1 file2 creates a copy of file1 with the name file2.
  • cp -r dir1 dir2 copies the directory dir1 recursively into directory dir2.

Working with Files (rm)

  • rm: removes files or directories
  • The -i option prompts for confirmation before removing
  • The -f option forces removal without confirmation
  • The -r option is used for recursively removing non-empty directories.

Working with Files (mv)

  • mv: renames or moves files or directories
  • The -i option prompts before overwriting
  • The -f option forces overwriting

Working with Files (touch)

  • touch: creates an empty file, or updates the timestamp of an existing file.

Working with Files (counting)

  • wc: counts lines, words, and characters in files.
  • wc -l counts lines
  • wc -w counts words
  • wc -c counts bytes
  • wc -m counts characters

File System Structure

  • The file system is hierarchical.
  • The root directory is /.
  • Subdirectories like /etc, /bin, /tmp, and /home reside under the root.
  • Files and directories are organized in various levels.

Paths to Objects

  • A path specifies how to locate a file or directory in the file system.
  • Absolute paths begin with the root directory (/).
  • Relative paths start from the current directory.
  • Separators in paths is /
  • Symbolic links are shortcuts that point to files or directories that are located elsewhere.
    • They don't consume extra disk space
    • If the original is deleted the symbolic link is broken
  • Hard links point directly to data on a storage device.
  • Soft links point to another name, which in turn points to the desired data.
  • A file has one original hard link. Inodes.
  • Deleting the original source file breaks the symbolic link.

List of Commands

  • sudo su Logs in as admin
  • adduser username Adds a new user
  • su – username Logs in as a new user
  • apt-get install nameofpackage Installs an app
  • pip install nameofpackage Installs an app or package
  • apt-get update Updates the package list

Module Summary

  • This module provides basic commands for file and directory management. Includes copying, moving, creating, removing, and working with symbolic links.

Learning Resources

  • Information for further study and understanding. Includes links to manuals, tutorials, and websites.

Studying That Suits You

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

Quiz Team

Related Documents

Description

This quiz tests your knowledge of file and directory management commands used in command-line mode. Topics include creating, removing, and navigating directories, as well as file manipulation techniques. Prepare to demonstrate your understanding of essential commands like mkdir, rmdir, and cd.

More Like This

Use Quizgecko on...
Browser
Browser