Command Combination | Description | Example |
---|---|---|
dd if=/dev/urandom of=/tmp/randomfile bs=1M count=10 | Create a 10MB file with random data. | dd if=/dev/urandom of=/tmp/randomfile bs=1M count=10 |
find / -name "*.log" -mtime +30 | Find log files older than 30 days. | find / -name "*.log" -mtime +30 |
grep -B 5 -A 5 "ERROR" /var/log/syslog | Show 5 lines before and after matches in log file. | grep -B 5 -A 5 "ERROR" /var/log/syslog |
`tail -n 1000 /var/log/syslog | grep -i “fail”` | Filter the last 1000 lines of syslog for case-insensitive “fail”. |
`head -n 50 /var/log/syslog | grep “warn”` | Display the first 50 lines of syslog and filter for “warn”. |
less +F /var/log/syslog | View and follow the syslog file in real-time using less. | less +F /var/log/syslog |
awk '{print $1, $2, $5}' /var/log/syslog | Extract and print specific columns from syslog using awk . | awk '{print $1, $2, $5}' /var/log/syslog |
sed 's/error/ERROR/g' /var/log/syslog | Replace “error” with “ERROR” in syslog using sed . | sed 's/error/ERROR/g' /var/log/syslog |
`tar czf – /path/to/dir | ssh user@remote ‘cat > /path/to/backup.tar.gz’` | Create a tarball of a directory and send it to a remote server. |
tcpdump -i eth0 -w /tmp/capture.pcap | Capture network packets on eth0 and save to a file. | tcpdump -i eth0 -w /tmp/capture.pcap |
nmap -p 1-65535 192.168.1.1 | Scan all ports on a specific IP using nmap . | nmap -p 1-65535 192.168.1.1 |
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 | Recursively download a website using wget . | wget -r -np -k http://example.com |
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 using scp . | scp -r user@remote:/path /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 bs=512 count=1 | hexdump -C` | Display the MBR (Master Boot Record) of a disk in human-readable format using dd . |
find /var/log -type f -size +100M | Find files larger than 100MB in /var/log. | find /var/log -type f -size +100M |
grep -c "ERROR" /var/log/syslog | Count occurrences of “ERROR” in syslog. | grep -c "ERROR" /var/log/syslog |
`tail -n 1000 /var/log/syslog | grep “error” | less` |
awk 'NR>=10 && NR<=20' /var/log/syslog | Extract lines 10 to 20 from syslog using awk . | awk 'NR>=10 && NR<=20' /var/log/syslog |
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 – /path/to/dir | ssh user@remote ‘dd of=/path/to/backup.tar.gz’` | Create a tarball of a directory 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 using tcpdump . | tcpdump -i eth0 'port 80 and (((ip[6:2] & 0x1fff) = 0) and (tcp[13] = 0x18))' |
nmap --script vuln 192.168.1.1 | Scan a host for vulnerabilities using nmap scripts. | nmap --script vuln 192.168.1.1 |
curl -u user:password http://example.com | Send a GET request with basic authentication using curl . | curl -u user:password http://example.com |
wget -b http://example.com/file.zip | Download a file in the background using wget . | wget -b http://example.com/file.zip |
rsync -e ssh -av /local/dir user@remote:/remote/dir | Synchronize files using a remote shell program via rsync . | rsync -e ssh -av /local/dir user@remote:/remote/dir |
scp -C file user@remote:/path | Securely copy files with compression enabled using scp . | scp -C file user@remote:/path |
ssh -D 8080 user@remote | Create a dynamic application-level port forwarding tunnel (SOCKS proxy) using ssh . | ssh -D 8080 user@remote |
dd if=/dev/sda of=/tmp/mbr.img bs=512 count=1 | Backup the MBR of a disk using dd . | dd if=/dev/sda of=/tmp/mbr.img bs=512 count=1 |
find /etc -name "*.conf" -exec grep -H "pattern" {} \; | Find configuration files and search for a pattern within them using grep . | find /etc -name "*.conf" -exec grep -H "pattern" {} \; |
grep -rl "ERROR" /var/log | Recursively search for files containing “ERROR” in /var/log using grep . | grep -rl "ERROR" /var/log |
`tail -n 100 /var/log/syslog | awk ‘{print $1, $2, $5}’ | less` |
awk '$3 == "ERROR"' /var/log/syslog | Filter lines in syslog where the third column is “ERROR” using awk . | awk '$3 == "ERROR"' /var/log/syslog |
sed -n '/start/,/end/p' file.txt | Extract lines between two patterns using sed . | sed -n '/start/,/end/p' file.txt |
`tar czf – /path/to/dir | gzip > backup.tar.gz` | Create a compressed tarball of a directory using tar and gzip . |
tcpdump -i eth0 -c 1000 -w capture.pcap | Capture a specified number of packets and save to a file using tcpdump . | tcpdump -i eth0 -c 1000 -w capture.pcap |
nmap -sS -sV -O 192.168.1.1 | Perform a stealth scan with service version detection and OS detection using nmap . | nmap -sS -sV -O 192.168.1.1 |
curl -o output.html -L http://example.com | Download a webpage and follow redirects using curl . | curl -o output.html -L http://example.com |
`wget -qO- http://example.com | grep “pattern”` | Quietly download a webpage and search for a specific pattern using grep . |
rsync -a --delete /src /dest | Synchronize files and delete extraneous files from the destination using rsync . | rsync -a --delete /path/to/source /path/to/destination |
scp -P 2222 file user@remote:/path | Securely copy a file to a remote server using a specific port with scp . | scp -P 2222 file user@remote:/path |
`ssh user@remote ‘tar czf – /path’ | tar xzf – -C /local/path` | Create a tarball on a remote server and extract it locally. |
rsync -e "ssh -p 2222" -av /src user@remote:/dest | Synchronize files using a non-default SSH port with rsync . | rsync -e "ssh -p 2222" -av /path/to/source user@remote:/path/to/destination |
`curl -s http://example.com | grep “pattern”` | Quietly fetch a webpage and search for a pattern using grep . |
`dd if=/dev/sda | gzip > /tmp/disk_image.gz` | Create a compressed disk image using dd and gzip . |
find /var/log -type f -exec cp {} /backup/ \; | Copy all files from /var/log to /backup using find and cp . | find /var/log -type f -exec cp {} /backup/ \; |
awk 'NR % 2 == 0' file.txt | Print every second line of a file using awk . | awk 'NR % 2 == 0' file.txt |
sed -i '/pattern/d' file.txt | Delete lines matching a pattern in a file using sed . | sed -i '/pattern/d' file.txt |
tar --exclude='*.log' -czf archive.tar.gz /path | Create a compressed tarball excluding specific files using tar . | tar --exclude='*.log' -czf archive.tar.gz /path/to/dir |
tcpdump -i eth0 -A -w capture.pcap | Capture network packets in ASCII and save to a file using tcpdump . | tcpdump -i eth0 -A -w capture.pcap |
curl -o output.html -L http://example.com | Download a webpage and follow redirects using curl | curl -o output.html -L http://example.com |
nmap -Pn 192.168.1.1 | Perform a pingless scan to detect a host even if ICMP is blocked using nmap . | nmap -Pn 192.168.1.1 |
curl -X DELETE http://example.com/resource | Send a DELETE request to remove a resource using ` |
Login
0 Comments