Insights on some basic commands in Linux (20 bases)

  1. Find files containing AAA in all files in the current directory

    ls |grep aaa ./*

  2. Find the file named AA in the current path

    find aa.*

  3. Find the process currently occupying port 80

    netstat -antpl |grep 80

  4. View logs dynamically

    ​tail -f 日志路径
    tailf

  5. ddos attack command

    etstat -nut |awk '{print $5}' | cut -d: -f1 |sort|uniq -c|sort -n

  6. Use awk to intercept the IP of the current server

    ​ ifconfig eth0 |grep netmask |awk '{print $2}'

  7. Use AWK to intercept the ip of the current server and show it as IP: xxxx

    ifconfig eth0 |grep netmask |awk '{print "ip:" $2}'

  8. Look at line 64 of the passwd file

    cat /etc/passwd|head -64|tail -1

    ​ sed -n ' 行数p'/etc/passwd

  9. View a file and compress the continuous blank lines of the file into one line

    ​cat -s 文件名

  10. Query the line ending with abc in the txt file

    grep abc$ txt

  11. Delete blank lines in txt file

    grep -v '^\s*$'  文件名     
    sed '/^\s*$/d'文件名
    sed -i '/^$/d' file.txt
    
  12. Backup and restore the mysql database test library

    备份:	mysqldump -u root -p test >备份路径
    恢复:	mysql -u root -p test <文件路径
    
  13. iptables prohibit 192.168.1.64 local access port 80
    iptables -I INPUT -s 192.168.1.64 -p TCP --dport 80 -j ACCEPT

  14. View the number of concurrent requests http
    netstat -an | grep ESTABLISHED | wc -l

  15. Find the ip most visited by Apache, the top 10
    awk '{print $1}'日志文件名 |sort |uniq -c|sort-nr|head -行数

  16. Statistics Number of files in / var / log directory
    cat /var/log|wc -l

  17. 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 }

  18. View the current available memory
    free
    df -h

  19. 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 在使用账户和密码登录
  1. Linux which support the power and resume function
    isync

Guess you like

Origin blog.csdn.net/a1749437237/article/details/108651148