Sysadmins & DevOps: 20 Must-Know Advanced Linux Commands

Thank you for all the likes, kind words, and support you’ve given us in the first two parts of our Linux commands series.

In the first article, we covered commands for users who are new to Linux and need essential knowledge to get started.

In the second article, we discussed commands that are useful for users at a middle level, helping them manage their own systems effectively.

In this article, we’ll explore the commands needed to administer a Linux server.

41. ip Command

The “ip command” is a networking tool that is used to manage network settings such as configuring IP addresses, managing interfaces, setting up routing tables, troubleshooting network issues, and much more.

Check Active Network Interfaces in Linux

To check active network interfaces on a Linux system, you can use the following command, which will list all network interfaces along with their state, their assigned IP addresses, and other relevant information.

ip addr show
List Linux Active Network Interfaces
List Linux Active Network Interfaces

How to Enable/Disable Network Interfaces in Linux

To disable or enable a network interface on a Linux system, you can use the following commands:

sudo ip link set <interface_name> down
sudo ip link set <interface_name> up

The “down” command disables a network interface, preventing it from sending or receiving data. Conversely, the “up” command enables the interface, allowing it to actively send and receive data.

Set a Static IP Address in Linux

To assign a static IP address to a network interface in Linux, you can use the following command:

sudo ip address add <ip_address>/<subnet_mask> dev <interface_name>

For example, to assign the IP address 192.168.1.100 with a subnet mask of 24 (equivalent to 255.255.255.0) to the interface eth0, you would use:

sudo ip address add 192.168.1.100/24 dev eth0

42. ss Command

The ‘ss command‘ displays various network-related information such as network connections, routing tables, interface statistics, masquerade connections, multicast memberships, etc.

List Active Network Ports in Linux

To list active network ports in Linux, you can use the following command, which will list all active TCP and UDP sockets that are in the listening state, along with their associated port numbers.

sudo ss -tuln

Here’s what each option means:

  • -t – Show TCP sockets.
  • -u – Show UDP sockets.
  • -l – Show only listening sockets.
  • -n – Show numerical addresses instead of resolving them to hostnames.
List Network Ports in Linux
List Network Ports in Linux

43. nslookup Command

The ‘nslookup command‘ is a network utility program used to obtain information about domain names, IP addresses, and other DNS records. It allows users to look up information such as the IP address associated with a domain name, or the domain name associated with an IP address.

Find the IP Address of a Website

To perform a DNS lookup for the domain “google.com“, use the following command, which will show the IP address(es) associated with the domain, along with other DNS information such as the authoritative name server(s) for the domain.

nslookup google.com
Find Domain IP Address
Find Domain IP Address

If the nslookup command is not found, you need to install it using the following appropriate command for your specific Linux distribution.

sudo apt install dnsutils         [On Debian, Ubuntu and Mint]
sudo yum install dnsutils         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/dnsutils  [On Gentoo Linux]
sudo apk add dnsutils             [On Alpine Linux]
sudo pacman -S dnsutils           [On Arch Linux]
sudo zypper install dnsutils      [On OpenSUSE]    
sudo pkg install dnsutils      [On FreeBSD]

Find Domain’s MX Records

To query the Mail Exchanger (MX) record for a domain, you can use the following syntax.

nslookup -type=mx google.com
Find Domain MX Records
Find Domain MX Records

Find Domain’s NS Records

To query the Name Server (NS) records for a domain, you can use the following syntax.

nslookup -type=ns google.com
Find Domain NS Records
Find Domain NS Records

Find Domain’s DNS Records

To find all DNS records for a domain, you can use the following syntax.

nslookup -type=any google.com 
Find Domain DNS Records
Find Domain DNS Records

Find Domain’s SOA Records

To query the Start of Authority (SOA) record for a domain, you can use the following syntax.

nslookup -type=SOA google.com
Find Domain SOA Records
Find Domain SOA Records

44. dig Command

The ‘dig command‘ (stands for domain information groper) is a commonly used network tool for querying DNS nameservers for information about host addresses, mail exchanges, nameservers, and related information.

This tool can be used from any Linux (Unix) or Macintosh OS X operating system. The most typical use of dig is to simply query a single host.

