File System Administration

InfraboyInfraboy
4 min read

list of commands related to file system administration, managing files and directories, understanding file permissions and ownership, using basic file manipulation commands, and managing hard and symbolic links in Red Hat Enterprise Linux (RHEL).

File System Administration

  1. Mounting and Unmounting File Systems

    • mount [options] device directory: Mount a file system.

    • umount [options] directory|device: Unmount a file system.

    • df [options]: Report file system disk space usage.

    • du [options] [path]: Estimate file space usage.

  2. Creating and Managing File Systems

    • mkfs [options] device: Create a file system.

    • mkfs.ext4 device: Create an ext4 file system.

    • tune2fs [options] device: Adjust tunable file system parameters.

  3. File System Checking and Repair

    • fsck [options] device: File system consistency check and repair.

    • e2fsck [options] device: Check an ext2/ext3/ext4 file system.

  4. Monitoring File System Usage

    • df -h: Display disk space usage in human-readable format.

    • du -sh [path]: Display total disk space usage for a directory.

Managing Files and Directories

  1. Listing Files and Directories

    • ls [options] [path]: List directory contents.

    • ls -l: List with detailed information.

    • ls -a: List all files including hidden files.

    • ls -lh: List with human-readable file sizes.

  2. Copying Files and Directories

    • cp [options] source destination: Copy files or directories.

    • cp -r source destination: Copy directories recursively.

  3. Moving and Renaming Files and Directories

    • mv [options] source destination: Move or rename files or directories.
  4. Removing Files and Directories

    • rm [options] file: Remove files.

    • rm -r directory: Remove directories recursively.

  5. Creating Directories

    • mkdir [options] directory: Create directories.

    • mkdir -p directory: Create nested directories.

  6. Removing Directories

    • rmdir directory: Remove empty directories.

Understanding File Permissions and Ownership

  1. Viewing File Permissions

    • ls -l [path]: List files with permissions.
  2. Changing File Permissions

    • chmod [options] mode file: Change file permissions.

    • chmod u+x file: Add execute permission for the user.

    • chmod g-w file: Remove write permission for the group.

    • chmod o=r file: Set read-only permission for others.

    • chmod 755 file: Set file permissions using numeric mode.

  3. Changing File Ownership

    • chown [options] owner:group file: Change file owner and group.

    • chown user file: Change file owner.

    • chgrp group file: Change file group.

Using Basic File Manipulation Commands

  1. Listing Files and Directories

    • ls [options] [path]: List directory contents.
  2. Copying Files

    • cp [options] source destination: Copy files.
  3. Moving and Renaming Files

    • mv [options] source destination: Move or rename files.
  4. Removing Files

    • rm [options] file: Remove files.
  5. Creating Directories

    • mkdir [options] directory: Create directories.
  6. Removing Directories

    • rmdir directory: Remove empty directories.
  1. Creating Hard Links

    • ln [options] target link: Create a hard link.
  2. Creating Symbolic (Soft) Links

    • ln -s [options] target link: Create a symbolic link.
  3. Viewing Links

    • ls -l [path]: List files with link information.
  4. Removing Links

    • rm [options] link: Remove links.

Here's a summary of the commonly used commands:

shellCopy code# File System Administration
mount /dev/sda1 /mnt            # Mount file system
umount /mnt                     # Unmount file system
df -h                           # Display disk space usage
du -sh /path/to/dir             # Estimate directory space usage

# Managing Files and Directories
ls -l                           # List directory contents with details
cp file1 file2                  # Copy file1 to file2
cp -r dir1 dir2                 # Copy directory dir1 to dir2
mv file1 file2                  # Move or rename file1 to file2
rm file                         # Remove file
rm -r dir                       # Remove directory dir recursively
mkdir newdir                    # Create new directory
rmdir emptydir                  # Remove empty directory

# Understanding File Permissions and Ownership
ls -l file                      # View file permissions
chmod u+x file                  # Add execute permission for user
chmod 755 file                  # Change file permissions using numeric mode
chown user:group file           # Change file owner and group
chgrp group file                # Change file group

# Managing Links
ln target link                  # Create hard link
ln -s target link               # Create symbolic link
ls -l link                      # View link information
rm link                         # Remove link
0
Subscribe to my newsletter

Read articles from Infraboy directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Infraboy
Infraboy

We will provide all kinds of the note which is related to IT infra courses like : Networking , Cloud Computing , AWS , CEH , Cyber Security