ls -l detailed information
ls /dev/ -ls very detailed
ls -a show hidden
ls -lh easy to see
ls -lh --sort=size Sort by size
. The beginning is hidden
cd /media/ Enter
cd .. upper level
pwd current working directory
cat /var/log/messages carefully view all text files
more /var/log/messages Look carefully at the text file
one screen at a time, keep pressing enter, stop pressing Q, display percentage
less /var/log/messages Look carefully at the text file
one screen at a time, keep pressing enter, stop pressing Q, no percentages are displayed
tail /var/log/messages If you look closely at the text file
, it will show the last ten lines by default.
tail -20 /var/log/messages will show the last twenty lines.
watch -n 2 tail -20 /var/log/messages displays the countdown 20 lines every 2 seconds
rm a.txt delete file
rm -ra delete folder
cp a.txt b.txt copy
cp -ra / b copy folder
top monitor system performance
ps see process information
ps -ef see detailed process information
ps aux detailed information, slightly different
cat /etc/passwd to see some information
grep ssh /etc/passwd to see the line containing ssh
ifconfig check IP
ifconfig eth0 down
ifconfig eth0 up
kill, enable
macchanger -m 00:11:11:11:11:11 eth0 Change the MAC address
netstat -pantu to see the server connected to TCP/UDP
netstat -pantu | egrep -v '0.0.0.0|:::'
to see the connection, excluding 0.0.0.0 and :::
netstat -pantu | egrep -v '0.0.0.0|:::' | awk '{print $5}' | egrep -v 'and|Address'
to see the connected external network IP
netstat -pantu | egrep -v '0.0.0.0|:::' | awk '{print $5}' | egrep -v 'and|Address' | cut -d ':' -f 1
Look at the IP connected to the external network IP , without looking at the port number (: split)
netstat -pantu | egrep -v '0.0.0.0|:::' | awk '{print $5}' |
egrep -v 'and|Address' | cut -d ':' -f 1 | sort | uniq
sort deduplication result
netstat -pantu | egrep -v '0.0.0.0|:::' | awk '{print $5}' |
egrep -v 'and|Address' | cut -d ':' -f 1 | sort | uniq > ip
output to the ip file
netstat -pantu | egrep -v '0.0.0.0|:::' | awk '{print $5}' |
egrep -v 'and|Address' | cut -d ':' -f 1 | sort | uniq >> ip
Append to ip file
find / -name nmap find nmap files
find / -iname nmap find nmap files, case insensitive
find . -name "ps*" to the file starting with ps in the current directory
whereis nmap find, fast
whereis -b nmap find binary files
updatedb update the database
vi open VIM
:wq save and exit
dd delete a line
o insert a line
cd aaa & ls execute
cd aaa || ls together If the former is unsuccessful, execute the latter
Shell programming
vi 1.sh Open 1.sh to edit
i to enter edit mode
#!/bin/bash
echo -n "IP:" (-n不换行)
read ip
echo "Your IP is:" $ip
chmod +x 1.sh gives execute permission./1.sh
execute
apt-get update upgrade index
apt-get upgrade upgrade