Basic Unix Shell Commands Quiz
11 Questions
1 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 does the ls command do?

Lists files and directories within the current directory.

Which command is used to make a new directory?

  • ls
  • mkdir (correct)
  • rmdir
  • cd
  • The rmdir command can remove non-empty directories.

    False

    What is the purpose of the cd command?

    <p>Change the current working directory</p> Signup and view all the answers

    What does the cat command do?

    <p>Displays the contents of a file, concatenates multiple files, and can create new files.</p> Signup and view all the answers

    What does the touch command do?

    <p>Updates the timestamps of a file or creates an empty file if it doesn't exist.</p> Signup and view all the answers

    What does the file command do?

    <p>Identifies the type of a file.</p> Signup and view all the answers

    Which option with the wc command counts the number of lines?

    <p>-l</p> Signup and view all the answers

    What does the sort command do?

    <p>Sorts the lines in a text file.</p> Signup and view all the answers

    What is the purpose of the grep command?

    <p>To search for patterns within files</p> Signup and view all the answers

    Which command can be used to estimate file space usage?

    <p>du</p> Signup and view all the answers

    Study Notes

    Unix Shell Commands Overview

    • ls (List Directory Contents): Lists files and directories in the current working directory.

      • ls -l: Long format showing file permissions, link count, owner, group, size, and timestamp.
      • ls -a: Displays all files, including hidden ones (those starting with a dot).
      • ls -h: Formats file sizes to be human-readable (KB, MB).
    • mkdir (Make Directory): Creates new directories.

      • Usage: mkdir [directory_name] for a single directory, or mkdir -p [path] for nested directories.
    • rmdir (Remove Directory): Deletes empty directories.

      • Usage: rmdir [directory_name] needs the directory to be empty; non-empty directories require rm -r.
    • cd (Change Directory): Alters the current working directory.

      • cd [directory_name]: Enter a specified directory.
      • cd ..: Move up one directory level.
      • cd ~: Go to the user's home directory.
      • cd -: Return to the previous directory.
    • cat (Concatenate and Display Files): Shows file contents and concatenates multiple files.

      • cat [file_name]: Displays a single file's contents.
      • cat [file1] [file2] > [newfile]: Merges two files into a new file.
      • cat > [newfile]: Creates a new file and enters content (exit with Ctrl+D).
    • banner (Create a Large Banner): Produces ASCII-art style text banners.

      • Usage: banner [text] outputs the specified text in a large format.
    • touch (Change File Timestamps or Create Empty Files): Updates file timestamps or creates empty files.

      • Usage: touch [file_name] either creates an empty file or modifies the timestamp of an existing file.
    • file (Determine File Type): Identifies and displays the type of a given file.

      • Usage: file [file_name] outputs the file type (text, binary, directory, etc.).
    • wc (Word, Line, Character, and Byte Count): Counts text elements in files.

      • wc -l: Counts lines.
      • wc -w: Counts words.
      • wc -c: Counts bytes.
      • wc [file_name]: Shows counts for lines, words, and bytes in the specified file.
    • sort (Sort Text Files): Arranges lines of text in files.

      • sort [file_name]: Sorts alphabetically by default.
      • sort -r [file_name]: Sorts in reverse order.
      • sort -n [file_name]: Sorts numerically.
    • cut (Remove Sections from Each Line of Files): Extracts specific portions from lines of a file.

      • cut -d [delimiter] -f [field_number] [file_name]: Extracts fields using a specified delimiter.
      • cut -c [start]-[end] [file_name]: Extracts characters from defined positions.
    • dd (Convert and Copy a File): Performs low-level file copying and conversion.

      • dd if=[source_file] of=[destination_file]: Copies a file from source to destination.
      • dd if=/dev/zero of=[file_name] bs=[block_size] count=[count]: Generates a file filled with zeros.
    • dfspace (Show Disk Space Usage): Used to show disk space usage (deprecated).

      • Current command: df -h for human-readable disk space statistics.
    • du (Estimate File Space Usage): Displays disk usage of files and directories.

      • du -h: Shows sizes in a human-readable format.
      • du -s [directory_name]: Reports total size of a specified directory.
    • ulimit (User Limits): Manages system-wide resource limits for users.

      • ulimit -a: Displays all current resource limits.
      • ulimit -c [size]: Sets limit for core file size.
      • ulimit -n [number]: Sets maximum number of open files.

    grep Command

    • grep: Stands for "Global Regular Expression Print"; used to search for specific patterns in files.
    • Recognized as a powerful command for text searching in Unix.

    Studying That Suits You

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

    Quiz Team

    Description

    Test your knowledge on basic Unix shell commands such as 'ls'. This quiz includes various options and their uses, aiding in understanding file and directory management. Perfect for beginners looking to grasp the essentials of Unix command line operations.

    More Like This

    Linux Midterm Review  3
    30 questions

    Linux Midterm Review 3

    LuxuryAbundance avatar
    LuxuryAbundance
    UNIX BASH Grundlagen
    13 questions

    UNIX BASH Grundlagen

    RevolutionaryFern2779 avatar
    RevolutionaryFern2779
    Shell et Commandes UNIX - Chapitre 2
    8 questions
    Systèmes d'exploitation UNIX
    42 questions

    Systèmes d'exploitation UNIX

    SumptuousRuthenium2479 avatar
    SumptuousRuthenium2479
    Use Quizgecko on...
    Browser
    Browser