Top Linux Commands Every System Administrator Should Know

Linux system administrator using futuristic terminal commands in a modern server room

Linux continues to be one of the most powerful and widely-used operating systems globally. Whether it’s cloud servers or enterprise infrastructure, businesses rely on Linux to power countless systems that they depend on daily. Thus, all system administrators should know how to work effectively at the Linux command line.

Graphical interfaces provide a level of abstraction over the operating system, whereas the Linux terminal allows direct control of the operating system. This means that jobs like process monitoring, networking, software installation, user administration and file management can be done faster and more reliably. In addition, mastering the terminal improves troubleshooting skills and boosts overall productivity.

This article will discuss the most critical Linux commands that every system administrator should be familiar with. These are the commands that will help you to use the Linux system with a better grip, whether you are an expert or beginner.

The commands are used in Linux and are of great importance.

The command line is a key tool for system administrators, providing flexibility, speed, and accuracy. Furthermore, many of the remote servers don’t even come with a graphical user interface, and so you’ll need to know your way around the command-line.

For those wishing to solidify their knowledge of Linux commands that were covered in this article – learning the basics of the necessary tools is a great way to start.

File Navigation Commands

Being able to navigate the Linux file system is one of the first things that every administrator should have to learn. Fortunately, there are a number of easy-to-use and very powerful commands in Linux for this.

pwd Command

The pwd command stands for “print working directory.” It shows the current directory that you are currently in.

Example:

pwd

Output:

/home/admin

This command is useful when dealing with multiple directories.

ls Command

The command ls lists information about the files and directories. Besides that, it has a few possibilities to show detailed information.

Example:

ls

For detailed output:

ls -l

To view hidden files:

ls -a

The ls command is commonly used by system administrators to check the contents of a directory without having to use more complex commands.

cd Command

The cd command is used to change the current directory.

Example:

cd /var/log

To change to the previous directory:

cd ..

In addition, the cd command is frequently used in conjunction with the tab command to navigate.

Manipulate Files and Directories Using Commands

A major component of system administration tasks is to manage files efficiently. Thus, it is important to know the following commands:

mkdir Command

mkdir is used to make directories.

Example:

mkdir backups

To make nested folders:

mkdir -p projects/linux/scripts

This command is useful to help administrators organise files correctly.

rm Command

rm – Remove files and directories.

Example:

rm file.txt

To delete a directory (and all its contents) recursively:

rm -r oldfiles

Administrators should take care of using this command since files deleted can be recovered with great difficulty.

cp Command

The command cp makes copies of files and directories.

Example:

cp config.conf backup.conf

To copy directories:

  • Copy recursive data from source to destination

Consequently, administrators are able to back up before changing critical files.

mv Command

mv: move or rename a file.

Example:

mv oldname.txt newname.txt

It can also be used to move files from one folder to another.

touch Command

The empty files are created by the touch command.

Example:

touch logfile.log

Also, it will update the time of the file if it already exists.

View and Edit the Contents of a File

System administrators constantly work with configuration files and log files. Thus, efficient viewing and editing of text is crucial.

cat Command

The cat command prints out the contents of a file.

Example:

cat /etc/passwd

Also, it allows administrators to merge or send the output to a different file.

less Command

The less command enables users to view a large file one page at a time.

Example:

less /var/log/syslog

Less is more convenient when it comes to reading long log files, as with cat.

head and tail Commands

The head command prints the first part of a file.

Example:

head -n 10 file.txt

The tail command prints the last part of a file.

Example:

tail -n 20 logfile.log

To see logs as they are written:

tail -f /var/log/auth.log

This means that administrators can see system activity in real time.

nano and vim Editors

There are text editors in Linux like nano and vim which are available in the terminal.

Using nano:

nano config.conf

Using vim:

vim config.conf

vim is for intermediate and expert administrators, while nano is for beginners.

File Permission Commands

Proper permissions and ownership are critical for the security of Linux systems. As such, it’s crucial that administrators know the commands associated with permissions inside-out.

chmod Command

The chmod command is used to modify the permissions of files.

Example:

chmod 755 script.sh

This command is used to set who can read, write, or execute files.

chown Command

It can change the ownership of files: chown

Example:

chown user:user file.txt

Therefore, administrators can set files to individual users or groups.

chmod Permission Breakdown

The default permissions of 755 is interpreted as:

  • 7 = read, write, execute
  • 5 = read and execute
  • 5 = read and execute

As a result the owner has all permission, limited permission is granted to others.

User and Group Management Commands

Another essential task of Linux administrators is user management.

useradd Command

The useradd command is used to add users.

Example:

useradd john

To automatically create a home directory:

useradd -m john

passwd Command

The passwd command is used to change or set passwords.

Example:

passwd john

Strong passwords boost the security of the servers.

userdel Command

The userdel command is used to remove users.

Example:

userdel john

