Master Essential Linux Commands for System Management on CentOS 7.6
This guide compiles the most useful Linux commands for service control, file handling, compression, disk and network monitoring, and package management on CentOS 7.6, providing clear examples and visual references to help developers and sysadmins work efficiently.
System Service Management
systemctl
List all service units:
<code>systemctl list-units --type=service</code>Check a service status:
<code>systemctl status firewalld</code>Stop a service:
<code>systemctl stop firewalld</code>Start a service:
<code>systemctl start firewalld</code>Restart a service (regardless of current state):
<code>systemctl restart firewalld</code>Reload configuration without stopping the service:
<code>systemctl reload firewalld</code>Disable a service from starting at boot:
<code>systemctl disable firewalld</code>Enable a service to start at boot:
<code>systemctl enable firewalld</code>File Management
ls
List all files in the root directory:
<code>ls -l /</code>pwd
Show the absolute path of the current working directory.
cd
Change the current directory:
<code>cd /usr/local</code>date
Display or modify system date and time:
<code>date '+%Y-%m-%d %H:%M:%S'</code>passwd
Set a user password (example for root):
<code>passwd root</code>su
Switch to another user, e.g., become superuser:
<code>su -</code>clear
Clear the terminal screen.
man
Show manual page for a command, e.g., ls:
<code>man ls</code>who
Show the current runlevel:
<code>who -r</code>List currently logged‑in users:
<code>who -bUT</code>free
Display memory usage in megabytes:
<code>free -m</code>ps
Show running processes:
<code>ps -ef</code>Filter for sshd processes:
<code>ps -ef | grep sshd</code>top
Interactive view of active processes, similar to Windows Task Manager.
mkdir
Create a new directory.
more
Paginated view of a long file, e.g., show 10 lines per page of /var/log/boot.log:
<code>more -c -10 /var/log/boot.log</code>cat
Display a file with line numbers, e.g., boot log:
<code>cat -Ab /var/log/boot.log</code>touch
Create an empty file named text.txt:
<code>touch text.txt</code>rm
Delete a file:
<code>rm text.txt</code>Force delete a directory and its contents:
<code>rm -rf testdir/</code>cp
Copy a directory recursively:
<code>cp -r /mydata/tes1 /mydata/test2</code>mv
Move or rename a file:
<code>mv text.txt text2.txt</code>Compression and Extraction
tar
Archive /etc without compression:
<code>tar -cvf /mydata/etc.tar /etc</code>Compress /etc with gzip:
<code>tar -zcvf /mydata/etc.tar.gz /etc</code>Compress /etc with bzip2:
<code>tar -jcvf /mydata/etc.tar.bz2 /etc</code>List contents of a gzip archive (paged):
<code>tar -ztvf /mydata/etc.tar.gz | more -c -10</code>Extract a gzip archive to the current directory:
<code>tar -zxvf /mydata/etc.tar.gz</code>Disk and Network Management
df
Show disk space usage in human‑readable format:
<code>df -hT</code>du
Show size of files and directories in the current folder (depth 1):
<code>du -h --max-depth=1 ./*</code>ifconfig
Display network interface status.
netstat
Show routing table:
<code>netstat -rn</code>Show all active TCP connections:
<code>netstat -an</code>Show listening services with program names:
<code>netstat -tulnp</code>Show all connections with process info:
<code>netstat -atunp</code>wget
Download a file from the internet.
Software Installation and Management
rpm
Install a package:
<code>rpm -ivh nginx-1.12.2-2.el7.x86_64.rpm</code>Search packages (fuzzy):
<code>rpm -qa | grep nginx</code>Query exact package name:
<code>rpm -qa nginx</code>List files installed by a package:
<code>rpm -ql nginx-1.12.2-2.el7.x86_64</code>Show package information:
<code>rpm -qi nginx-1.12.2-2.el7.x86_64</code>Verify package integrity:
<code>rpm -V nginx-1.12.2-2.el7.x86_64</code>Upgrade a package:
<code>rpm -Uvh nginx-1.12.2-2.el7.x86_64</code>Remove a package:
<code>rpm -e nginx-1.12.2-2.el7.x86_64</code>yum
Install a package:
<code>yum install nginx</code>Check for available updates:
<code>yum check-update</code>Update a specific package:
<code>yum update nginx</code>Search package information in repositories:
<code>yum info nginx*</code>List all installed packages:
<code>yum info installed</code>List package names matching a pattern:
<code>yum list nginx*</code>Fuzzy search for packages:
<code>yum search nginx</code>Follow and like for more tips.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.