linux server management command - ghdrako/doc_snipets GitHub Wiki
Monitoring and Performance
- sar - The sar command is used to collect, report, and save system activity information.
sar -u 5 10 # display CPU utilization statistics every 5 seconds, 10 times
- atop - The atop command is used to monitor system resources and processes
atop -r /var/log/atop/atop_20230301 # display the system activity for a specific date
- free - Display the amount of free and used memory in the system.
free -h # display the data in a human-readable format
Process Management
ps -aux
kill -9 1234
- pkill - Kill processes based on their name or other attributes.
pkill -f firefox
- nice - nice command is used to set the priority of a process. It is often used to give lower priority to CPU-intensive processes so that they don’t hog the system resources.
nice -5 wget https://akashrajpurohit.com
To set negative priority you can use a double hyphen
nice --5 wget https://akashrajpurohit.com
- renice - Change the priority of an already running process.
renice +5 1234 # change the priority of the process with PID 1234.
- top - Displays real-time information about running processes and system resources.
Networking Commands
- traceroute - Traces the route taken by packets over an IP network.
traceroute google.com
- tcpdump - Captures network traffic in real-time and saves it to a file.
tcpdump -i eth0 -w capture.pcap
- netstat - Displays information about network connections, routing tables, and network interfaces.
netstat -ano | grep ESTABLISHED
- nmap - Scans a network and discovers open ports and services.
nmap -sS -O 192.168.1.1/24
Disk Management
- lsof - The lsof command is used to list open files on the system. It is helpful for identifying processes that are using a specific file or disk partition.
lsof /dev/sda1
This command will list all processes that are using the /dev/sda1 disk partition.
- blkid - The blkid command is used to display information about block devices. It is helpful for identifying disk partitions and their properties.
blkid /dev/sda1 # display the properties of the /dev/sda1 disk partition
- fdisk - fdisk command is used to list, create, delete, or modify partitions on a hard disk.
fdisk -l # list the partition tables for the hard drive