Command | Description | Example |
---|---|---|
top | Display tasks and system information. | top |
htop | Interactive process viewer. | htop |
ps | Display current processes. | ps aux |
kill | Terminate a process by PID. | kill -9 1234 |
pkill | Terminate a process by name. | pkill firefox |
pgrep | Find process IDs by name. | pgrep apache2 |
free | Display memory usage. | free -h |
df | Display disk space usage. | df -h |
du | Estimate file space usage. | du -sh /var/log |
iostat | Report CPU and I/O statistics. | iostat |
vmstat | Report virtual memory statistics. | vmstat |
netstat | Network statistics. | netstat -tuln |
ss | Display socket statistics. | ss -tuln |
lsof | List open files. | lsof /var/log/syslog |
strace | Trace system calls and signals. | strace -p 1234 |
dmesg | Kernel ring buffer. | `dmesg |
journalctl | Query systemd journal. | journalctl -xe |
systemctl | Control systemd services. | systemctl status httpd |
service | Control system services. | service apache2 status |
uptime | Show system uptime. | uptime |
who | Show who is logged on. | who |
w | Show who is logged on and what they are doing. | w |
last | Show last logins of users. | last |
ping | Send ICMP ECHO_REQUEST to network hosts. | ping google.com |
traceroute | Print the route packets take to the network host. | traceroute google.com |
ifconfig | Configure network interfaces. | ifconfig eth0 |
ip | Show/manipulate routing, devices, policy routing. | ip addr show |
hostname | Show or set the system’s hostname. | hostname |
nslookup | Query Internet name servers interactively. | nslookup google.com |
dig | DNS lookup utility. | dig google.com |
arp | Manipulate the system ARP cache. | arp -a |
route | Show/manipulate the IP routing table. | route -n |
tcpdump | Command-line packet analyzer. | tcpdump -i eth0 |
wireshark | Network protocol analyzer with GUI. | wireshark |
nc (netcat) | Utility for reading and writing from/to network connections. | nc -zv google.com 80 |
curl | Transfer data from or to a server. | curl -I http://google.com |
wget | Non-interactive network downloader. | wget http://example.com/file.zip |
rsync | Remote file and directory synchronization. | rsync -avz /path/to/source /path/to/dest |
scp | Secure copy (remote file copy program). | scp file.txt user@remote:/path/to/dest |
ssh | OpenSSH SSH client (remote login program). | ssh user@remote |
fdisk | Partition table manipulator for Linux. | fdisk -l |
mkfs | Build a Linux file system. | mkfs.ext4 /dev/sda1 |
mount | Mount a file system. | mount /dev/sda1 /mnt |
umount | Unmount file systems. | umount /mnt |
fsck | File system consistency check and repair. | fsck /dev/sda1 |
lsblk | List information about block devices. | lsblk |
blkid | Locate/print block device attributes. | blkid |
modprobe | Add and remove modules from the Linux Kernel. | modprobe module_name |
systemctl | Control the systemd system and service manager. | systemctl restart nginx |
journalctl | Query and display messages from the journal. | journalctl -u nginx.service |
crontab | Schedule jobs to run periodically. | crontab -e |
date | Display or set the system date and time. | date |
timedatectl | Control the system time and date. | timedatectl status |
df | Report file system disk space usage. | df -h |
du | Estimate file space usage. | du -sh /var/log |
dd | Convert and copy a file. | dd if=/dev/sda of=/dev/sdb bs=4M |
find | Search for files in a directory hierarchy. | find /var/log -name "*.log" |
grep | Search text using patterns. | grep "error" /var/log/syslog |
tail | Output the last part of files. | tail -n 100 /var/log/syslog |
head | Output the first part of files. | head -n 20 /var/log/syslog |
less | View file contents in a scrollable manner. | less /var/log/syslog |
cat | Concatenate and display file contents. | cat /var/log/syslog |
echo | Display a line of text. | echo "Hello, World!" |
chmod | Change file permissions. | chmod 755 script.sh |
chown | Change file owner and group. | chown user:group file.txt |
stat | Display file or file system status. | stat file.txt |
touch | Change file timestamps or create an empty file. | touch newfile.txt |
sar | Collect, report, or save system activity information. | sar -u 1 3 |
sysctl | Configure kernel parameters at runtime. | sysctl -a |
arch | Print machine architecture. | arch |
lsmod | Show the status of modules in the Linux Kernel. | lsmod |
parted | A partition manipulation program. | parted /dev/sda |
hwclock | Query and set the hardware clock (RTC). | hwclock --show |
uptime | Tell how long the system has been running. | uptime |
hostnamectl | Control the system hostname. | hostnamectl |
iostat | Report CPU and I/O statistics. | iostat -x 5 3 |
nmap | Network exploration tool and security scanner. | nmap -sP 192.168.1.0/24 |
telnet | User interface to the TELNET protocol. | telnet google.com 80 |
ethtool | Display or change Ethernet device settings. | ethtool eth0 |
ip addr | Show/manipulate network interfaces. | ip addr show |
ip link | Display and modify network interfaces. | ip link set eth0 up |
dmidecode | Dump computer’s DMI (some say SMBIOS) table contents in human-readable format. | dmidecode |
Top 100 Linux Troubleshooting Commands with Examples
Command | Description | Example |
---|---|---|
top | Display tasks and system information. | top |
htop | Interactive process viewer. | htop |
ps | Display current processes. | ps aux |
kill | Terminate a process by PID. | kill -9 1234 |
pkill | Terminate a process by name. | pkill firefox |
pgrep | Find process IDs by name. | pgrep apache2 |
free | Display memory usage. | free -h |
df | Display disk space usage. | df -h |
du | Estimate file space usage. | du -sh /var/log |
iostat | Report CPU and I/O statistics. | iostat |
vmstat | Report virtual memory statistics. | vmstat |
netstat | Network statistics. | netstat -tuln |
ss | Display socket statistics. | ss -tuln |
lsof | List open files. | lsof /var/log/syslog |
strace | Trace system calls and signals. | strace -p 1234 |
dmesg | Kernel ring buffer. | `dmesg |
journalctl | Query systemd journal. | journalctl -xe |
systemctl | Control systemd services. | systemctl status httpd |
service | Control system services. | service apache2 status |
uptime | Show system uptime. | uptime |
who | Show who is logged on. | who |
w | Show who is logged on and what they are doing. | w |
last | Show last logins of users. | last |
ping | Send ICMP ECHO_REQUEST to network hosts. | ping google.com |
traceroute | Print the route packets take to the network host. | traceroute google.com |
ifconfig | Configure network interfaces. | ifconfig eth0 |
ip | Show/manipulate routing, devices, policy routing. | ip addr show |
hostname | Show or set the system’s hostname. | hostname |
nslookup | Query Internet name servers interactively. | nslookup google.com |
dig | DNS lookup utility. | dig google.com |
arp | Manipulate the system ARP cache. | arp -a |
route | Show/manipulate the IP routing table. | route -n |
tcpdump | Command-line packet analyzer. | tcpdump -i eth0 |
wireshark | Network protocol analyzer with GUI. | wireshark |
nc (netcat) | Utility for reading and writing from/to network connections. | nc -zv google.com 80 |
curl | Transfer data from or to a server. | curl -I http://google.com |
wget | Non-interactive network downloader. | wget http://example.com/file.zip |
rsync | Remote file and directory synchronization. | rsync -avz /path/to/source /path/to/dest |
scp | Secure copy (remote file copy program). | scp file.txt user@remote:/path/to/dest |
ssh | OpenSSH SSH client (remote login program). | ssh user@remote |
fdisk | Partition table manipulator for Linux. | fdisk -l |
mkfs | Build a Linux file system. | mkfs.ext4 /dev/sda1 |
mount | Mount a file system. | mount /dev/sda1 /mnt |
umount | Unmount file systems. | umount /mnt |
fsck | File system consistency check and repair. | fsck /dev/sda1 |
lsblk | List information about block devices. | lsblk |
blkid | Locate/print block device attributes. | blkid |
modprobe | Add and remove modules from the Linux Kernel. | modprobe module_name |
systemctl | Control the systemd system and service manager. | systemctl restart nginx |
journalctl | Query and display messages from the journal. | journalctl -u nginx.service |
crontab | Schedule jobs to run periodically. | crontab -e |
date | Display or set the system date and time. | date |
timedatectl | Control the system time and date. | timedatectl status |
df | Report file system disk space usage. | df -h |
du | Estimate file space usage. | du -sh /var/log |
dd | Convert and copy a file. | dd if=/dev/sda of=/dev/sdb bs=4M |
find | Search for files in a directory hierarchy. | find /var/log -name "*.log" |
grep | Search text using patterns. | grep "error" /var/log/syslog |
tail | Output the last part of files. | tail -n 100 /var/log/syslog |
head | Output the first part of files. | head -n 20 /var/log/syslog |
less | View file contents in a scrollable manner. | less /var/log/syslog |
cat | Concatenate and display file contents. | cat /var/log/syslog |
echo | Display a line of text. | echo "Hello, World!" |
chmod | Change file permissions. | chmod 755 script.sh |
chown | Change file owner and group. | chown user:group file.txt |
stat | Display file or file system status. | stat file.txt |
touch | Change file timestamps or create an empty file. | touch newfile.txt |
sar | Collect, report, or save system activity information. | sar -u 1 3 |
sysctl | Configure kernel parameters at runtime. | sysctl -a |
arch | Print machine architecture. | arch |
lsmod | Show the status of modules in the Linux Kernel. | lsmod |
parted | A partition manipulation program. | parted /dev/sda |
hwclock | Query and set the hardware clock (RTC). | hwclock --show |
uptime | Tell how long the system has been running. | uptime |
hostnamectl | Control the system hostname. | hostnamectl |
iostat | Report CPU and I/O statistics. | iostat -x 5 3 |
nmap | Network exploration tool and security scanner. | nmap -sP 192.168.1.0/24 |
telnet | User interface to the TELNET protocol. | telnet google.com 80 |
ethtool | Display or change Ethernet device settings. | ethtool eth0 |
ip addr | Show/manipulate network interfaces. | ip addr show |
ip link | Display and modify network interfaces. | ip link set eth0 up |
dmidecode | Dump computer’s DMI (some say SMBIOS) table contents in human-readable format. | dmidecode |
uname | Print system information. | uname -a |
sar | Collect, report, or save system activity information. | sar -u 1 3 |
sysctl | Configure kernel parameters at runtime. | sysctl -a |
nstat | Network statistics utility. | nstat |
ss | Display socket statistics. | ss -tuln |
watch | Execute a program periodically, showing output fullscreen. | watch df -h |
tshark | Network protocol analyzer (text-based Wireshark). | tshark -i eth0 |
iftop | Display bandwidth usage on an interface by host. | iftop -i eth0 |
ipset | Admin tool to manage IP sets in the Linux kernel. | ipset list |
iptables | Admin tool to configure IPv4 packet filtering rules. | iptables -L |
firewalld | Dynamic firewall daemon with D-Bus interface. | firewall-cmd --list-all |
ping6 | Send ICMP ECHO_REQUEST to network hosts (IPv6). | ping6 google.com |
traceroute6 | Print the route packets take to the network host (IPv6). | traceroute6 google.com |
route | Show/manipulate the IP routing table. | route -n |
nmap | Network exploration tool and security scanner. | nmap -sP 192.168.1.0/24 |
dig | DNS lookup utility. | dig google.com |
host | DNS lookup utility. | host google.com |
netstat | Network statistics. | netstat -tuln |
arp | Manipulate the system ARP cache. | arp -a |
route | Show/manipulate the IP routing table. | route -n |
iwconfig | Configure wireless network interfaces. | iwconfig |
iwlist | Get more detailed wireless information. | iwlist scanning |
nmcli | Command-line client for NetworkManager. | nmcli dev status |
ifdown | Take a network interface down. | ifdown eth0 |
ifup | Bring a network interface up. | ifup eth0 |
ss | Display socket statistics. | ss -tuln |
ip a | Show/manipulate network interfaces. | ip a |
ip link | Display and modify network interfaces. | ip link set eth0 up |
ip route | Show/manipulate the IP routing table. | ip route show |
ip addr | Show/manipulate network interfaces. | ip addr show |
ethtool | Display or change Ethernet device settings. | ethtool eth0 |
mtr | Network diagnostic tool combining ping and traceroute. | mtr google.com |
bmon | Bandwidth monitor and rate estimator. | bmon |
iftop | Display bandwidth usage on an interface by host. | iftop -i eth0 |
iptraf | Network monitoring utility. | iptraf |
Complex Linux Troubleshooting Commands (Combined with Other Commands)
Command Combination | Description | Example |
---|---|---|
`ps aux | grep process_name` | Search for a specific process by name. |
`du -sh * | sort -rh` | List directory sizes and sort them by size in descending order. |
find / -type f -name "file" | Find files by name starting from the root directory. | find / -type f -name "error.log" |
`dmesg | grep -i error` | Search for error messages in the kernel ring buffer. |
`netstat -tuln | grep LISTEN` | Display listening network connections. |
`ss -tuln | grep LISTEN` | Show listening sockets with ss command. |
lsof -i :port_number | List open files and ports. | lsof -i :80 |
tail -f /var/log/syslog | Continuously monitor log file changes. | tail -f /var/log/syslog |
grep -r "search_term" /path | Recursively search for a term within a directory. | grep -r "ERROR" /var/log |
`df -h | grep /dev/sd` | Show disk space usage for specific devices. |
`top -b -n 1 | head -n 20` | Batch mode operation of top , useful for logging or scripting. |
strace -p $(pgrep process) | Trace system calls and signals for a process. | strace -p $(pgrep apache2) |
`ip addr show | grep inet` | Display IP addresses. |
iostat -x 1 5 | Extended I/O statistics report every second for 5 times. | iostat -x 1 5 |
watch -n 5 'df -h' | Monitor disk usage every 5 seconds. | watch -n 5 'df -h' |
journalctl -f | Follow the systemd journal in real time. | journalctl -f |
vmstat 1 5 | Report system performance statistics every second for 5 times. | vmstat 1 5 |
ping -c 5 google.com | Ping a host 5 times. | ping -c 5 google.com |
find / -mtime -1 | Find files modified within the last 24 hours. | find / -mtime -1 |
awk '{print $1}' file.txt | Extract the first column from a text file using awk . | awk '{print $1}' file.txt |
sed -n '5,10p' file.txt | Print lines 5 to 10 from a file using sed . | sed -n '5,10p' file.txt |
tar czvf archive.tar.gz dir/ | Create a compressed tarball of a directory. | tar czvf archive.tar.gz /path/to/dir |
tcpdump -i eth0 port 80 | Capture network packets on port 80. | tcpdump -i eth0 port 80 |
nmap -sP 192.168.1.0/24 | Perform a ping scan on a subnet using nmap . | nmap -sP 192.168.1.0/24 |
curl -I http://google.com | Fetch HTTP headers using curl . | curl -I http://google.com |
wget -qO- http://google.com | Download the contents of a URL and display them. | wget -qO- http://google.com |
rsync -avz /src /dest | Synchronize files and directories between two locations. | rsync -avz /path/to/source /path/to/destination |
scp file.txt user@remote:/path | Securely copy a file to a remote server using scp . | scp file.txt user@remote:/path |
ssh user@remote 'command' | Execute a command on a remote server via SSH. | ssh user@remote 'df -h' |
fdisk -l /dev/sda | List partition tables for a specific device. | fdisk -l /dev/sda |
mkfs.ext4 /dev/sda1 | Create an ext4 file system on a partition. | mkfs.ext4 /dev/sda1 |
mount /dev/sda1 /mnt | Mount a file system. | mount /dev/sda1 /mnt |
umount /mnt | Unmount a file system. | umount /mnt |
fsck /dev/sda1 | Check and repair a file system. | fsck /dev/sda1 |
lsblk -f | List block devices with file system information. | lsblk -f |
blkid /dev/sda1 | Print the UUID of a file system. | blkid /dev/sda1 |
modprobe module_name | Load a kernel module. | modprobe module_name |
rmmod module_name | Remove a kernel module. | rmmod module_name |
systemctl restart service | Restart a systemd service. | systemctl restart nginx |
journalctl -u service | View logs for a specific systemd service. | journalctl -u nginx.service |
`crontab -l | grep job` | List scheduled cron jobs and filter by job. |
date +%Y-%m-%d | Print the current date in YYYY-MM-DD format. | date +%Y-%m-%d |
timedatectl set-time 'HH:MM:SS' | Set the system time. | timedatectl set-time '12:00:00' |
df -h /dev/sda1 | Show disk space usage for a specific device. | df -h /dev/sda1 |
`du -sh /var/* | sort -rh` | Display size of directories under /var and sort them by size. |
dd if=/dev/zero of=/tmp/test.img bs=1M count=1024 | Create a 1GB test file using dd . | dd if=/dev/zero of=/tmp/test.img bs=1M count=1024 |
find / -type f -mtime -1 | Find files modified in the last 24 hours. | find / -type f -mtime -1 |
grep -i error /var/log/syslog | Search for case-insensitive error messages in syslog. | grep -i error /var/log/syslog |
tail -n 50 /var/log/syslog | Display the last 50 lines of the syslog file. | tail -n 50 /var/log/syslog |
head -n 10 /var/log/syslog | Display the first 10 lines of the syslog file. | head -n 10 /var/log/syslog |
less /var/log/syslog | View the syslog file with less for easy navigation. | less /var/log/syslog |
`cat /etc/passwd | grep user` | Search for a specific user in the passwd file. |
chmod 755 script.sh | Change file permissions to make a script executable. | chmod 755 script.sh |
chown user:group file | Change the owner and group of a file. | chown user:group file.txt |
stat file.txt | Display detailed information about a file. | stat file.txt |
touch /tmp/newfile | Create a new empty file or update the timestamp of an existing file. | touch /tmp/newfile |
sar -u 1 5 | Collect and display CPU usage every second for 5 seconds. | sar -u 1 5 |
`sysctl -a | grep net.ipv4` | List all IPv4 network kernel parameters. |
arch | Print the machine architecture. | arch |
`lsmod | grep module` | List currently loaded kernel modules and filter by name. |
parted /dev/sda print | Display partition information for a specific device. | parted /dev/sda print |
hwclock --systohc | Set the hardware clock to the current system time. | hwclock --systohc |
uname -a | Print all system information. | uname -a |
ip addr show dev eth0 | Display detailed information about a specific network interface. | ip addr show dev eth0 |
ip link set eth0 up | Bring a network interface up. | ip link set eth0 up |
ip route add default via 192.168.1.1 | Add a default gateway. | ip route add default via 192.168.1.1 |
ethtool eth0 | Display or change Ethernet device settings. | ethtool eth0 |
mtr google.com | Network diagnostic tool combining ping and traceroute. | mtr google.com |
iftop -i eth0 | Display bandwidth usage on an interface by host. | iftop -i eth0 |
tcpdump -i eth0 port 80 | Capture network packets on port 80. | tcpdump -i eth0 port 80 |
nmap -sP 192.168.1.0/24 | Perform a ping scan on a subnet using nmap . | nmap -sP 192.168.1.0/24 |
watch -n 5 'df -h' | Monitor disk usage every 5 seconds. | watch -n 5 'df -h' |
journalctl -f | Follow the systemd journal in real time. | journalctl -f |
vmstat 1 5 | Report system performance statistics every second for 5 times. | vmstat 1 5 |
ping -c 5 google.com | Ping a host 5 times. | ping -c 5 google.com |
find / -mtime -1 | Find files modified within the last 24 hours. | find / -mtime -1 |
awk '{print $1}' file.txt | Extract the first column from a text file using awk . | awk '{print $1}' file.txt |
sed -n '5,10p' file.txt | Print lines 5 to 10 from a file using sed . | sed -n '5,10p' file.txt |
tar czvf archive.tar.gz dir/ | Create a compressed tarball of a |
Command Combination | Description | Example |
---|---|---|
tar xzvf archive.tar.gz -C /path | Extract a tar.gz archive to a specified path. | tar xzvf archive.tar.gz -C /path/to/extract |
find /path -type f -exec ls -lh {} \; | Find files and list them with detailed information. | find /var/log -type f -exec ls -lh {} \; |
chmod -R 755 /path/to/dir | Recursively change permissions of a directory and its contents. | chmod -R 755 /var/www/html |
chown -R user:group /path/to/dir | Recursively change the owner and group of a directory and its contents. | chown -R user:group /var/www/html |
xargs -n 1 | Build and execute command lines from standard input. | `echo “file1 file2 file3” |
`ps -eo pid,ppid,cmd,%mem,%cpu –sort=-%mem | head` | List processes sorted by memory usage. |
watch -n 1 'cat /proc/meminfo' | Monitor memory usage in real-time. | watch -n 1 'cat /proc/meminfo' |
vmstat -s | Display summary of system statistics. | vmstat -s |
iostat -m 1 | Monitor disk I/O statistics in megabytes. | iostat -m 1 |
top -u user | Display processes for a specific user. | top -u root |
iftop -n -P | Display bandwidth usage without resolving hostnames and show ports. | iftop -n -P |
tcpdump -A -i eth0 | Capture and display packets in ASCII. | tcpdump -A -i eth0 |
ethtool -S eth0 | Display network interface statistics. | ethtool -S eth0 |
netstat -i | Display network interface statistics. | netstat -i |
ip -s link | Display network statistics for all interfaces. | ip -s link |
ss -s | Display socket statistics summary. | ss -s |
iptables -L -v -n | List all iptables rules with detailed information. | iptables -L -v -n |
firewall-cmd --list-all | Display current firewalld settings. | firewall-cmd --list-all |
ping -I eth0 google.com | Send ICMP ECHO_REQUEST from a specific interface. | ping -I eth0 google.com |
nmap -A 192.168.1.1 | Perform a comprehensive scan on a host, including OS detection. | nmap -A 192.168.1.1 |
curl -o /dev/null -s -w "%{http_code}\n" http://google.com | Check the HTTP status code of a URL. | curl -o /dev/null -s -w "%{http_code}\n" http://google.com |
`wget -O- http://example.com | grep “HTML”` | Download a webpage and search for a specific string. |
rsync -avz --delete /src /dest | Synchronize files and directories, deleting files at the destination if they don’t exist at source. | rsync -avz --delete /path/to/source /path/to/destination |
scp -r user@remote:/path /local | Securely copy a directory from a remote server. | scp -r user@remote:/path/to/remote /path/to/local |
ssh -L 5900:localhost:5900 user@remote | Create an SSH tunnel for VNC. | ssh -L 5900:localhost:5900 user@remote |
dd if=/dev/sda of=/dev/sdb bs=4M | Clone a disk using dd . | dd if=/dev/sda of=/dev/sdb bs=4M |
find /var/log -type f -mtime +30 -delete | Find and delete log files older than 30 days. | find /var/log -type f -mtime +30 -delete |
`grep -E ‘error | fail | critical’ /var/log/syslog` |
`tail -f /var/log/syslog | grep “error”` | Continuously monitor log file for specific strings. |
head -n 50 /var/log/syslog | Display the first 50 lines of the syslog file. | head -n 50 /var/log/syslog |
less +F /var/log/syslog | View the syslog file with less in follow mode. | less +F /var/log/syslog |
awk '{print $1, $4}' file.txt | Extract and print specific columns from a text file using awk . | awk '{print $1, $4}' file.txt |
sed 's/error/ERROR/g' file.txt | Replace all occurrences of a string in a file using sed . | sed 's/error/ERROR/g' file.txt |
`tar cf – . | (cd /new/dir && tar xf -)` | Copy a directory structure preserving permissions and timestamps. |
tcpdump -i eth0 -w capture.pcap | Capture network packets and save to a file. | tcpdump -i eth0 -w capture.pcap |
nmap -p 1-65535 localhost | Scan all ports on the local machine using nmap . | nmap -p 1-65535 localhost |
curl -X POST -d "param1=value1¶m2=value2" http://example.com | Send a POST request with data using curl . | curl -X POST -d "param1=value1¶m2=value2" http://example.com |
wget -r -np -k http://example.com | Download an entire website recursively using wget . | wget -r -np -k http://example.com |
rsync -av --progress /src /dest | Synchronize files and show progress. | rsync -av --progress /path/to/source /path/to/destination |
scp -i /path/to/key file user@remote:/path | Use a specific SSH key to securely copy a file to a remote server. | scp -i /path/to/key file user@remote:/path |
ssh user@remote 'df -h; free -m' | Execute multiple commands on a remote server via SSH. | ssh user@remote 'df -h; free -m' |
dd if=/dev/zero of=/tmp/testfile bs=1M count=1024 | Create a 1GB test file filled with zeros using dd . | dd if=/dev/zero of=/tmp/testfile bs=1M count=1024 |
find / -type f -exec md5sum {} \; | Generate MD5 checksums for all files on the system. | find / -type f -exec md5sum {} \; |
grep -v '^#' /etc/fstab | Display non-comment lines from a configuration file. | grep -v '^#' /etc/fstab |
tail -n +10 file.txt | Display lines starting from line 10. | tail -n +10 file.txt |
head -c 100 file.txt | Display the first 100 bytes of a file. | head -c 100 file.txt |
awk '/pattern1/ && /pattern2/' file.txt | Search for lines containing multiple patterns using awk . | awk '/pattern1/ && /pattern2/' file.txt |
sed -i 's/foo/bar/g' file.txt | Edit a file in place, replacing all occurrences of a string using sed . | sed -i 's/foo/bar/g' file.txt |
`tar czf – dir | ssh user@remote ‘cat > /path/to/backup.tar.gz’` | Create a tarball and send it directly to a remote server via SSH. |
tcpdump -nn -v -i eth0 | Capture and display packets without resolving hostnames or ports. | tcpdump -nn -v -i eth0 |
nmap -O 192.168.1.1 | Detect the operating system of a remote host using nmap . | nmap -O 192.168.1.1 |
curl -s -o /dev/null -w "%{time_total}\n" http://example.com | Measure the total time taken to download a URL using curl . | curl -s -o /dev/null -w "%{time_total}\n" http://example.com |
wget --limit-rate=100k http://example.com/file.zip | Download a file with a specified download rate limit using wget . | wget --limit-rate=100k http://example.com/file.zip |
rsync -azP user@remote:/path/to/src /local/dest | Synchronize files with partial transfer and compression. | rsync -azP user@remote:/path/to/src /local/dest |
scp -3 user1@host1:/path user2@host2:/path | Securely copy files between two remote hosts. | scp -3 user1@host1:/path user2@host2:/path |
ssh -R 8080:localhost:80 user@remote | Create a reverse SSH tunnel. | ssh -R 8080:localhost:80 user@remote |
`dd if=/dev/sda bs=512 count=1 | hexdump -C` | Display the MBR (Master Boot Record) of a disk in a human-readable format. |
find /var/log -type f -size +100M | Find files larger than 100MB. | find /var/log -type f -size +100M |
grep -c "ERROR" /var/log/syslog | Count occurrences of a specific string in a log file. | grep -c "ERROR" /var/log/syslog |
`tail -n 1000 /var/log/syslog | grep “error” | less` |
awk 'NR>=10 && NR<=20' file.txt | Extract lines from 10 to 20 from a file using awk . | awk 'NR>=10 && NR<=20' file.txt |
sed -e 's/foo/bar/' -e 's/baz/qux/' file.txt | Apply multiple search-and-replace patterns using sed . | sed -e 's/foo/bar/' -e 's/baz/qux/' file.txt |
`tar czf – dir | ssh user@remote ‘dd of=/path/to/backup.tar.gz’` | Create a tarball and send it to a remote server using dd . |
tcpdump -i eth0 'port 80 and (((ip[6:2] & 0x1fff) = 0) and (tcp[13] = 0x18))' | Capture only complete HTTP packets. | `tcpdump -i eth0 ‘port 80 and (((ip[6:2] & 0x1fff) = |