Linux Commands For Admins

 

System & Process Management

  1. top – Monitor processes
    Example: top
    View CPU and memory usage in real-time.

  2. htop – Enhanced process monitor
    Example: htop
    (If not installed: sudo dnf install htop)
    Use arrow keys to navigate processes interactively.

  3. ps aux – Show all running processes
    Example: ps aux | grep firefox
    Check if Firefox is running.

  4. systemctl status – Check service status
    Example: systemctl status sshd
    See if the SSH service is active.

  5. journalctl -xe – View logs
    Example: journalctl -xe
    View system error logs when debugging failures.

  6. uptime – How long the system has been up
    Example: uptime
    Useful for checking server availability.

  7. free -h – View memory usage
    Example: free -h
    Helps when diagnosing performance issues.

  8. df -h – Check disk space
    Example: df -h /home
    Check available space on /home.

  9. du -sh * – Show size of folders
    Example: du -sh /var/log/*
    Find which log folder is taking the most space.


Package Management (DNF)

  1. sudo dnf update – Update package info
    Example: sudo dnf update
    Update the local package database.

  2. sudo dnf upgrade – Upgrade all packages
    Example: sudo dnf upgrade
    Install the latest software and security updates.

  3. sudo dnf install <package> – Install packages
    Example: sudo dnf install git
    Install Git on your system.

  4. sudo dnf remove <package> – Uninstall packages
    Example: sudo dnf remove gedit
    Remove the Gedit text editor.

  5. dnf list installed – List all installed packages
    Example: dnf list installed | grep nginx
    Check if nginx is installed.

  6. dnf search <term> – Search for packages
    Example: dnf search vscode
    Look for available Visual Studio Code packages.


Networking

  1. ip a – Show network interfaces
    Example: ip a
    Get your IP address and network interface info.

  2. ping <host> – Check connectivity
    Example: ping google.com
    Verify internet connection.

  3. curl <url> – Download web data
    Example: curl https://api.ipify.org
    Display your public IP address.

  4. ss -tuln – View open ports
    Example: ss -tuln
    Check which services are listening for connections.

  5. nmcli – Manage network connections
    Example: nmcli device status
    List all network devices and their states.


File & Directory Operations

  1. ls -lah – List detailed files
    Example: ls -lah /var/log
    View size, ownership, and permissions of logs.

  2. cp -r <src> <dst> – Copy files/directories
    Example: cp -r ~/projects /mnt/backup/
    Backup a project directory.

  3. mv <src> <dst> – Move or rename
    Example: mv report.txt old_report.txt
    Rename a file.

  4. rm -rf <dir> – Delete files/directories
    Example: rm -rf /tmp/test-folder
    Delete a test folder (use cautiously!).

  5. find . -name "<pattern>" – Search for files
    Example: find . -name "*.log"
    Find all log files in the current directory tree.


User & Permission Management

  1. sudo adduser <username> – Add a user
    Example: sudo adduser john
    Create a user named John.

  2. sudo passwd <username> – Set password
    Example: sudo passwd john
    Set or reset John's password.

  3. sudo usermod -aG wheel <username> – Add to sudo group
    Example: sudo usermod -aG wheel john
    Give John sudo privileges.

  4. chmod +x <file> – Make script executable
    Example: chmod +x deploy.sh
    Allow a script to be run as a program.

  5. chown <user>:<group> <file> – Change ownership
    Example: chown john:john report.txt
    Give John ownership of a file.


Bonus: Miscellaneous Essentials

  1. whoami – Show current username
    Example: whoami
    Confirm which user you’re logged in as.

  2. hostnamectl – Set or check hostname
    Example: hostnamectl set-hostname dev-server
    Rename your system.

  3. grep <pattern> <file> – Search text
    Example: grep "error" /var/log/messages
    Find error messages in log files.

  4. tar -czvf archive.tar.gz <dir> – Compress files
    Example: tar -czvf backup.tar.gz ~/projects
    Archive and compress a folder.

  5. crontab -e – Edit scheduled tasks
    Example: crontab -e
    Schedule a backup script to run every night.

  6. alias ll='ls -l' – Create command shortcuts
    Example: alias gs='git status'
    Speed up frequent tasks with aliases.

  7. echo $PATH – Show environment path
    Example: echo $PATH
    See where the shell looks for executables.

  8. which <command> – Locate binaries
    Example: which python
    Find the path to the installed Python binary.

  9. man <command> – View manual
    Example: man chmod
    Get help for any command.

----

Examples


System & Process Management

  • top

    top
    # Monitor CPU and memory usage in real-time, useful to find resource hogs.
    
  • htop

    htop
    # Navigate interactively to find processes and kill if needed (press F9).
    
  • ps aux

    ps aux | grep firefox
    # Check if Firefox browser is currently running.
    
  • systemctl status

    systemctl status sshd
    # Verify if the SSH service is active and running.
    
  • journalctl -xe

    journalctl -xe
    # View recent system errors for troubleshooting failed services.
    
  • uptime

    uptime
    # Check how long the server has been running and its load averages.
    
  • free -h

    free -h
    # Diagnose memory usage including swap in a human-readable format.
    
  • df -h

    df -h /home
    # Check free disk space on the /home partition.
    
  • **du -sh ***

    du -sh /var/log/*
    # Find which log directories consume the most space.
    

Package Management (DNF)

  • sudo dnf update

    sudo dnf update
    # Refresh package metadata before installing or upgrading.
    
  • sudo dnf upgrade

    sudo dnf upgrade
    # Upgrade all packages to latest versions including security fixes.
    
  • sudo dnf install

    sudo dnf install git
    # Install Git version control system on your machine.
    
  • sudo dnf remove

    sudo dnf remove gedit
    # Remove Gedit text editor if no longer needed.
    
  • dnf list installed

    dnf list installed | grep nginx
    # Check if nginx web server is installed.
    
  • dnf search

    dnf search vscode
    # Search for Visual Studio Code or related packages.
    

Networking

  • ip a

    ip a
    # Show all network interfaces and their IP addresses.
    
  • ping

    ping google.com
    # Test if your system has internet connectivity.
    
  • curl

    curl https://api.ipify.org
    # Retrieve and display your public IP address.
    
  • ss -tuln

    ss -tuln
    # List all listening TCP/UDP ports and associated services.
    
  • nmcli

    nmcli device status
    # Show network device status and connections.
    

File & Directory Operations

  • ls -lah

    ls -lah /var/log
    # View detailed list of log files with sizes and permissions.
    
  • cp -r

    cp -r ~/projects /mnt/backup/
    # Copy project directory to backup location.
    
  • mv

    mv report.txt old_report.txt
    # Rename a report file.
    
  • rm -rf

    rm -rf /tmp/test-folder
    # Force delete a temporary folder (be careful!).
    
  • find . -name ""

    find . -name "*.log"
    # Find all log files recursively in current directory.
    

User & Permission Management

  • sudo adduser

    sudo adduser john
    # Create a new user named John.
    
  • sudo passwd

    sudo passwd john
    # Set or reset John's user password.
    
  • sudo usermod -aG wheel

    sudo usermod -aG wheel john
    # Add John to sudoers group for admin privileges.
    
  • chmod +x

    chmod +x deploy.sh
    # Make a deployment script executable.
    
  • chown :

    chown john:john report.txt
    # Change ownership of a report file to user John.
    

Bonus: Miscellaneous Essentials

  • whoami

    whoami
    # Confirm your current logged-in user.
    
  • hostnamectl

    hostnamectl set-hostname dev-server
    # Rename your machine to 'dev-server'.
    
  • grep

    grep "error" /var/log/messages
    # Search for "error" keywords in system messages.
    
  • tar -czvf archive.tar.gz

    tar -czvf backup.tar.gz ~/projects
    # Archive and compress your projects folder.
    
  • crontab -e

    crontab -e
    # Edit cron jobs to schedule regular backups.
    
  • alias

    alias gs='git status'
    # Create shortcut for a common Git command.
    
  • echo $PATH

    echo $PATH
    # Show directories where executables are searched.
    
  • which

    which python
    # Find full path of installed Python interpreter.
    
  • man

    man chmod
    # Open manual page for chmod command.
    


Comments

Popular posts from this blog

Differences Between Ubuntu 24.04.2 LTS and Ubuntu 25.04

Kapardak Bhasma: A Comprehensive Review and use

Vanga Bhasma: A Traditional Ayurvedic Metallic Formulation and use