dig google.com
Find Domain DNS Servers
Find Domain DNS Servers

45. uptime Command

The ‘uptime command‘ is the most useful tool that displays the information about your system’s current uptime and load average over different time intervals.

uptime
Find System Uptime
Find System Uptime

46. wall Command

One of the most important commands for administrators is the ‘wall‘ command which is used to broadcast important notifications or announcements to all users currently logged into the system.

wall "we will be going down for maintenance for one hour sharply at 03:30 pm"
Send Message to All Users
Send Message to All Users

47. mesg Command

The “mesg” command is used to control whether other system users can send messages to your terminal.

To allow other users to send messages to your terminal, use:

mesg y

To disallow other users from sending messages to your terminal, use:

mesg n

By default, most systems have the “mesg” permission set to "y", allowing other users to send messages to your terminal.

48. write Command

The “write” command is used to send messages to another user who is logged into the same system.

write john

You can then type your message and press "Ctrl+D" to send it.

Send Message to User
Send a Message to the User

49. talk Command

The “talk” command is used for interactive communication between two users logged into the same system.

talk tecmint

If the talk command is not installed, use the following appropriate command for your specific Linux distribution.

sudo apt install talk         [On Debian, Ubuntu and Mint]
sudo yum install talk         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/talk  [On Gentoo Linux]
sudo apk add talk             [On Alpine Linux]
sudo pacman -S talk           [On Arch Linux]
sudo zypper install talk      [On OpenSUSE]    
sudo pkg install talk        [On FreeBSD]

50. w Command

What makes the ‘w‘ command seem funny? Surprisingly, it’s not a joke at all. Despite being just one letter long, the ‘w‘ command is quite meaningful.

It combines the functionality of both the ‘uptime‘ and ‘who‘ commands, providing information about system uptime and currently logged-in users, all with just a single keystroke!

w
List Logged-in Users
List Logged-in Users

51. rename Command

The ‘rename command‘, as its name implies, is used to rename files. It allows users to rename specified files by replacing the first occurrence found in the file name.

For example, if you want to rename multiple files with similar patterns or prefixes, the ‘rename‘ command offers a convenient way to quickly rename them in batch.

rename 's/file_//' file_*.txt
Rename Files in Linux
Rename Files in Linux

52. top Command

The ‘top command‘ displays real-time information about system processes, including CPU usage, memory usage, and other system metrics.

top
Monitor Linux Running Processes
Monitor Linux Running Processes

53. mkfs.ext4 Command

The ‘mkfs.ext4 command‘ is used to create a new ext4 file system on the specified device. It’s important to note that if the wrong device is specified, the entire block will be wiped and formatted.

Therefore, it is highly recommended not to run this command unless you fully understand its implications and are certain of the device you are targeting. Misuse of this command can lead to data loss or corruption.

Here’s an example of how you can use the mkfs.ext4 command to create an ext4 file system on a specified device:

sudo mkfs.ext4 /dev/sdb1

54. vi/nano and emacs Commands

vi is a text editor that is part of the Unix and Linux operating systems that allows users to create, edit, and save text files.

vi myfile.txt

nano is a simple and user-friendly text editor that is ideal for beginners or those who prefer a straightforward editing experience.

nano myfile.txt

emacs is a powerful and extensible text editor with advanced features that offers a wide range of functionalities beyond basic text editing.

emacs myfile.txt

55. rsync Command

The ‘rsync command‘ is used for copying files, and it includes a handy '-P' switch that shows a progress bar during file transfers. If you have rsync installed, you can create a simple alias to make copying files easier.

alias cp='rsync -aP'

Now, when you use the ‘cp command‘ in the terminal, it will actually use rsync with the '-aP' options, giving you a progress bar during file copying.

In addition, keeping and maintaining backups is a crucial yet often tedious task for system administrators. Rsync is a great tool (among several others) that can be used in the terminal to create and manage backups efficiently.

56. free Command

Monitoring memory and system resources is crucial for administrators, and the ‘free command‘ is a helpful tool for this purpose, as it provides information about the amount of free and used memory in the system.

free
free -k
free -m
free -g
Check Linux Memory Usage
Check Linux Memory Usage

