LINUX File System Overview and Commands
5 Questions
0 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 grep command do by default?

  • Prints out the matching lines. (correct)
  • Counts the number of matches found.
  • Prints the line numbers of matches.
  • Ignores case sensitivity.
  • Which grep option would you use to find lines that do NOT match a specific pattern?

  • -c
  • -n
  • -v (correct)
  • -i
  • How can you ignore case sensitivity in a grep search?

  • By using the -i option. (correct)
  • By using the -v option.
  • By using the -n option.
  • By using the -c option.
  • What is the output of the command 'sort input1.txt input2.txt > output.txt'?

    <p>Sorts the files and saves the output in output.txt.</p> Signup and view all the answers

    Which command is most effective to remove adjacent duplicate lines from a sorted file?

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

    Study Notes

    LINUX File System Overview

    • LINUX uses a hierarchical tree structure for its filesystem, starting from the root directory (/).
    • Each directory can have multiple child directories but only one parent directory.
    • Paths can be absolute (from root) or relative (from the current directory).

    Listing LFS Directories

    • The ls command displays current directory contents; it lists visible files and directories by default.
    • Hidden files (starting with a period) can be shown using ls -a, which lists all entries, including . (current) and .. (parent) directories.

    I-node Structure

    • An i-node is a data structure that stores file metadata, including ownership, location, and pointers to file blocks.
    • Each partition has its own set of i-nodes, allowing files with the same i-node number in different partitions.
    • Use ls -i to display i-node numbers for files in the current directory.
    • Links are a file name combined with an i-node number, allowing access to files from different locations.
    • Hard links are direct duplicates of the original file; symbolic links point to the original file's location.
    • Create symbolic links with ln -s existing_file new_file.

    Finding Files

    • Use the find command to search for files by name within a directory tree.
    • Example to find .txt files: find /home -name "*.txt" -print.
    • Find can filter files by type, permissions, size, etc., and can execute commands on found files with the -exec option.

    Finding Text in Files

    • The grep command searches for text patterns in files.
    • Basic syntax: grep options pattern files, where options can modify behavior (e.g., -c counts matches, -i ignores case).
    • Combine grep with find to search through files in directory trees (e.g., grep hello \find . -name "*.txt" -print``).

    Sorting Files

    • The sort command organizes file contents alphabetically or numerically.
    • To output sorted results to another file, use redirection (e.g., sort input1.txt input2.txt > output.txt).
    • The uniq command removes adjacent duplicate lines from a file, often used after sort for streamlined output (e.g., sort input.txt | uniq > output.txt).

    Studying That Suits You

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

    Quiz Team

    Related Documents

    lab4.docx

    Description

    Explore the structure and commands of the LINUX file system in this quiz. Learn about the hierarchical tree structure, directory relationships, and how to list contents using commands like ls. Test your knowledge on both absolute and relative paths as well.

    More Like This

    File Path Navigation Quiz
    26 questions
    CEST-CE Term_2 GNU/LINUX (Week 4)
    50 questions
    Use Quizgecko on...
    Browser
    Browser