Linux File System Concepts

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 a symbolic link contain?

  • A copy of the original file
  • The complete file system structure
  • A pointer to another file (correct)
  • Actual file data

What is contained within the superblock?

  • File data
  • List of all files
  • User permissions
  • Information about the filesystem (correct)

Which of the following is stored in the inode?

  • A shortcut to the file
  • The Superblock
  • The actual file data
  • File size and data block locations (correct)

What do hard linked files share?

<p>The same inode and inode number (A)</p> Signup and view all the answers

What command is used to create a hard link?

<p><code>ln</code> (C)</p> Signup and view all the answers

Which action reduces the link count for a file?

<p>Deleting a hard linked file (C)</p> Signup and view all the answers

Where must hard linked files reside?

<p>The same filesystem (B)</p> Signup and view all the answers

Which command is used to create a new directory in Linux?

<p>mkdir (B)</p> Signup and view all the answers

What is stored in Data blocks?

<p>Data making up contents of a file (C)</p> Signup and view all the answers

Which command removes empty directories?

<p>rmdir (B)</p> Signup and view all the answers

What is the primary function of the mv command?

<p>Move or rename files and directories (B)</p> Signup and view all the answers

Which command is used to copy files and directories?

<p>cp (C)</p> Signup and view all the answers

Which command displays shell aliases?

<p>alias (B)</p> Signup and view all the answers

Which command removes files?

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

What command is used to display the current umask?

<p>umask (B)</p> Signup and view all the answers

Which command is used to search for files in a pre-made indexed database?

<p>locate (C)</p> Signup and view all the answers

Which command recursively searches for files starting from a specified directory?

<p>find (B)</p> Signup and view all the answers

What is the default permission given to new files?

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

What does the PATH variable contain?

<p>Executable file locations (D)</p> Signup and view all the answers

Which of the following special permissions, when set on a file, allows a user executing the file to become the owner of that file during execution?

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

To what type of files can SUID be applied?

<p>Binary compiled programs (C)</p> Signup and view all the answers

Which command is used to search for an executable file?

<p>which (C)</p> Signup and view all the answers

What is the purpose of the umask variable?

<p>It takes away permissions on new files and directories. (D)</p> Signup and view all the answers

What is the primary function of the mkdir command in Linux?

<p>To create new directories (A)</p> Signup and view all the answers

The mv command requires a minimum of how many arguments?

<p>Two (A)</p> Signup and view all the answers

What is the purpose of the Filesystem Hierarchy Standard (FHS)?

<p>To standardize the directory structure in Linux (A)</p> Signup and view all the answers

Besides moving files, what other function does the mv command perform?

<p>Renaming files (B)</p> Signup and view all the answers

Which of the following is NOT a primary goal of the Filesystem Hierarchy Standard?

<p>Complicating software development (A)</p> Signup and view all the answers

What type of pathnames can the mv command use?

<p>Absolute or relative pathnames (B)</p> Signup and view all the answers

What does the first argument of the mv command specify?

<p>Source file/directory (A)</p> Signup and view all the answers

Which command is used to create directories?

<p><code>mkdir</code> (B)</p> Signup and view all the answers

What does the second argument of the mv command specify?

<p>Target file/directory (A)</p> Signup and view all the answers

What can be used in a pathname for the mv command when moving multiple files?

<p>Wildcards (B)</p> Signup and view all the answers

Which command is used to copy files in Linux?

<p>cp (B)</p> Signup and view all the answers

What option is used with the cp command to copy a directory and its subdirectories?

<p>-r (A)</p> Signup and view all the answers

Which command is used to remove files?

<p>rm (A)</p> Signup and view all the answers

What does interactive mode do when using mv or cp commands?

<p>Prompts the user before overwriting files. (C)</p> Signup and view all the answers

Which option overrides interactive mode and forces the command to proceed?

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

Which command removes a directory only if it is empty?

<p>rmdir (A)</p> Signup and view all the answers

What command displays the aliases present in the current shell?

<p>alias (A)</p> Signup and view all the answers

