-
Find files containing AAA in all files in the current directory
ls |grep aaa ./*
-
Find the file named AA in the current path
find aa.*
-
Find the process currently occupying port 80
netstat -antpl |grep 80
-
View logs dynamically
tail -f 日志路径
tailf
-
ddos attack command
etstat -nut |awk '{print $5}' | cut -d: -f1 |sort|uniq -c|sort -n
-
Use awk to intercept the IP of the current server
ifconfig eth0 |grep netmask |awk '{print $2}'
-
Use AWK to intercept the ip of the current server and show it as IP: xxxx
ifconfig eth0 |grep netmask |awk '{print "ip:" $2}'
-
Look at line 64 of the passwd file
cat /etc/passwd|head -64|tail -1
sed -n ' 行数p'/etc/passwd
-
View a file and compress the continuous blank lines of the file into one line
cat -s 文件名
-
Query the line ending with abc in the txt file
grep abc$ txt
-
Delete blank lines in txt file
grep -v '^\s*$' 文件名 sed '/^\s*$/d'文件名 sed -i '/^$/d' file.txt
-
Backup and restore the mysql database test library
备份: mysqldump -u root -p test >备份路径 恢复: mysql -u root -p test <文件路径
-
iptables prohibit 192.168.1.64 local access port 80
iptables -I INPUT -s 192.168.1.64 -p TCP --dport 80 -j ACCEPT
-
View the number of concurrent requests http
netstat -an | grep ESTABLISHED | wc -l
-
Find the ip most visited by Apache, the top 10
awk
'{print $1}'日志文件名 |sort |uniq -c|sort-nr|head -行数
-
Statistics Number of files in / var / log directory
cat /var/log|wc -l
-
Taken Linux system, the network address of the machine, the format 172.168.1.200/255.255.255.0
ifconfig eth0 |grep netmask |awk '{print $2 "/" $4 }
-
View the current available memory
free
df -h
-
After entering mysql, reset the password
在/etc/my.cnf中写入skip-grant-tables 用来跳过密码验证
登入mysql
update user set password=PASSWORD('xxx') where user='root';
刷新权限
flush privileges;
去掉配置文件中的 skip,然后重启mysql 在使用账户和密码登录
- Linux which support the power and resume function
isync