Common linux O & M commands

Source: Internet
Author: User


Common linux O & M commands in Linux O & M, recording the work bit by bit, accumulating over time and constantly improving! Routine shell operations and a collection of typical commands are shared with Linux O & M beginners! Everyone just needs to share a little bit, and we can all get a lot! 1. Search for all tar files and move them to the directory: find. -name "*. tar "-exec mv {}. /backup/; 2. Search for I in 'Find. -name *. html | sed's /. // G' | sed's/html /. html/g''; do echo http: // 192.168.0.170: 8017 $ I; done www.2cto.com 3. Remove the first line. character: find. -name *. html | sed's/^. // g'4. find the file type and back up it to another directory: find. -name nginx. conf. tgz-exec cp {} dir/; 5. Monitor linux disk partitions. If the disk space exceeds 90%, send an email to Linux SA (1), print the root partition size df-h | sed-n' // $/P' | awk '{print $5}' | awk-F "%" '{p Rint $1} '(2). The if condition determines whether the size is greater than 90, if it is greater than 90, send an email alert while sleep 5 mdofor I in 'df-h | sed-n' // $/P' | awk '{print $5}' | sed' s/% // g'' doecho $ iif [$ I-gt 90]; thenecho "More than 90% Linux of disk space, Please Linux SA Check Linux Disk!" | Mail-s "Warn Linux/Parts is $ I %" wugk@map.com www.2cto.com fidonedone6, statistics apache access logs, traffic ranked first 20 IP Address: cat access. log | awk '{print $1}' | sort | uniq-c | sort-nr | head-20
7. Add http://img.map.com before all rows and add/sed-e's/^/http://img.map.com/maplite/map/subway/1.1/'-e's/$ // 'a.txt 8. Find the current row, then, modify the parameters after the row: sed-I '/SELINUX/s/disabled/enforcing/'/etc/selinux/config9, find and modify the names of all folders in the directory: find. -name "NaviInfo.2010.12.0" | xargs rename NaviInfo.2010.12.0 NaviInfo.2010.12.110, view the number of concurrent apache connections, and related forwarding status: netstat-n | awk '/^ tcp/' | awk '{print $ NF}' | sort | uniq-c | sort-nrnetstat-n | awk '/^ Tcp/{++ S [$ NF]} END {for (a in S) print, S [a]} 'www.2cto.com 11. Print the maximum and minimum values in a file: cat a.txt | sort-nr | awk '{} END {print} NR = 1' cat a.txt | sort-nr | awk 'end {print} NR = 1' true Print maximum and minimum values: sed's // G' a.txt | sort-nr | sed-n' 1p; $ P' 12. Use snmpd to capture cacti data of version v2: snmpwalk-v2c-c public 192.168.0.24113. In the modification text, replace the ending value of jk with yz: sed-e's/jk $/yz/G' B .txt 14. Capture packets over the network: tcpdumptcpdump-nn host 192.168.56.7 and port 80 capture 56.7 data packets that pass 80 requests. Tcpdump-nn host 192.168.56.7 or! Host 192.168.0.22 and port 80 exclude port 0.22 80! TCP/IP Layer 7 protocol physical layer-data link layer-network layer-Transport Layer-Session Layer-presentation layer-application layer. 15. Configure the group name for H3C: first set the snmp version as follows: snmp-agent sys-info version v1 v2c, and then set the Group Name: snmp-agent community read public www.2cto.com 16. display the most common 20 commands: cat. bash_history | grep-v ^ # | awk '{print $1}' | sort | uniq-c | sort-nr | head-20 17. Write a script to find the last creation time 3 days ago, the suffix is *. log File and delete it. Find.-mtime + 3-name "*. log" | xargs rm-rf {}; 18. Write a script to move files larger than kb in a directory to/tmp. Find.-size + 100 k-exec mv {}/tmp; 19. Write a firewall configuration script that only allows remote hosts to access port 80 of the local machine. Iptables-Fiptables-Xiptables-a input-p tcp -- dport 80-j acceptiptables-a input-p tcp-j REJECT or iptables-a input-m state -- state NEW-m tcp -p tcp -- dport 80-j ACCEPT www.2cto.com 20. Write a script to perform nginx log statistics, obtain the first 10 most ip addresses (nginx Log Path:/home/logs/nginx/default/access. log ). Cd/home/logs. nginx/defaultsort-m-k 4-o access. logok access.1 access.2 access.3 ..... cat access. logok | awk '{print $1}' | sort-n | uniq-c | sort-nr | head-10 21. write the meanings of the following commands (1) MaxKeepAliveRequests 100 maximum number of requests connected (2) Options FollowSymLinks Allow 192.168.1.1 to list directories Order Deny Allow Deny from all Allow from 192.168.1.122. replace the directory sed's:/user/local:/tmp: g'test.txt www.2cto.com or sed-I's // usr/local // tmp/G' test.txt author rabbit bug

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.