Linux utility system management command review

Source: Internet
Author: User
Linux practical system management command review-Linux general technology-Linux technology and application information, the following is a detailed description. 1.
Free-m # view memory usage
Free-m-t # view memory usage and statistics
Free-n-t-s 2 # view memory usage and statistics, refresh every two seconds
2.
Vmstat-s # view memory usage
3.
Top # view the CPU ranking of processes
Top-d 1 # refresh once every second
Press 1 after the top entry to view the execution status of each cpu.
Press "f", "j", and "space" after the top entry to view the CPU on which the process is executed.
Press W (uppercase) to save the TOP settings.
4.
Ps-ef # view the complete process information
Ps-eLf # If each process does not display its threads, the L parameter can display each thread
Ps-eo ppid, pid, user, args, % mem, vsz, rss -- sort rss # display process name, memory usage, virtual memory, physical memory, and sort by physical memory usage
Ps-eo ppid, pid, user, args, % mem, vsz, rss -- sort vsz # display process name, memory usage, virtual memory, physical memory, and sort by virtual memory usage
(The use of virtual memory and physical memory is likely to produce a large number of fragments)
5.
Iostat-p 2 # displays the IO of each partition and refreshes every 2 seconds.

1. view memory information in ps
RSS-memory usage of processes
VSZ -- calculate the total usage of shared libraries
Ps-eo pid, user, comm, args, % cpu, % mem, rss, vsz, sz
View memory and CPU
Ps-fewL | grep face_svr
Ps-fp $ (pgrep-d, face_svr)

Top c
Total virtual memory used by VIRT, VIRT = SWAP + RES
Physical memory used by RES, Not swapped out, RES = CODE + DATA
SWAP size in the virtual memory used by SWAP
SHR shared memory size
Physical memory occupied by CODE executable CODE
Physical memory size occupied by parts other than the DATA executable code (DATA Segment + stack)
% MEM percentage of physical memory used, = RES/total memory size

2. view the information of the specified process name
Ps-fp $ (pgrep-d,-fx./httpd)

3. accurately calculate the number of processes
Proc_num = $ (pgrep-x $ proc | wc-l)

4. Database Operations
Mysqldump group_filter-uroot-proot @ 105 -- default-character-set = latin1 -- extended-insert = false
Mysql-uroot-e "select fpath, lloccode into outfile '/data/dump_data/mongodb_idx.mongot.txt' from picdata _ $ db_idx.album_photolist _ $ t where lloccode like '^ % ';"

Unix time Conversion
Select now ();
Select from_unixtime (1238373217 );
Select unix_timestamp ('2017-03-30 08:33:37 ')


5. exclude Compression
----- Do not add the final/to the subdirectory/
Tar -- exclude = qhttpd/log-cfvz qhttpd. tgz qhttpd (error)
Tar -- exclude = log-cfvz qhttpd. tgz qhttpd)



6. Modify the maximum shared memory size from the startup.
Sysctl-w kernel. shmmax = 4294967295

7. Added www users
# Useradd-s/bin/false-d/dev/null www
Useradd-s/bin/false www
Groupadd www

8. Local IP Address
LOCALHOST = 'ifconfig | grep eth1-A1 | sed-n '2p' | awk-F ": "'{print $2}' | awk-F" "'{print $1 }''
Cat ifcfg-eth0 | grep IP | awk-F \ ''{printf $2" \ n "}'

9. Common lsof usage:

Lsof abc.txt displays the process of opening the abc.txt File
Lsof-I: 22. Know what programs are running on port 22.
Lsof-c abc displays the files currently opened by the abc process
Lsof-g gid: displays the processes that belong to the gid.
Lsof + d/usr/local/display files opened by processes in the directory
Lsof + D/usr/local /.
Lsof-d 4 displays processes with fd 4
Lsof-I is used to display qualified Processes

10. view the location of Common commands
Which mysql or whereis mysql

11. vmstat
Procs
R -- wait for running in the running queue. Displays the number of tasks being executed and waiting for CPU resources. When this value exceeds the number of CPUs, a CPU bottleneck will occur.
B -- blocked by resources (I/0, page scheduling, etc .)
W -- runable but replaced

Cpu indicates the cpu usage status
Cs -- time used by the user process
Sy -- time used by the system process
Id -- cpu idle time
Related Article

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.