Basic Unix Shell Commands Quiz

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

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 (B)

What is the purpose of the cd command?

<p>Change the current working directory (A)</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 (C)</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 (B)</p> Signup and view all the answers

Which command can be used to estimate file space usage?

<p>du (D)</p> Signup and view all the answers

Flashcards

ls Command

Lists files and directories in the working directory.

mkdir Command

Creates new directories.

rmdir Command

Deletes empty directories.

cd Command

Alters the current working directory.

Signup and view all the flashcards

cat Command

Shows file contents and concatenates files.

Signup and view all the flashcards

banner Command

Creates ASCII art text banners.

Signup and view all the flashcards

touch Command

Updates file timestamps or creates empty files.

Signup and view all the flashcards

file Command

Identifies and shows the type of a file.

Signup and view all the flashcards

wc Command

Counts text elements in files.

Signup and view all the flashcards

sort Command

Arranges lines of text in files.

Signup and view all the flashcards

grep Command

Searches for specific patterns in files.

Signup and view all the flashcards

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

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
Systèmes d'exploitation UNIX
42 questions

Systèmes d'exploitation UNIX

SumptuousRuthenium2479 avatar
SumptuousRuthenium2479
Use Quizgecko on...
Browser
Browser