57. mysqldump Command

The ‘mysqldump command‘ is used to create backups of MySQL databases. It allows users to dump all or specific database data into a specified file.

For example, the following command creates a backup of all databases and saves it to a file named ‘backupfile.sql‘.

mysqldump -u root -p --all-databases > /home/ravi/backupfile.sql

58. mkpasswd Command

The ‘mkpasswd command‘ is used to generate hard-to-guess, random passwords of specified lengths. It’s particularly useful for creating secure passwords for various purposes.

For example, the following command generates a random password of 10 characters, such as “zI4+Ybqfx9“.

mkpasswd -l 10

“`
Note that the "-l" option is used to specify the length of the password, which is commonly used in scripting languages to generate random passwords for various purposes.

To use the “mkpasswd” command, you may need to install the “expect” package using the following appropriate command for your specific Linux distribution.

sudo apt install expect         [On Debian, Ubuntu and Mint]
sudo yum install expect         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/expect  [On Gentoo Linux]
sudo apk add expect             [On Alpine Linux]
sudo pacman -S expect           [On Arch Linux]
sudo zypper install expect      [On OpenSUSE]    
sudo pkg install expect         [On FreeBSD]

59. paste Command

The “paste” command is used to merge lines of files. It takes lines from multiple input files and concatenates them horizontally, with each line separated by a delimiter.

paste File1.txt File2.txt
Linux Paste Command
Linux Paste Command

60. lsof Command

The ‘lsof command‘ stands for “list open files” and displays all the files that your system has currently opened. It’s very useful to figure out which processes uses a certain file, or to display all the files for a single process.

lsof 
Check Open Files in Linux
Check Open Files in Linux

This is not the end. A System Administrator does a lot of tasks to provide you with such a nice interface on which you work. System Administration is actually an art of learning and implementing in a very perfect way.

We will try to provide you with all the other necessary information that a Linux professional must learn. Linux itself is a process of continuous learning.

Your kind words are always appreciated, as they encourage us to put in more effort to provide you with knowledgeable articles.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

23 Comments

Leave a Reply
  1. When executed “mkpasswd” command with -l option, I get below error.

    $ mkpasswd -l 20
    
    mkpasswd: invalid option -- 'l'
    Try 'mkpasswd --help' for more information.
    

    Without -l option it works.

    $ mkpasswd 20
    YYEJT8KAvh4C6
    Reply
    • @Praneeth,

      Thanks for sharing the tip, it seems you’re tried these instructions on Ubuntu based distro, so seems some difference options and arguments replaced or changed in the latest version of mkpasswd package..

      Reply
  2. Yeah, except ifconfig is going away for the more feature-complete ip command. ip pretty much has the same syntax setup as git, but can let you do anything and everything you’d want, from basic interface up/down commands, to configuring vlans and bridged connections that you’d normally only be able to do on an enterprise-grade router.

    Reply
  3. “54. Command: vi/emac/nano”

    First of all, it is spelled “emacs” NOT “emac”. Secondly, where is your explanation of the editor?

    Unfortunately, all your explanations are too simplified to be usefull.

    “man” should be the the first command explained in the first section, not in the second!

    Reply
  4. I notice you explain deprecated commands like ifconfig and nslookup. you should at least cover their replacement comnands (ip, ss, host, etc..) as well.

    They are either easier to use or in some cases the same flags are used and they do a better job of output.

    examples:
    ifconfig -> ip addr show (or shorthand “ip a sh”)
    nslookup myhost -> host myhost
    netstat -anp -> ss -anp

    There are way more but you get the idea. :-)

    Reply
  5. There seems to be something missing from 59. Command: paste

    I finally did a paste file1 file2>file3
    and I got the desired result.

    I didn’t see that explanation in this tutorial.

    Cheers
    Rick

    Reply
  6. Just be careful that you don’t issue “ifconfig eth0 down” over a SSH connection to a remote box. You might end up needing 2hr of driving just to issue one command from the console. Not that I’ve ever done this. :-)

    Also, a couple typos:
    s/eht0/eth0/g
    s/Query Start of Autory/Query Start of Authority/
    s@Command: vi/emac/nano@Command: vi/emacs/nano@

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.