To delete the user’s home directory also:

userdel -r john

groupadd Command

Groups can be created with the groupadd command.

Example:

groupadd developers

Many users’ permission is easily managed with groups.

Process Management Commands

It is very important for every Linux administrator to be able to monitor and control system processes.

ps Command

The ps command will list running processes.

Example:

ps aux

This command gives information like CPU usage, memory usage, process IDs, etc.

top Command

System activity is displayed on top command.

Example:

top

Administrators can use it to easily discover high resource consuming processes.

kill Command

Processes are killed using the kill command.

Example:

kill 1234

Forced End a Process:

kill -9 1234

But when forceful termination is necessary it should only be done so.

htop Command

htop is an enhanced version of top.

Example:

htop

It offers more interactive and visual user interface.

Networking Commands

Networking is a significant aspect of managing a system. As a result, there are a number of useful utilities for networking in Linux.

ping Command

Ping is used to test connection to network.

Example:

ping google.com

If packets are received successfully, then the network connection is working.

ip Command

The ip command is used to control network interfaces and addresses.

Example:

ip addr show

To show the routing information:

ip route

The newer Linux-based operating systems tend to favor ip over the old networking utilities.

netstat Command

The netstat command shows network connections and listening ports.

Example:

netstat -tulnp

Therefore administrators can be able to determine the active services.

ssh Command

The ssh command can be used to securely connect to remote servers.

Example:

ssh admin@192.168.1.10

One of the most vital tools in Linux is SSH because of the way that it’s usually managed remotely.

scp Command

scp: securely copies files between systems (secure copy).

Example:

scp backup.tar.gz admin@server:/backups

So, administrators can safely transfer files between networks.

Data Protection – Backup & Recovery Commands

By managing storage, you can ensure server stability and performance.

df Command

To check the usage of the disk space, use the df command.

Example:

df -h

Option -h will give human-readable output.

du Command

The du command is to estimate the size of directories.

Example:

du -sh /var/log

This can help an administrator identify just what files are taking up disk space.

mount Command

Mount operation is used to attach storage devices to the file system.

Example:

mount /dev/sdb1 /mnt

lsblk Command

The lsblk command prints out list of block devices.

Example:

lsblk

This means that administrators can get a good view of disks and partitions.

Package Management Commands

Another routine administration task is to install and update software.

apt Command

apt is used for Debian-based systems.

Example:

apt update

To install packages:

apt install nginx

yum Command

On Red Hat systems yum is used.

Example:

yum install httpd

dnf Command

Newer Red Hat based systems and Fedora use dnf.

Example:

dnf update

Remain updated with packages to increase security and performance.

System Monitoring Commands

System health monitoring keeps systems up and running and performing well.

uptime Command

The uptime command displays load averages and running time of the system.

Example:

uptime

free Command

The free command shows the amount of memory used.

Example:

free -h

It can be used to track how much RAM is being used by administrators.

uname Command

uname is used to print information about the system.

Example:

uname -a

These contain kernel information, architecture data, etc.

journalctl Command

The log files on systems that use systemd are accessed via journalctl.

Example:

journalctl -xe

This makes troubleshooting much easier, therefore.

The Compression Command and the Archive Commands

A piece of advice for administrators: compress files to save on storage and to make backups easier.

tar Command

The tar command is used to make tar files.

Example:

  • Create a backup of the /home directory by using the following command:

To extract archives:

tar -xvf backup.tar

gzip Command

The gzip is a command that compresses files.

Example:

gzip logfile.log

Compressed files will occupy smaller disk space and be faster to transfer.

Search and Text Processing Commands

There are excellent tools to search and filter information in Linux.

grep Command

grep is used to search for patterns of text.

Example:

grep “error” logfile.log

It’s often used in the log of administrators for troubleshooting.

find Command

The find command is used to find files and directories.

Example:

find /home -name “*.txt”

This command is useful in locating files in large systems.

Use of awk and sed Commands

awk reads text data that is structured.

Example:

awk ‘{print $1}’ file.txt

sed is a text stream editor.

Example:

sed ‘s/error/warning/g’ logfile.log

These commands can be particularly useful for automation and scripting.

Conclusion

Knowing the command line is crucial to Linux system administration. Thus, learning some of the basic Linux commands can significantly enhance efficiency, troubleshooting skills, and overall system management.

Common commands like ls, cd, chmod, top, ssh, apt and grep are core to the day-to-day use of an administrator. Moreover, knowledge of networking, storage management, package installation and process monitoring enables administrators to manage secure and reliable systems.

While it can be intimidating at first to learn all the Linux commands, it becomes easier to learn them over time. This means that administrators can operate more confidently on servers, automate tasks and troubleshoot technical problems.

With these commands, aspiring Linux administrators will be able to gain an understanding of the foundation skills that will be necessary when they are ready to further their education and learning in system administration.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x