CentralCircle
Jul 22, 2026

red hat linux commands cheat sheet

J

Juwan Hahn III

red hat linux commands cheat sheet

Red Hat Linux Commands Cheat Sheet

Navigating and managing a Red Hat Linux system efficiently requires familiarity with a variety of commands. Whether you're a seasoned system administrator or a beginner, having a comprehensive cheat sheet can significantly streamline your workflow. This guide provides an organized overview of essential Red Hat Linux commands, categorized for easy reference. From system management to networking, file handling, and troubleshooting, you'll find the commands you need to perform common tasks effectively.


Basic System Information Commands

Understanding your system's current state is fundamental. These commands help you gather essential details about your Red Hat Linux environment.

1. Display Kernel and OS Details

  • uname -r: Shows the kernel version.
  • cat /etc/redhat-release: Displays the Red Hat release version.
  • hostnamectl: Provides detailed information about the hostname and OS.

2. Check System Architecture

  • arch: Displays the architecture type.
  • uname -m: Shows machine hardware name.

3. CPU and Memory Usage

  • lscpu: Provides CPU architecture details.
  • free -m: Shows memory usage in megabytes.
  • top: Interactive real-time process viewer.
  • htop (if installed): Enhanced interactive process viewer.

File and Directory Management Commands

Managing files and directories is a core part of Linux administration. Here are essential commands to handle these tasks.

1. Navigating the Filesystem

  • pwd: Prints the current working directory.
  • cd [directory]: Changes directory.
  • ls [options] [directory]: Lists directory contents.

2. File Operations

  • cp [source] [destination]: Copies files or directories.
  • mv [source] [destination]: Moves or renames files/directories.
  • rm [options] file: Removes files or directories (-r for recursive).
  • touch filename: Creates an empty file or updates timestamp.

3. Creating and Extracting Archives

  • tar -cvf archive.tar directory/: Creates a tar archive.
  • tar -xvf archive.tar: Extracts tar archive.
  • zip filename.zip files: Compresses files into ZIP archive.
  • unzip filename.zip: Extracts ZIP archive.

File Permissions and Ownership

Proper permissions are vital for security and functionality.

1. Viewing Permissions

  • ls -l [file]: Displays permissions, owner, and group.

2. Modifying Permissions

  • chmod [permissions] [file]: Changes file permissions.
  • Permissions are represented numerically (e.g., 755, 644) or symbolically (e.g., u+rwx).

3. Changing Ownership

  • chown [owner]:[group] [file]: Changes owner and group.

User and Group Management

Managing users and groups is fundamental for access control.

1. User Commands

  • adduser [username]: Adds a new user.
  • useradd [options] [username]: Creates a user with options.
  • passwd [username]: Sets or updates a user's password.
  • usermod [options] [username]: Modifies user account.
  • userdel [username]: Deletes a user.

2. Group Commands

  • groupadd [groupname]: Creates a new group.
  • groupmod [options] [groupname]: Modifies a group.
  • groupdel [groupname]: Deletes a group.
  • usermod -aG [group] [username]: Adds user to a group.

Package Management with YUM and DNF

Red Hat uses YUM (Yellowdog Updater Modified) or DNF (Dandified YUM) for package management.

1. Installing, Removing, and Updating Packages

  • yum install [package] / dnf install [package]: Installs a package.
  • yum remove [package] / dnf remove [package]: Removes a package.
  • yum update / dnf update: Updates all packages.

2. Searching Packages

  • yum search [keyword] / dnf search [keyword]: Search for packages.

3. Listing Installed Packages

  • yum list installed / dnf list installed: Shows installed packages.

Service and Process Management Commands

Managing services and processes ensures system stability.

1. Managing Services

  • systemctl start [service]: Starts a service.
  • systemctl stop [service]: Stops a service.
  • systemctl restart [service]: Restarts a service.
  • systemctl enable [service]: Enables a service at boot.
  • systemctl disable [service]: Disables a service.
  • systemctl status [service]: Checks status of a service.

2. Managing Processes

  • ps aux: Lists all running processes.
  • top: Interactive process viewer.
  • kill [PID]: Terminates a process by PID.
  • killall [process_name]: Kills all processes matching the name.

Network Configuration and Troubleshooting

Networking is critical; these commands help configure and troubleshoot network issues.

1. Viewing Network Interfaces

  • ip addr: Displays IP addresses assigned to interfaces.
  • ifconfig (deprecated, but still used): Shows network interfaces.

2. Managing Network Services

  • systemctl restart network: Restarts network service.
  • nmcli device status: Shows network device status.