Which of the following is a valid use of wildcards with the rm command?

<p>rm *.txt (B)</p> Signup and view all the answers

What happens when you use the cp command to copy a file to a location where a file with the same name already exists?

<p>The existing file is overwritten. (A)</p> Signup and view all the answers

If you want to remove a directory that is not empty, which command should you use?

<p>rm -r (B)</p> Signup and view all the answers

Flashcards

Symbolic Link (Symlink)

A pointer or shortcut to another file.

Hard Link

Two files that share the same data and inode.

Superblock

Contains metadata about the filesystem, like the number of inodes and block sizes.

Inode Table

A table of inodes, each describing a file/directory and containing its unique inode number.

Signup and view all the flashcards

Data Blocks

The actual raw bytes that make up the contents of a file.

Signup and view all the flashcards

Inode Number

A unique identifier for a file within a filesystem.

Signup and view all the flashcards

ln command

Command used to create hard or symbolic links.

Signup and view all the flashcards

Hard Link Limitations

Hard links share the same inode and inode number and must be on the same file system.

Signup and view all the flashcards

mkdir

Creates new directories.

Signup and view all the flashcards

rmdir

Removes empty directories.

Signup and view all the flashcards

mv

Moves or renames files and directories.

Signup and view all the flashcards

cp

Copies files and directories.

Signup and view all the flashcards

alias

Displays BASH shell aliases.

Signup and view all the flashcards

rm

Removes files and directories (including those full of files when used with -r or -R).

Signup and view all the flashcards

unlink

Removes files.

Signup and view all the flashcards

locate command

Searches for files in a premade indexed database.

Signup and view all the flashcards

updatedb command

Updates the database used by the locate command.

Signup and view all the flashcards

find command

Recursively searches for files starting from a specified directory.

Signup and view all the flashcards

Numeric Representation of Permissions (Mode)

Represents file permissions as a number; each digit corresponds to user, group, and others, with values derived from summing read (4), write (2), and execute (1) permissions.

Signup and view all the flashcards

umask variable

A special variable that removes permissions from new files and directories upon their creation.

Signup and view all the flashcards

umask command

A command used to view or modify the current umask value, influencing default file permissions.

Signup and view all the flashcards

SUID (Set User ID)

A special permission that allows a file to be executed with the privileges of its owner, rather than the user executing it.

Signup and view all the flashcards

SUID Effect

During execution, the user temporarily becomes the owner of the file.

Signup and view all the flashcards

What is the cp command?

Copies files. Uses the same arguments as the mv command.

Signup and view all the flashcards

What does cp -r do?

Copies a directory, including all files and subdirectories within it.

Signup and view all the flashcards

What happens when copying or moving to an existing file?

The shell warns you and asks if you want to replace the file.

Signup and view all the flashcards

How to view shell aliases?

Type alias at the command prompt.

Signup and view all the flashcards

What is interactive mode?

Prompts the user for confirmation before overwriting files.

Signup and view all the flashcards

What does the -f option do?

Overrides interactive mode, forcing the action to proceed without prompting.

Signup and view all the flashcards

What is the rm command?

Removes (deletes) files.

Signup and view all the flashcards

Arguments for rm?

Lists the files to be removed.

Signup and view all the flashcards

What is the rmdir command?

Removes (deletes) directories.

Signup and view all the flashcards

What's required to remove a directory with rmdir?

It must be empty.

Signup and view all the flashcards

Filesystem Hierarchy Standard (FHS)

A standard that defines the directory structure and file locations in Linux and UNIX-like systems.

Signup and view all the flashcards

mkdir command

Creates a new directory.

Signup and view all the flashcards

Source Pathname

Specifies the original location of the file or directory you want to affect with a command.

Signup and view all the flashcards

Target Pathname

Specifies the new location or name for the file or directory you are affecting with a command.

Signup and view all the flashcards

Absolute Pathname

The complete path to a file or directory, starting from the root directory (/).

Signup and view all the flashcards

Relative Pathname

The path to a file or directory, starting from your current working directory.

Signup and view all the flashcards

