Linux Basics: Commands Overview
10 Questions
1 Views

Linux Basics: Commands Overview

Created by
@EfficientForethought2795

Questions and Answers

What option for the 'ls' command allows you to see hidden files?

  • -h
  • -a (correct)
  • -r
  • -l
  • Which command will overwrite a file without prompting unless the interactive option is used?

  • mv (correct)
  • cp
  • ls
  • cat
  • What does the 'tail -f' command do?

  • Views file content line by line.
  • Follows the end of a file in real-time. (correct)
  • Displays the last 10 lines of a file.
  • Displays the first few lines of a file.
  • Which of the following commands would you use to display detailed information about currently running processes?

    <p>ps -ef</p> Signup and view all the answers

    What is the primary difference between the 'more' and 'less' commands?

    <p>Less allows for backward navigation while more does not.</p> Signup and view all the answers

    Which option with the 'cp' command is used to ensure that you only copy files that are newer than those in the destination?

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

    How do you exit from the 'more' command interface?

    <p>Press 'q'</p> Signup and view all the answers

    What does the '-b' option do when used with the 'cat' command?

    <p>Numbers non-blank output lines.</p> Signup and view all the answers

    What is the default number of lines displayed by the 'head' command?

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

    Which command is used to view the contents of files within the terminal?

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

    Study Notes

    Linux Basics and Commands

    ls (List)

    • Displays the contents of a directory.
    • Common options:
      • -l: Long listing format (detailed view).
      • -a: Include hidden files (starting with .).
      • -h: Human-readable file sizes.

    mv (Move/Rename)

    • Moves or renames files or directories.
    • Syntax: mv [source] [destination]
    • Overwrites files without warning unless the -i (interactive) option is used.

    cat (Concatenate)

    • Displays the contents of files to the standard output.
    • Can also concatenate multiple files.
    • Syntax: cat [file1] [file2] ...
    • Common options:
      • -n: Number all output lines.
      • -b: Number non-blank output lines.

    cp (Copy)

    • Copies files and directories.
    • Syntax: cp [source] [destination]
    • Common options:
      • -r: Recursively copy directories.
      • -i: Interactive mode, prompts before overwrite.
      • -u: Copies only when the source file is newer.

    more (View File Content)

    • Views text files one screen at a time.
    • Scroll down using the spacebar; press Enter to scroll line by line.
    • To exit, press q.

    less (View File Content)

    • Similar to more but allows backward and forward navigation.
    • Scrolling:
      • Up/Down arrow keys or PgUp/PgDn.
      • Search using /[pattern] and press n to find the next occurrence.
    • To exit, press q.

    tail (View End of File)

    • Displays the last part of a file.
    • Default shows the last 10 lines.
    • Common options:
      • -n [number]: Specify number of lines to display.
      • -f: Follow a file in real-time (useful for logs).

    head (View Start of File)

    • Displays the beginning part of a file.
    • Default shows the first 10 lines.
    • Common option:
      • -n [number]: Specify number of lines to display from the top.

    ps (Process Status)

    • Displays currently running processes.
    • Common options:
      • aux: Shows all users' processes.
      • -ef: Extended format, detailed information.
    • Useful for monitoring system activity and managing tasks.

    Linux Basics and Commands

    ls (List)

    • Lists directory contents, showing files and subdirectories.
    • Options for customization:
      • -l: Provides a long listing format for detailed file information, including permissions and ownership.
      • -a: Shows all files, including hidden ones that start with a dot.
      • -h: Displays file sizes in a human-readable format (e.g., KB, MB).

    mv (Move/Rename)

    • Facilitates moving or renaming files and directories.
    • Command syntax: mv [source] [destination].
    • By default, overwrites existing files without a warning; use -i to enable interactive mode for confirmation before overwriting.

    cat (Concatenate)

    • Outputs the contents of files directly to the terminal.
    • Supports concatenation of multiple files in one command.
    • Options include:
      • -n: Adds line numbers to all output lines.
      • -b: Numbers only non-blank output lines.

    cp (Copy)

    • Copies files and directories from one location to another.
    • Command syntax: cp [source] [destination].
    • Options for enhanced functionality:
      • -r: Enables recursive copying of directories and their contents.
      • -i: Activates interactive mode, prompting before overwriting.
      • -u: Copies only if the source file is newer than the destination file.

    more (View File Content)

    • Displays content of text files, allowing user to scroll through them one screen at a time.
    • Use spacebar to scroll down a page and Enter for line-by-line navigation; press q to exit.

    less (View File Content)

    • Offers enhanced file viewing compared to more, with both forward and backward scrolling capabilities.
    • Scrolling options include Up/Down arrow keys or PgUp/PgDn.
    • Searching can be done using /[pattern], with the n key to jump to the next occurrence; exit with q.

    tail (View End of File)

    • Displays the last section of a text file, defaulting to the last 10 lines.
    • Option for custom line display:
      • -n [number]: Specifies exact number of lines shown.
      • -f: Follows updates to the file in real-time, particularly useful for monitoring logs.

    head (View Start of File)

    • Outputs the first section of a text file, also defaulting to the first 10 lines.
    • Customization available with the option:
      • -n [number]: Specify how many lines to display from the start.

    ps (Process Status)

    • Displays information on currently running processes in the system.
    • Useful options for detailed views:
      • aux: Lists processes for all users.
      • -ef: Presents an extended format, providing detailed process information.
    • Essential for system monitoring and effective task management.

    Studying That Suits You

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

    Quiz Team

    Description

    This quiz covers fundamental Linux commands including ls, mv, cat, cp, and more. You will learn how to list, move, rename, concatenate, and copy files and directories using these essential commands. Test your knowledge and improve your Linux skills!

    More Quizzes Like This

    Quiz de Comandos y Linux
    6 questions
    Linux Directory and File Commands Lab
    10 questions
    Unix File Management Basics
    37 questions
    Linux Befehle und Dateiverwaltung
    27 questions
    Use Quizgecko on...
    Browser
    Browser