In this article, we will review commonly used tar and gzip commands in Linux with some examples. Linux users and IT professionals alike, ought to
In this article, we will review the top 50 Linux commands every Linux Sysadmin should know. Junior-level sysadmins and Linux enthusiasts are familiar with all of these commands and know how to use them.
Before we begin, this is just my subjective view of the what belongs on the top 50 list. Therefore, if your favorite command does not make it on this list, don’t worry. This is just my view based on my over two-decade experience working as a Systems Administrator/Engineer. With that said, I limited my choices to the basic commands and a brief description that people who know Linux are familiar with–including usage examples.
# | Command | Utility | Example |
1 | ls | List directory contents – The example command will list the contents of the home directory. | $ ls /home |
2 | cd | Change directory – Change to the /var/log directory | $ cd /var/log |
3 | pwd | Print working directory | $ pwd |
4 | mkdir | Create or make directory – Create a new directory. For example, mkdir /tmp/newdir will create a new directory called newdir in the /tmp directory. | $ mkdir /tmp/newdir |
5 | rmdir | Remove a directory – For example, rmdir /tmp/newdir will remove the newdir directory from the /tmp directory. | $ rmdir /tmp/newdir |
6 | touch | Create a new file or update the modification time of an existing file. For example, touch myfile.txt will create a new empty file called myfile.txt. | $ touch myfile.txt |
7 | cat | Concatenate and display files. For example, cat file1.txt file2.txt will display the contents of both file1.txt and file2.txt. | $ cat file1.txt file2.txt |
8 | less | Display the contents of a file one page at a time. For example, less myfile.txt will display the contents of myfile.txt one page at a time. | $ less myfile.txt |
9 | tail | Display the last few lines of a file. For example, tail myfile.txt will display the last few lines of myfile.txt. | $ tail myfile.txt |
10 | head | Display the first few lines of a file. For example, head myfile.txt will display the first few lines of myfile.txt. | $ head myfile.txt |
11 | cp | Copy files and directories. For example, cp file1.txt /tmp/ will copy file1.txt to the /tmp directory. | $ cp file1.txt /tmp/ |
12 | mv | Move or rename files and directories. For example, mv file1.txt file2.txt will rename file1.txt to file2.txt. | $ mv file1.txt file2.txt |
13 | rm | Remove files and directories. For example, rm myfile.txt will remove the myfile.txt file. | $ rm myfile.txt |
14 | passwd | Change a user’s password. For example, passwd newuser will prompt for a new password for the user newuser. | $ passwd <username> |
15 | find | Search for files and directories. For example, find / -name myfile.txt will search for myfile.txt starting from the root directory (/). | $ find / -name myfile.txt |
16 | grep | Search for a pattern in a file or files. For example, grep “error” logfile.txt will search for the word “error” in logfile.txt. | $ grep error logfile.txt |
17 | chmod | Change the permissions of files and directories. For example, chmod 755 myfile.txt will give read, write, and execute permissions to the owner of myfile.txt, and read and execute permissions to all others. | $ chmod 755 myfile.txt |
18 | chown | Change the owner of files and directories. For example, chown user myfile.txt will change the owner of myfile.txt to user. | $ chown user myfile.txt |
19 | chgrp | Change the group of files and directories. For example, chgrp group myfile.txt will change the group of myfile.txt to group. | $ chgrp group myfile.txt |
20 | du | Display disk usage. For example, du -h /home will display the disk usage of the /home directory in a human-readable format. | $ du -h /home |
21 | df | Display free disk space. For example, df -h will display the free disk space on all mounted filesystems in a human-readable format | $ df -h |
22 | top | Display system resource usage. For example, top will display a live view of system resource usage, including CPU usage, memory usage, and more. | $ top |
23 | ps | Display information about running processes. For example, ps aux will display a list of all running processes with details such as the process ID, CPU usage, memory usage, and more. | $ ps aux |
24 | kill | Send a signal to a process to terminate it. For example, kill 1234 will send a signal to the process with ID 1234 to terminate it. | $ kill 1234 |
25 | ping | Test network connectivity. For example, ping google.com will send ICMP echo requests to google.com to test network connectivity. | $ ping google.com |
26 | ifconfig | Display network interface configuration. For example, ifconfig will display the configuration of all network interfaces on the system. | $ ifconfig |
27 | ip | Display and manipulate network interface configuration. For example, ip addr show will display the IP addresses of all network interfaces on the system. (used instead of ifconfig on RHEL7/CentOS7 and later versions). | $ ip addr show |
28 | route | Display and manipulate routing table. For example, route -n will display the routing table in a numeric format. | $ route -n |
29 | traceroute | Trace the route taken by packets across a network. For example, traceroute google.com will show the path that packets take to reach google.com. | $ traceroute google.com |
30 | wget | Download files from the internet. For example, wget https://example.com/file.txt will download file.txt from the example.com website | $ wget https://example.com/file.txt |
31 | curl | Transfer data from or to a server. For example, curl https://example.com will display the HTML content of the example.com website. | $ curl https://example.com |
32 | ssh | Connect to a remote server securely. For example, ssh user@remote-server will establish a secure shell connection to the remote-server as user. | $ ssh user@remote-server |
33 | scp | Copy files securely between hosts. For example, scp myfile.txt user@remote-server:/tmp/ will copy myfile.txt to the /tmp directory on the remote-server as user. | $ scp myfile.txt user@remote-server:/tmp/ |
34 | rsync | Sync files and directories between hosts. For example, rsync -avz /local/path/ user@remote-server:/remote/path/ will sync the contents of /local/path to /remote/path on the remote-server as user. | $ rsync -avz /local/path/ user@remote-server:/remote/path/ |
35 | tar | Create and extract archives. For example, tar -cvzf archive.tar.gz /path/to/directory will create a compressed archive of the /path/to/directory. | $ tar -cvzf archive.tar.gz /path/to/directory |
36 | zip | Compress files into a zip archive. For example, zip archive.zip file1.txt file2.txt will create a zip archive of file1.txt and file2.txt. | $ zip archive.zip file1.txt file2.txt |
37 | unzip | Extract files from a zip archive. For example, unzip archive.zip will extract the contents of archive.zip to the current directory. | $ unzip archive.zip |
38 | useradd | Create a new user account. For example, useradd newuser will create a new user account called newuser. | $ useradd newuser |
39 | userdel | Remove a user account. For example, userdel olduser will remove the user account called olduser. | $ userdel olduser |
40 | groupadd | Create a new group. For example, groupadd newgroup will create a new group called newgroup. | $ groupadd newgroup |
41 | groupdel | Remove a group. For example, groupdel oldgroup will remove the group called oldgroup. | $ groupdel oldgroup |
42 | sudo | Execute a command with superuser privileges. For example, sudo apt-get update will update the package list using apt-get with superuser privileges. | $ sudo apt-get update |
43 | su | Switch to a different user account. For example, su newuser will switch to the user account newuser. | $ su newuser |
44 | sed | Stream editor for modifying text. For example, sed ‘s/oldstring/newstring/g’ file.txt will replace all instances of oldstring with newstring in file.txt. | $ sed ‘s/oldstring/newstring/g’ file.txt |
45 | awk | Text processing tool for extracting and manipulating data. For example, awk ‘{print $1}’ file.txt will print the first column of data in file.txt. | $ awk ‘{print $1}’ file.txt |
46 | journalctl | A command-line tool for viewing and querying system logs from the systemd journal. For example, journalctl -u apache2.service will show logs related to the apache2 service. | $ journalctl -u apache2.service |
47 | pvcreate | pvcreate – create a physical volume (PV) to be used with LVM. Example: To create a physical volume on the device /dev/sdb, use the command: pvcreate /dev/sdb. | $ pvcreate /dev/sdb |
48 | vgcreate | vgcreate – create a volume group (VG) using one or more physical volumes. Example: To create a volume group named myvg using the physical volume /dev/sdb, use the command: vgcreate myvg /dev/sdb. | $ vgcreate myvg /dev/sdb |
49 | lvcreate | Create a logical volume (LV) in a volume group (VG). Example: To create a logical volume named mylv with a size of 10 GB in the volume group myvg, use the command: lvcreate -L 10G -n mylv myvg. | $ lvcreate -L 10G -n mylv myvg |
50 | lvextend | extend the size of a logical volume. Example: To extend the size of the logical volume mylv by 5 GB, use the command: lvextend -L +5G /dev/myvg/mylv. | $ lvextend -L +5G /dev/myvg/mylv |
Overall, these Linux commands are essential tools for system administrators to manage and maintain Linux-based systems. While there are many more commands and variations available, these 50 commands provide a solid foundation for system administration.
Was this article helpful to you? If so, leave us your thoughts in the comment section below and share!
Related Posts
In this article, we will review commonly used tar and gzip commands in Linux with some examples. Linux users and IT professionals alike, ought to
In this article, we will compare chmod vs. umask, the differences between them as well as how we can use them in our Linux environment.
In this article, we will review the most commonly used RPM commands in Linux. These commands play a pivotal role in package management, allowing users