Wildcards

Special characters used to match patterns in filenames.

Signup and view all the flashcards

Non-distribution-specific software

Creating software that can be installed on different Linux distributions without modification.

Signup and view all the flashcards

Purpose of the FHS

Standardizes file locations, simplifying file finding and software deployment.

Signup and view all the flashcards

Study Notes

Linux Filesystem Management

  • Covers finding files and directories
  • Includes linking files, understanding the Filesystem Hierarchy Standard
  • Explores managing files and directories with standard Linux commands
  • Explains modifying file and directory ownership
  • Explains defining and change Linux file and directory permissions
  • Shows identifying the default permissions created on files and directories
  • Describes applying special file and directory permissions
  • Covers modifying the default access control list (ACL)
  • Shows how to View and set filesystem attributes

The Filesystem Hierarchy Standard

  • Includes standard set of directories for Linux and UNIX systems
  • Covers standard file and subdirectory contents
  • Simplifies finding specific files
  • Gives Linux software developers the ability to locate files on any Linux system
  • Supports creating non-distribution-specific software

Managing Files and Directories

  • The mkdir command creates new directories, using absolute or relative pathnames
  • The mv (move) command moves files and requires a minimum of two arguments: a source file/directory and a target file/directory
  • Pathnames in mv can be absolute or relative, and wildcards can be used for multiple files; also used to rename files.
  • The cp (copy) command copies files
  • To copy a directory recursively (with all files and subdirectories), use the -r option with cp command.
  • Both the mv and cp commands warn if the target is an existing file and prompt for confirmation in Fedora Linux that has BASH aliases for these commands.
  • To see shell aliases, type alias at the prompt.
  • Interactive mode prompts the user before overwriting files
  • The -f option with rm forces overwriting in interactive mode.
  • The rm (remove) command removes files, and takes a list of files as arguments and can use wildcards.
  • It operates in interactive mode by default, but -f overrides this.
  • The rmdir (remove directory) command removes directories, but only if they are empty

Finding Files

  • The locate command searches for files in the Linux directory tree using a pre-made indexed database
  • Use updatedb command to update the database used by locate
  • The output from locate may require using more or less commands to view
  • The find command recursively searches for files starting from a specified directory
  • Has format: find -criteria .
  • find is slower but more versatile than locate
  • Wildcard metacharacters must be quoted to be interpreted by find.
  • Specifying a subdirectory reduces search time
  • The PATH variable lists directories where executable files are located, allowing them to be run without specifying the full path.
  • The which command searches for an executable file by searching the PATH variable; if not found shows directories searched
  • The type and whereis commands are alternatives to which

Linking Files

  • Files can be linked to each other using symbolic links (symlinks).
  • A symbolic link is a pointer or shortcut to another file
  • Files can be linked to each other using hard links, where two files share the same data
  • Improved understanding of file storage on a filesystem requires defining: superblock, inode tables, and data blocks.
  • The superblock stores filesystem information like the number of inodes and data blocks, as well as the size of each data block
  • The inode table contains inodes, each describing a file or directory with a unique inode number
  • The inode stores file size, data block locations, last date modified, permissions, and ownership
  • Data blocks contain the data making up the contents of a file and are referenced by the inode.
  • Hard linked files share the same inode and inode number and must reside on the same filesystem
  • To create a hard link, use the ln (link) command with two arguments: the existing file and the target file to be created as a hard link
  • Removing a hard linked file reduces the link count for the file
  • Symbolic linked files do not share the same inode and data blocks with their target file
  • A symbolic link is a pointer to its target, storing the pathname to the target file in its data blocks so editing the symbolic link edits the target file
  • If the target file is deleted, the symbolic link become useless.
  • To create a symbolic link, use the -s option with the ln command.
  • Symbolic links can use relative or absolute pathnames and are viewed with ls -l
  • Symbolic links need not reside on the same filesystem as their target

File and Directory Permissions

  • Linux requires users to log in with a username and password.
  • Usernames and group memberships determine access to resources based on required permissions.

