ArrowLeft Icon

Mastering Intermediate Linux Commands for Efficient Server Management

📆 · ⏳ 4 min read · · 👀

Introduction

As a sysadmin, you often come across complex tasks that require more than just basic commands. That’s why it’s important to learn some intermediate-level Linux commands that can make your work easier and more efficient.

These commands can help you automate repetitive tasks, manage processes, and monitor system performance, among other things. In this article, we will explore some of these commands and their usage.

💡

Pro Tip!

Just like the previous article dropping in a friendly advice that refer to man pages for learning more in detail about each commands using the man <command_name>

Monitoring and Performance

  • sar - The sar command is used to collect, report, and save system activity information.

    It is helpful for monitoring system performance and diagnosing issues.

    Terminal window
    sar -u 5 10

    This command will display CPU utilization statistics every 5 seconds, 10 times.

  • atop - The atop command is used to monitor system resources and processes.

    It provides a detailed view of the system activity and helps in identifying performance bottlenecks.

    Terminal window
    atop -r /var/log/atop/atop_20230301

    This command will display the system activity for a specific date.

  • free - Display the amount of free and used memory in the system.

    Terminal window
    free -h

    This will display the data in a human-readable format.

Process Management

  • ps - Display information about the currently running processes.

    Terminal window
    ps -aux
  • kill - Send a signal to a process, which can be used to terminate the process.

    Terminal window
    kill -9 1234

    This will kill the process which has the PID of 1234

  • pkill - Kill processes based on their name or other attributes.

    Terminal window
    pkill -f firefox

    This will kill the firefox process.

  • nice - nice command is used to set the priority of a process.

    It is often used to give lower priority to CPU-intensive processes so that they don’t hog the system resources.

    Terminal window
    nice -5 wget https://akashrajpurohit.com

    To set negative priority you can use a double hyphen

    Terminal window
    nice --5 wget https://akashrajpurohit.com
  • renice - Change the priority of an already running process.

    Terminal window
    renice +5 1234

    This will change the priority of the process with PID 1234.

  • top - Displays real-time information about running processes and system resources.

    Terminal window
    top

Networking Commands

  • traceroute - Traces the route taken by packets over an IP network.

    Terminal window
    traceroute google.com
  • tcpdump - Captures network traffic in real-time and saves it to a file.

    Terminal window
    tcpdump -i eth0 -w capture.pcap
  • netstat - Displays information about network connections, routing tables, and network interfaces.

    Terminal window
    netstat -ano | grep ESTABLISHED
  • nmap - Scans a network and discovers open ports and services.

    Terminal window
    nmap -sS -O 192.168.1.1/24

Disk Management

  • lsof - The lsof command is used to list open files on the system. It is helpful for identifying processes that are using a specific file or disk partition.

    Terminal window
    lsof /dev/sda1

    This command will list all processes that are using the /dev/sda1 disk partition.

  • blkid - The blkid command is used to display information about block devices. It is helpful for identifying disk partitions and their properties.

    Terminal window
    blkid /dev/sda1

    This command will display the properties of the /dev/sda1 disk partition.

  • fdisk - fdisk command is used to list, create, delete, or modify partitions on a hard disk.

    Terminal window
    fdisk -l

    This command will list the partition tables for the hard drive.

Miscellaneous Commands

  • sed - A stream editor for filtering and transforming text.

    Terminal window
    sed 's/foo/bar/g' input.txt > output.txt
  • awk - A versatile programming language for text processing and data extraction.

    Terminal window
    cat access.log | awk '{ print $1 }'
  • tar - A utility for creating and manipulating tar archives.

    Terminal window
    tar -czvf archive.tar.gz file1 file2 dir1
  • find - Searches for files and directories that match certain criteria.

    Terminal window
    find /var/log -type f -name "*.log" -mtime +7 -exec rm {} \;

Conclusion

These are some of the intermediate-level Linux commands that a system admin may use while maintaining a Linux server.

However, this is not an exhaustive list, and there are many more commands that you can explore as you become more experienced with Linux administration.

If you are someone who manages Linux servers a lot and want to add/edit some of the commands then do let me know by reaching out on any social media platform.

EnvelopeOpen IconStay up to date

Get notified when I publish something new, and unsubscribe at any time.

Need help with your software project? Let’s talk

You may also like

  • # linux

    SystemD Timers vs. Cron Jobs

    Explore the world of task scheduling in Linux as we compare the classic Cron Jobs with the modern SystemD Timers. Learn when to use each method and how to set them up to automate your Linux system tasks effectively.

  • # linux

    Essential Linux Commands for Server Maintenance at Home

    As a Linux system administrator, it's essential to have a good grasp of the command-line interface. In this blog, we'll explore some of the most common and useful commands used for maintaining a Linux server at home. From handling files to networking, these commands will help you streamline your work and keep your server running smoothly.

  • # linux# docker

    Build Your Own Docker with Linux Namespaces, cgroups, and chroot: Hands-on Guide

    Take a practical approach to containerization as we guide you through the step-by-step process of building your own Docker-like environment using Linux namespaces, cgroups, and chroot. Dive into the code and command examples to gain a deeper understanding of how these technologies work together to create isolated and efficient containers.