Linux File System and Commands
10 Questions
0 Views

Linux File System and Commands

Created by
@StylishSpessartine

Questions and Answers

Match the command with its function:

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

Match the output with the corresponding command:

cd .. = ahmed@the-game:/mnt/collection1> cd ~ = ahmed@the-game:~> pwd = /mnt/collection1/ogg rmdir student = The directory will be deleted

Match the command with its usage:

mkdir student/language/Pascal = Create a subdirectory in language cd /mnt/collection1/ogg = Change to a specific directory cd .. = Change to parent directory rm -r teacher = Delete a directory with contents

Match the directory change command with the description:

<p>cd directory = Change to named directory cd .. = Change to parent directory cd = Change to home directory cd ~ = Change to home directory</p> Signup and view all the answers

Match the example with the respective command:

<p>ahmed@the-game:<del>&gt; cd ahmed = Change to a named directory ahmed@the-game:/mnt/collection1/ogg&gt; pwd = Output the current directory ahmed@the-game:/mnt/collection1/ogg&gt; cd .. = Change to parent directory ahmed@the-game:</del>&gt; rmdir student = Remove a directory</p> Signup and view all the answers

Match the command with its requirement:

<p>rmdir = Requires the directory to be empty rm -r = Can remove directories with contents mkdir = No pre-existing directory requirement cd = No directory requirement if using ~</p> Signup and view all the answers

Match the output with the corresponding command:

<p>pwd = /home/mohd cd /mnt/collection1/ogg = ahmed@the-game:/mnt/collection1/ogg&gt; cd .. = ahmed@the-game:/mnt/collection1&gt; rmdir student = The directory will be deleted</p> Signup and view all the answers

Match the command with its result:

<p>cd .. = Navigate to the parent directory cd ~ = Return to the user's home directory rmdir student = Delete the student directory if empty rm -r teacher = Delete teacher directory and its contents</p> Signup and view all the answers

Match the command with its effect:

<p>mkdir student/language/Pascal = Creates 'Pascal' directory under 'language' cd directory = Enters the specified directory cd - = Returns to the previous directory rmdir student = Removes the directory 'student'</p> Signup and view all the answers

Match the command with its appropriate action:

<p>pwd = Displays the current working directory cd = Navigates to a specified directory rmdir = Removes an empty directory rm -r = Deletes a directory along with its contents</p> Signup and view all the answers

Study Notes

Linux File System and Commands

  • Linux file system allows for structured storage of information using files consisting of bits ('0' or '1').
  • Rules for naming files in Linux include:
    • No spaces allowed; use underscores instead.
    • Names must start with an alphabet character.
    • Special characters like $, *, %, @, /, etc., are not permitted.
    • File names are case-sensitive (e.g., "City", "city", and "CITY" are distinct).

File Creation and Management

  • Use cat command to create a file:

    • Syntax: $ cat > file_name
    • Save contents with Ctrl + D to exit.
    • Example: $ cat > city.txt creates a text file named city.txt.
  • Display file contents:

    • Use cat file_name to view contents on the screen.

Editing and Modifying Files

  • Add data to an existing file:

    • Use cat command and save with Ctrl + D.
  • Display contents of multiple files:

    • Use $ cat file1 file2 to view combined contents.
  • Create an empty file:

    • Use touch command: $ touch filename.

Viewing File Contents

  • Use more to view file contents one screen at a time, with options for line numbers and screen size.

Moving and Renaming Files

  • Use mv command for moving and renaming files:
    • Syntax: $ mv [options] source destination.
    • Moving example: $ mv ~/temp/file.txt . moves a file to the current directory.
    • Renaming example: $ mv file.txt ~/temp/file2.txt renames a file.

Copying Files

  • Use cp command to copy files or directories:
    • Syntax: $ cp [options] source destination.
    • Copying example: $ cp file.txt ~/temp/ copies file to a directory.

File Deletion

  • Use rm command to delete files:
    • Syntax: $ rm [options] file(s).
    • Example: $ rm file1.txt deletes a specified file.

Working with Directories

  • Creating directories:

    • Use mkdir directory-name to create new directories (e.g., $ mkdir student).
    • Create multiple directories at once: $ mkdir student teacher administration.
  • Change directories:

    • Use $ cd directory to navigate into a directory.
    • Use $ cd .. to go to the parent directory.
    • $ cd or $ cd ~ returns to the home directory.
  • Display current directory:

    • Use pwd command to show the current working directory path.

Removing Directories

  • Use rmdir to remove empty directories:
    • Example: $ rmdir student.
  • To delete a directory and its contents, use:
    • $ rm -r directory_name (use cautiously).

Summary

  • Mastering these commands enhances efficiency in managing files and directories on Linux.
  • Familiarization with command-line syntax is crucial for effective use of the operating system.

Studying That Suits You

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

Quiz Team

Description

Test your knowledge on the Linux file system and command usage. This quiz covers the essential rules for naming files in Linux, including naming conventions and case sensitivity. Challenge yourself to understand file creation and management in Linux.

More Quizzes Like This

Command Line Navigation Quiz
3 questions
Linux Command Line Basics
9 questions

Linux Command Line Basics

SmootherTsavorite avatar
SmootherTsavorite
Linux File System Management
10 questions

Linux File System Management

PanoramicManticore9929 avatar
PanoramicManticore9929
Aperçu des commandes Linux
8 questions

Aperçu des commandes Linux

WellBalancedConnemara8768 avatar
WellBalancedConnemara8768
Use Quizgecko on...
Browser
Browser