File and Directory Ownership

  • During file creation, the user's name and primary group become the owner and group owner
  • The same applies for directory creation
  • whoami command shows the current user name
  • groups command shows group memberships and primary group
  • touch command creates an empty file.
  • The chown (change owner) command changes the ownership of a file or directory specified by two arguments, New owner, and file or directory to change
  • The -R option with chown changes permissions recursively throughout the directory tree.
  • chgrp changes the group owner of a file or directory, using the same arguments and options as chown.

Managing File and Directory Permissions

  • The mode is the inode section that stores permissions for the user (owner), group owner, and others (everyone)
  • Read, write, and execute are the three regular permissions that may be assigned to each user
  • The mode order is user, group, other.
  • The system assigns the first set of permissions that are matched
  • Focus on assigning permissions to the user and group, not just to "other"

Interpreting Permissions

  • Read permission allows a user to open and read the file's contents
  • Write permission allows a user to open, read, and edit file contents
  • Execute permission allows a user to run the file in memory if it is a program or script
  • Read permission on a directory lets a user list the contents when execute is granted
  • Write permission on a directory lets a user add or remove files and requires execute
  • Execute permission on a directory lets a user enter the directory and work with its contents

Changing Permissions

  • The chmod (change mode) command changes the permissions (mode) of files or directories
  • The chmod command has at least two arguments, criteria used to change permissions and the filenames to change
  • When permissions are the same for all categories, use the "a" character to apply to all categories
  • The values:
    • u (user) - + (adds permission)
    • g (group) - -(removes permission)
    • o (other) - = (makes permission equal to)
    • a (all categories)
  • Permissions:
    • r (read)
    • w (write)
    • x (execute)
  • Numeric representation of the mode
    • User, group, other
    • Values for each, 4 read, 2 write, 1 execute
    • The mode number is the sum of these values

Default Permissions

  • New files have rw-rw-rw- permissions by default
  • New directories have rwxrwxrwx permissions by default
  • The umask variable is a special variable that takes away permissions on new files and directories.
  • umask command is used to display the umask
  • To change the umask, set a new umask as an argument to the umask command.

Special Permissions

  • These include SUID, SGID, and the sticky bit

Defining special permissions

  • If SUID is set on a file, the user executing it gains ownership during execution (e.g., passwd command).
  • SUID has no function on directories and only works on binary compiled programs, not shell scripts.
  • SGID is applicable to both files and directories.
  • If set on a file, the executing user becomes a member of the file's group.
  • With SGID set on a directory, file creations in that directory are set to the directory's group owner, not the user's primary group
  • The sticky bit was used to lock files in memory, but is currently limited to directories.
  • It ensures users with write permissions can only delete their own files

Setting Special Permissions

  • Special permissions require execute permissions
  • They mask the execute permission when displayed with Is –l command
  • May be set even if file or directory does not have execute permission
  • Indicating letter in the mode will be capitalized
  • Special persmissions added via chmod command

Setting Custom Permissions in Access Control List (ACL)

  • An ACL is a list of users or groups that you can assign permissions to
  • The setfacl command is used to modify ACL entries for a Linux file or directory, using the -m option
  • Use the -b option to remove all extra ACL assignments on a particular file or directory
  • The getfacl command lists all additional entries in the ACL

Managing Filesystem Attributes

  • Linux files have settable attributes separate from Linux permissions
  • These attributes are specific to the filesystem
  • The lsattr command lists filesystem attributes
  • Thechattr command adds or removes filesystem attributes.
  • The immutable attribute (i) prevents a files from being modified.

Studying That Suits You

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

Quiz Team

Related Documents

More Like This

EXT File System Overview
12 questions

EXT File System Overview

MesmerizingChocolate avatar
MesmerizingChocolate
CEST-CE Term_2 GNU/LINUX (Week 4)
50 questions
User and Group Permissions
10 questions

User and Group Permissions

StylishSpessartine avatar
StylishSpessartine
Systèmes de fichiers Linux - Concepts Clés
41 questions
Use Quizgecko on...
Browser
Browser