25 Useful Linux Commands for System Administrators


Linux is a popular open-source operating system used by many system administrators for managing their servers and infrastructure. As a system administrator, it is essential to have a good understanding of Linux commands to manage and troubleshoot system efficiently. In this article, we will discuss 25 useful Linux commands for system administrators, along with their examples.

ls - List Directory Contents

The ls command is used to list contents of a directory. By default, it lists files and directories in current directory.

Example − To list all files and directories in current directory, use following command −

ls

cd - Change Directory

The cd command is used to change current working directory.

Example − To change current directory to /usr/local/bin, use following command −

cd /usr/local/bin

pwd - Print Working Directory

The pwd command is used to print current working directory.

Example − To print current working directory, use following command −

pwd

mkdir - Make Directory

The mkdir command is used to create a new directory.

Example − To create a new directory called test, use following command −

mkdir test

rm - Remove Files or Directories

The rm command is used to remove files or directories.

Example − To remove a file called myfile.txt, use following command −

rm myfile.txt

rmdir - Remove Directories

The rmdir command is used to remove directories.

Example − To remove a directory called test, use following command −

rmdir test

cp - Copy Files or Directories

The cp command is used to copy files or directories.

Example − To copy a file called myfile.txt to a new location /tmp, use following command −

cp myfile.txt /tmp

mv - Move or Rename Files or Directories

The mv command is used to move or rename files or directories.

Example − To rename a file called myfile.txt to newfile.txt, use following command −

mv myfile.txt newfile.txt

cat - Display File Contents

The cat command is used to display contents of a file.

Example − To display contents of a file called myfile.txt, use following command −

cat myfile.txt

tail - Display Last Part of a File

The tail command is used to display last part of a file.

Example − To display last 10 lines of a file called myfile.txt, use following command −

tail -n 10 myfile.txt

head - Display First Part of a File

The head command is used to display first part of a file.

Example − To display first 10 lines of a file called myfile.txt, use following command −

head -n 10 myfile.txt

less - Display File Contents Page by Page

The less command is used to display file contents page by page.

Example − To display contents of a file called myfile.txt page by page, use following command −

less myfile.txt

top - Display System Resource Usage

The top command is used to display system resource usage, such as CPU and memory usage.

Example − To display system resource usage, use following command −

top

ps - Display Running Processes

The ps command is used to display running processes.

Example − To display running processes, use following command −

ps aux

kill - Terminate Processes

The kill command is used to terminate processes.

Example − To terminate a process with a process ID of 1234, use following command −

kill 1234

df - Display Disk Space Usage

The df command is used to display disk space usage.

Example − To display disk space usage for all mounted file systems, use following command −

df -h

du - Display Directory Space Usage

The du command is used to display directory space usage.

Example − To display directory space usage for current directory, use following command −

du -sh .

ifconfig - Configure Network Interfaces

The ifconfig command is used to configure network interfaces.

Example − To display network interface information, use following command −

ifconfig

ping - Test Network Connectivity

The ping command is used to test network connectivity.

Example − To test network connectivity to a host with IP address 192.168.1.1, use following command −

ping 192.168.1.1

netstat - Display Network Connections

The netstat command is used to display network connections.

Example − To display active network connections, use following command −

netstat -an

ssh - Securely Connect to a Remote System

The ssh command is used to securely connect to a remote system.

Example − To connect to a remote system with IP address 192.168.1.1, use following command −

ssh 192.168.1.1

scp - Securely Copy Files Between Systems

The scp command is used to securely copy files between systems.

Example − To copy a file called myfile.txt from local system to a remote system with IP address 192.168.1.1, use following command −

scp myfile.txt user@192.168.1.1:/path/to/destination

wget - Download Files From Web

The wget command is used to download files from web.

Example − To download a file from a website, use following command −

wget https://example.com/file.zip

tar - Create and Extract Compressed Archives

The tar command is used to create and extract compressed archives.

Example − To create a compressed archive of a directory called mydir, use following command −

tar -czvf mydir.tar.gz mydir

crontab - Schedule Tasks to Run at Specific Times

The crontab command is used to schedule tasks to run at specific times.

Example − To schedule a task to run every day at 2am, use following command −

0 2 * * * /path/to/command

useradd - Add a New User to System

The useradd command is used to add a new user to system.

Example − To add a new user with username "john", use following command −

useradd john

passwd - Change User Password

The passwd command is used to change password of a user.

Example − To change password for user "john", use following command −

passwd john

sudo - Execute a Command with Superuser Privileges

The sudo command is used to execute a command with superuser privileges.

Example − To execute a command as a superuser, use following command −

sudo command

Conclusion

In conclusion, Linux commands are essential for system administrators to manage and troubleshoot their systems efficiently. above 25 commands are just a few of many commands available in Linux. By mastering these commands, you can become more proficient in managing Linux systems. I hope this article has been useful in providing you with some useful Linux commands to help you in your role as a system administrator.

Updated on: 28-Mar-2023

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements