Linux and O & M

Source: Internet
Author: User

From: http://my.benorz.org/index.php/more/135/zh-cn

============= Certificate generation ======
Keytool-genkey-alias tomcat-keyalg RSA-keypass changeit-storepass changeit-keystore Ben. keystore-validity 3600

==================================== Commonly used commands ================== ==============
Netstat-N | awk '/^ TCP/{++ s [$ NF]} end {for (a in S) print a, s [a]}'
Status: Description
Closed: No connection is active or in progress
Listen: the server is waiting for incoming call
Syn_recv: a connection request has arrived, waiting for confirmation
Syn_sent: The application has started. Open a connection.
Established: normal data transmission status
Fin_wait1: The application says it has been completed
Fin_wait2: the other side has agreed to release
Itmed_wait: wait until all groups die
Closing: both sides attempt to close at the same time
Time_wait: the other side has initialized a release.
Last_ack: waiting for all groups to die

DDoS Attack
You can use this command to find out which IP Address has the most connections and seal it.

Netstat-na | grep ESTABLISHED | awk '{print $5}' | awk-F: '{print $1}' | sort | uniq-c | sort-r + 0n
Netstat-na | grep SYN | awk '{print $5}' | awk-F: '{print $1}' | sort | uniq-c | sort-r + 0n
Cat file | grep google | awk '/Googlebot/{print $1}' | sort | uniq | sort-rn

Netstat-n | awk '/^ tcp/{print substr ($5, 0, (index ($5, ":")-1 )), $ NF} '| sort-r | uniq-c | sort-rn | head-n 5
[Root @ mth01 logs] # cat *. log | awk '/GET/{++ N [$1]} END {for (I in N) {print N, I} '| sort-rn | head-n8

================= JVM memory optimization ==========
-Xmn256M-Xms1024M-Xmx1024M-XX: MaxNewSize = 512 m-XX: MaxPermSize = 512m"

Incremental Backup
Rsync-v-a-z-e ssh-delete/opt/virtual/192.168.3.1:/bakhome/virtual
Rsync-v-a-z-e ssh-delete/opt/mthpic/192.168.3.1:/bakhome/mthpic
====================================

--- What serial number is missing, as if it was from server 2003 -----
EnterPrise: YCFX3-376TJ-KD224-Y9B8J-7XDQK
Standard: 738XF-4MBKQ-9GRM6-4MVVH-PVJ6Q
Web: GH9QJ-FY3VX-VCD6X-3T2VV-3G9QV
Datacenter: YWD28-W67QX-F22JD-3JJJ6-7H8R3

Windows XP Professional Edition (This number is genuine and can be used ):
MRX3F-47B9T-2487J-KWKMF-RPWBY

Time Server
Cn.pool.ntp.org
======= Cache cleanup (only supported for 32-bit Systems) ==================
Compile:
Reference blog.s135.com
Wget http://www.wa.apana.org.au /~ Dean/sources/purge-20040201-src.tar.gz
Tar zxvf purge-20040201-src.tar.gz
Cd purge
Make

Example of clearing the Squid cache:
1. Clear the cached files whose URLs end with "deleted objects ".
Reference
Purge-p pic.benorz.org: 80-P 1-se '\. jpg $'
Purge-p pic.benorz.org: 80-P 1-se '\. gif $'
Purge-p html.benorz.org: 80-P 1-se '\. swf $'
Purge-p html.benorz.org: 80-P 1-se '\. html $'
Purge-p html.benorz.org: 80-P 1-se 'benorz. org'
2. Clear all caches whose URLs contain benorz.org:
Reference
./Purge-p localhost: 80-P 1-se 'benorz. org'

I like to push the program to the background for execution, so that it can slowly clear the Squid cache and record the output content to the purge. log file:
Reference
./Purge-p localhost: 80-P 1-se 'benorz. org '> purge. log 2> & 1 &
========================================================== ========================================================== ================
Linux tips

/* Update every day */
/* Starting from today, I will give you a tip every day to learn more about LINUX! */
/* Mainly commands, system management, and tips */

1. Process sorting by memory from large to small:
Ps-eo "% C: % p: % z: % a" | sort-k5-nr

2. Check which processes are currently running; view the files opened by the process:
Ps-A; lsof-p PID

3. Get the current IP address (learn the role of grep, awk, and cut)
Ifconfig eth0 | grep "inet addr:" | awk '{print $2}' | cut-c 6-

4. Count the frequency of each word and sort it.
Awk '{arr [$1] + = 1} end {for (I in ARR) {print arr "\ t" I}' file name | sort-Rn

5. Display 10 of the most common commands
Sed-E "S/|/\ n/g "~ /. Bash_history | cut-D ''-F 1 | sort | uniq-c | sort-Nr | HEAD

6. Killing nginx processes (killing a process)
PS-Ef | grep-V grep | grep nginx | awk '{print $2}' or
For I in 'ps aux | grep nginx | grep-V grep | awk {'print $2 '}'; do kill $ I; done

7. List the directory size of the current folder, which is displayed in G, M, and K.
Du-B-max-depth 1 | sort-Nr | Perl-PE's {([0-9] +)} {sprintf "%. 1f % s ", $1> = 2 ** 30? ($1/2 ** 30, "G"): $1> = 2 ** 20? ($1/2 ** 20, "M"): $1> = 2 ** 10? ($1/2 ** 10, "K"): ($1, "")} E'

8. Clear Linux buffer cache
Sync & Echo 3>/proc/sys/Vm/drop_caches

9. Convert all file names in the current directory to lowercase letters.
For I in *; Do MV "$ I" "$ (echo $ I | tr A-Z A-z)"; done

10. Several methods to eliminate ^ m in VIM
1) dos2unformatted filename
2) sed-e's/^ M // 'filename
3) in vim: s/^ M // gc
4) col-bx newfile
5) tr-s "\ r \ n" "\ n" newfile

11. Clear all arp caches
Arp-n | awk '/^ [1-9]/{print "arp-d" $1}' | sh

12. Bind the arp Address of a known Machine
Cat/proc/net/arp | awk '{print $1 "$4}' | sort-t.-n + 3-4>/etc/ethers

========================== Oracle operation steps ========================== =
Su oracle

Source/home/oracle/. bash_profile

Cd/opt/oracle/p */10.2/bin

Lsnrctl start

Sqlplus/as sysdba

SQL> startup

================================

SQL> exit stop: $ sqlplus

Enter user-name:/as sysdba
SQL> shutdown immediate
SQL> exit

List Oracle processes: $ ps a € "fuoracle
Create or replace directory dump_dir as '/home/oracle/dump'
Impdp system/123456 dumpfile = gh_080822.dmp DIRECTORY = dump_dir
Impdp system/123456 dumpfile = mth20081014.dmp DIRECTORY = dump_dir
Impdp system/123456 dumpfile = mth. dmp DIRECTORY = dump_dir
Impdp mth/mth dumpfile = MTH_PROP_JOURNAL % U. dmp DIRECTORY = dump_dir
Impdp system/123456 dumpfile = gh_080822.dmp CONTENT = METADATA_ONLY DIRECTORY = dump_dir
Drop user xxxx cascade;
Log On With sys: connect as/sysdba;
Unlock scott: alter user scott account unlock;
========================== Modify 2003 default remote terminal port ============================== ===
1. Change PortNumber = 3389 under HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Terminal Server \ Wds \ rdpwd \ Tds \ tcp to the port number of the custom port.
2. Change PortNumber = 3389 in HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Terminal Server \ WinStations \ RDP-Tcp to the custom port number.
==========================================
Basic usage
* Obtain squid running status information: squidclient-p 80 mgr: info
* Obtain squid memory usage: squidclient-p 80 mgr: mem
* Obtain the squid cached list: squidclient-p 80 mgr: objects. use it carefully, it may crash
* Obtain squid disk usage: squidclient-p 80 mgr: diskd
* Force update a url: squidclient-p 80-m PURGE http://www.php-oa.com/static.php
* For more information, see squidclient-h or squidclient-p 80 mgr:

* How do I know the status of squid execution?
The simplest way is to observe through a browser. Squid itself provides a cgi program named cachemgr. cgi. After installing squid, copy it to the cgi-bin directory under Apache.
To view information provided by Cache Manager, Type
Http: // server name or IP address/cgi-bin/cachemgr. cgi
Of course, I prefer the following method.
Squidclient-t 1-h localhost-p 80 mgr: inf.
[Root @ MTH93 squid] # bin/squidclient-h BEN-p 80 mgr:
HTTP/1.0 200 OK
Server: squid/BRL. stable21-20080721
Date: Thu, 23 Oct 2008 04:49:14 GMT
Content-Type: text/plain
Expires: Thu, 23 Oct 2008 04:49:14 GMT
Last-modified: Thu, 23 Oct 2008 04:49:14 GMT
X-Cache: Miss from pic.benorz.org
Via: 1.0 pic.benorz.org: 80 (squid/2.6.stable21-20080721)
Connection: Close

Mem memory utilization public
Cbdata callback data registry contents public
Events event queue public
Squidaio_counts async Io function counters public
Coss stats public
Diskd stats public
Config current squid configuration hidden
Ipcache IP cache stats and contents public
Fqdncache FQDN cache stats and contents public
DNS dnsserver statistics public
External_acl external ACL stats public
Http_headers HTTP header statistics public
Menu This Cachemanager Menu public
Shutdown Shut Down the Squid Process hidden
Offline_toggle Toggle offline_mode setting hidden
Info General Runtime Information public
Filedescriptors Process Filedescriptor Allocation public
Objects All Cache Objects public
Vm_objects In-Memory and In-Transit Objects public
Openfd_objects Objects with Swapout files open public
Pending_objects Objects being retreived from the network public
Client_objects Objects being sent to clients public
Io Server-side network read () size histograms public
Counters Traffic and Resource Counters public
Peer_select Peer Selection Algorithms public
Digest_stats Cache Digest and ICP blob public
5 min 5 Minute Average of Counters public
60 min 60 Minute Average of Counters public
Utilization Cache Utilization public
Histograms Full Histogram Counts public
Active_requests Client-side Active Requests public
Storedir Store Directory Stats public
Store_check_cachable_stats storeCheckCachable () Stats public
Store_io Store IO Interface Stats public
Pconn Persistent Connection Utilization Histograms public
Refresh Refresh Algorithm Statistics public
Delay Delay Pool Levels public
Forward Request Forwarding Statistics public
Client_list Cache Client List public
Asndb AS Number Database public
Server_list Peer Cache Statistics public

Export JAVA_HOME =/usr/java/jdk1.6.0 _ 12/
Export PATH = $ JAVA_HOME/bin/: $ PATH
Export CLASSPATH = $ JAVA_HOME/lib :.

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.