3. Testing Network Connectivity

  • ping [hostname/IP]: Tests connectivity to a host.
  • traceroute [hostname/IP]: Traces route to a host.
  • netstat -tulnp: Lists active network connections and listening ports.
  • ss -tuln: Alternative to netstat for socket statistics.

Disk and Filesystem Management

Managing disk space and filesystems is vital for system health.

1. Disk Usage

  • df -h: Shows disk space usage in human-readable format.
  • du -sh [directory]: Summarizes disk usage of a directory.

2. Managing Partitions and Filesystems

  • lsblk: Lists block devices and partitions.
  • <

    Red Hat Linux commands cheat sheet: An essential guide for system administrators and Linux enthusiasts

    In the realm of Linux system administration, mastering command-line operations is crucial for ensuring efficient management, troubleshooting, and optimization of systems. Red Hat Linux, a leading enterprise Linux distribution, relies heavily on command-line tools to perform a vast array of tasks—from user management to system monitoring. A well-rounded understanding of these commands not only accelerates workflow but also enhances the security and stability of Red Hat environments. This comprehensive cheat sheet aims to serve as a definitive reference, providing detailed explanations and insights into the most vital commands used in Red Hat Linux.


    Understanding the Red Hat Linux Command Line Environment

    Before diving into specific commands, it is important to understand the environment in which these commands operate. Red Hat Linux uses the Bash shell (Bourne Again SHell) as its default command interpreter. Bash provides a powerful interface for executing commands, scripting, and automating tasks.

    The command-line interface (CLI) in Red Hat Linux allows administrators to interact directly with the kernel and underlying system components. This interface provides granular control over system resources, configuration files, and services, making it indispensable for system management, especially in server environments.


    Basic Navigation Commands

    Mastering navigation commands is fundamental to efficiently working within the Linux filesystem.

    1. pwd (Print Working Directory)

    • Purpose: Displays the current directory path.
    • Usage:

    ```bash

    pwd

    ```

    • Explanation: Helps determine where you are within the directory structure, crucial for context during operations.

    2. ls (List Directory Contents)

    • Purpose: Lists files and directories.
    • Options:
    • `-l` : Long listing format, shows permissions, owner, size, timestamp.
    • `-a` : Includes hidden files.
    • `-h` : Human-readable sizes.
    • Usage:

    ```bash

    ls -lah

    ```

    • Explanation: Provides detailed insight into directory contents, aiding in file management.

    3. cd (Change Directory)

    • Purpose: Changes the current directory.
    • Usage:

    ```bash

    cd /path/to/directory

    ```

    • Common Patterns:
    • `cd ..` : Moves up one directory level.
    • `cd ~` : Navigates to the user's home directory.
    • Explanation: Navigational command essential for traversing filesystem hierarchies.

    File and Directory Management Commands

    Efficient file management is core to system administration.

    1. cp (Copy Files and Directories)

    • Purpose: Copies files or directories.
    • Usage:

    ```bash

    cp source_file destination/

    ```

    • Options:
    • `-r` : Recursively copy directories.
    • `-v` : Verbose output.
    • Example:

    ```bash

    cp -r /etc/nginx /backup/

    ```

    • Explanation: Critical for backups and duplicating configurations.

    2. mv (Move or Rename Files)

    • Purpose: Moves or renames files/directories.
    • Usage:

    ```bash

    mv oldname.txt newname.txt

    ```

    • Explanation: Simplifies file organization and renaming tasks.

    3. rm (Remove Files and Directories)

    • Purpose: Deletes files or directories.
    • Options:
    • `-r` : Remove directories and their contents recursively.
    • `-f` : Force deletion without prompt.
    • Usage:

    ```bash

    rm -rf /tmp/testdir

    ```

    • Warning: Use with caution; deletions are irreversible.

    4. mkdir (Make Directory)

    • Purpose: Creates new directories.
    • Usage:

    ```bash

    mkdir new_directory

    ```

    • Options:
    • `-p` : Creates parent directories as needed.
    • Example:

    ```bash

    mkdir -p /var/www/html

    ```

    • Explanation: Useful in preparing directory structures.

    5. find (Search Files)

    • Purpose: Locates files matching criteria.
    • Usage:

    ```bash

    find /var/log -name ".log"

    ```

    • Explanation: Essential for locating files based on name, size, modification time, etc.

    User and Group Management Commands

    Managing user access and permissions is vital for security.

    1. useradd / adduser

    • Purpose: Adds new users.
    • Usage:

    ```bash

    useradd username

    ```

    • Options:
    • `-m` : Creates home directory.
    • `-s` : Specifies login shell.
    • Example:

    ```bash

    useradd -m -s /bin/bash john

    ```

    • Explanation: Automates user creation with custom settings.

    2. passwd

    • Purpose: Changes user passwords.
    • Usage:

    ```bash

    passwd username

    ```

    • Explanation: Enforces password policies and updates access credentials.

    3. userdel

    • Purpose: Deletes users.
    • Usage:

    ```bash

    userdel -r username

    ```

    • Options:
    • `-r` : Removes home directory and mail spool.
    • Explanation: Cleans up user accounts when no longer needed.

    4. groupadd / groupdel / groupmod

    • Purpose: Manages user groups.
    • Usage:

    ```bash

    groupadd groupname

    groupdel groupname

    groupmod -n newgroupname oldgroupname

    ```

    • Explanation: Facilitates group-based permissions management.

    5. usermod

    • Purpose: Modifies user account properties.
    • Usage:

    ```bash

    usermod -aG groupname username

    ```

    • Explanation: Adds users to groups or changes login shells.

    File Permissions and Ownership Commands

    Controlling access rights is fundamental for security.

    1. chmod (Change Mode)

    • Purpose: Changes file/directory permissions.
    • Usage:

    ```bash

    chmod 755 filename

    ```

    • Syntax:
    • Numeric mode (e.g., 755)
    • Symbolic mode (e.g., u+r, g-w)
    • Explanation: Sets read, write, execute permissions for user, group, others.

    2. chown (Change Ownership)

    • Purpose: Changes file owner and group.
    • Usage:

    ```bash

    chown user:group filename

    ```

    • Explanation: Ensures correct ownership for security and access control.

    3. chgrp (Change Group)

    • Purpose: Changes the group ownership of a file.
    • Usage:

    ```bash

    chgrp groupname filename

    ```

    • Explanation: Assigns group-level permissions to files.

    System Monitoring and Performance Commands

    Keeping track of system health is vital for uptime and security.

    1. top / htop

    • Purpose: Displays real-time system resource usage.
    • Usage:

    ```bash

    top

    ```

    or, if installed,

    ```bash

    htop

    ```

    • Features: Shows CPU, memory, process info; `htop` offers a more user-friendly interface.

    2. ps (Process Status)

    • Purpose: Lists active processes.
    • Usage:

    ```bash

    ps aux

    ```

    • Explanation: Provides detailed process info, useful for troubleshooting.

    3. free

    • Purpose: Displays memory usage.
    • Usage:

    ```bash

    free -h

    ```

    • Explanation: Helps monitor RAM and swap utilization.

    4. df (Disk Free)

    • Purpose: Shows disk space usage.
    • Usage:

    ```bash

    df -h

    ```

    • Explanation: Critical for capacity planning and preventing disk exhaustion.

    5. du (Disk Usage)

    • Purpose: Reports directory space consumption.
    • Usage:

    ```bash

    du -sh /var/log/

    ```

    • Explanation: Identifies large directories/files for cleanup.

    Package Management Commands in Red Hat Linux

    Managing software packages is crucial for system updates and security patches.

    1. yum (Yellowdog Updater, Modified)

    • Purpose: Handles package installation, updates, and removal.
    • Common Commands:
    • Installing a package:

    ```bash

    yum install package_name

    ```

    • Removing a package:

    ```bash

    yum remove package_name

    ```

    • Updating all packages:

    ```bash

    yum update

    ```

    • Searching for packages:

    ```bash

    yum search keyword

    ```

    • Listing installed packages:

    ```bash

    yum list installed

    ```

    • Note: As of RHEL 8
    QuestionAnswer
    What are some essential Red Hat Linux commands included in a cheat sheet? Common commands include 'yum' or 'dnf' for package management, 'systemctl' for service management, 'ls' for listing directory contents, 'cd' to change directories, 'pwd' to print working directory, and 'vim' or 'nano' for editing files.
    How can I quickly check the status of a service in Red Hat Linux? Use 'systemctl status service_name' to view the current status of a specific service, for example, 'systemctl status nginx'.
    What command is used to view disk space usage in Red Hat Linux? Use 'df -h' to display disk space usage in a human-readable format.
    How do I list all installed packages on Red Hat Linux? Use 'rpm -qa' to list all installed RPM packages, or 'dnf list installed' if using DNF.
    What is the command to restart a service in Red Hat Linux? Use 'systemctl restart service_name', for example, 'systemctl restart nginx'.
    How can I view network configurations and interfaces quickly? Use 'ip addr' or 'ifconfig' to display network interface details in Red Hat Linux.

    Related keywords: Red Hat Linux, Linux commands, command line, bash scripting, system administration, Linux tutorials, Linux tips, Linux cheat sheet, Linux basics, Linux commands reference