Linux Common commands

Source: Internet
Author: User
Tags disk usage

1. Switch the current user to admin.

 sudo su admin  

2. View historical commands and modify them ~ /. Add export histcontrol = ignoredups to bash_profile and delete duplicate commands.

history | more
History | tail-3 // display the last three
[Admin @ v035114 ~] $ History | tail-3 1002 VI. bash_profile 1003 history | tail-4 1004 history | tail-3 [admin @ v035114 ~] $! 1002 //! 1002 run the 1,002nd command

3. View machine usage

uptime

4. Send files

scp file_name remote_host_ip:/dir/

Send file_name to the specified directory on the remote machine.

5 free view memory

free -m
             total       used       free     shared    buffers     cachedMem:          3952       3700        251          0        440       2359-/+ buffers/cache:        900       3051Swap:         8191          0       8191
 
 
-M indicates the reference http://llog.cn/article-126.html using M bytes
Then you will get such a result.
There are three rows in the displayed result:
Mem: memory usage and allocation status.
Total: indicates that the total physical memory is 879 MB.
Used: This indicates not the total memory usage, but the size of the memory allocated to the buffer and cache (you don't have to worry if this line is full ).
Free: The size of unallocated physical memory.
Shared: I have never used shared memory. I hope I can give some advice to the LZ sisters.
Buffers: indicates that the physical memory has been allocated to the buffer, but the buffer has not been used.
Cached: indicates that the physical memory has been allocated to the cache, but the cache has not been used.
Row 2-/+ buffers/cache: indicates the usage statistics of the physical memory allocated to the buffer and cache (that is, the size of 3700.
Used1 (different from used): indicates the usage of the physical memory allocated to the buffer and cache (or the above 3700. MB of buffers and cached are used.
Free1 (different from the free above): indicates the unused physical memory. This is the actual memory remaining size, that is, the amount of available memory. 3051 equals free (251) + allocated but not used buffers (440) + unused use orders (2359)
The third row swap space (not here)
What is the relationship between memory and buffer and cache in terms of values:
Total = used + free
= Used1 + free1
= Buffers + cached + used1 + free
The buffer has not been written to the disk, and the cache has been read from and saved to the disk for future use.

6 uname-a view system information

-S, -- kernel name-N, network name-R, -- kernel-release-V, -- kernel-version-M, print the machine hardware name-P, print the processor type or "unknown"-I, -- hardware-platform print the hardware platform or "unknown"-o, -- operating-system

7 DF-H disk usage. Du displays the subdirectories and directory sizes in the current directory. Run the sort command to output the results of DU.-R indicates the values in descending order.-N indicates the numbers.

[shuohai.lhl@login1.cm3 ~]$ df -hlFilesystem            Size  Used Avail Use% Mounted on/dev/sda2             3.8G  1.4G  2.3G  37% //dev/sda9             371G  245G  107G  70% /home/dev/sda8             3.8G  1.9G  1.8G  52% /var/dev/sda7             3.8G  847M  2.8G  24% /tmp/dev/sda6             3.8G  107M  3.5G   3% /opt/dev/sda5             9.5G  1.8G  7.3G  20% /usr/dev/sda1             122M   18M   98M  16% /boottmpfs                 3.9G  8.0K  3.9G   1% /dev/shm

View the file and directory size in Du

[admin@arch036086.sqa.cm4 ~]$ du -h| grep "activ"12K     ./.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.0.152K     ./.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.0.268K     ./.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.1_spec40K     ./.m2/repository/org/codehaus/plexus/plexus-active-collections/1.0-beta-244K     ./.m2/repository/org/codehaus/plexus/plexus-active-collections16K     ./.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-420K     ./.m2/repository/org/codehaus/plexus/plexus-interactivity-api84K     ./.m2/repository/javax/activation/activation/1.188K     ./.m2/repository/javax/activation/activation92K     ./.m2/repository/javax/activation

Sort sorting command

[admin@arch036086.sqa.cm4 ~]$ du -h| grep "activ" | sort -nr92K     ./.m2/repository/javax/activation88K     ./.m2/repository/javax/activation/activation84K     ./.m2/repository/javax/activation/activation/1.168K     ./.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.1_spec52K     ./.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.0.244K     ./.m2/repository/org/codehaus/plexus/plexus-active-collections40K     ./.m2/repository/org/codehaus/plexus/plexus-active-collections/1.0-beta-220K     ./.m2/repository/org/codehaus/plexus/plexus-interactivity-api16K     ./.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-412K     ./.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.0.1

8. Find the file named Fred in the current directory.

find . -name fred  
[admin@arch036088.sqa.cm4 ~]$ find . -depth -name "build"./jingwei-console/bin/build

-When searching for depth, first find the current directory document, and then find it in its subdirectory

9 who whoami: pts/0 first. In man, ptmx and PTS-pseudo do-terminal master and slave are the so-called pseudo terminal or virtual terminal, the specific manifestation is that you open a terminal, which is called pts/0. If you open another terminal, this new terminal is called pts/1.

[admin@v035114 ~]$ whoadmin    pts/2        2012-07-16 09:23 (10.13.44.57)admin    pts/3        2012-07-24 14:43 (10.13.44.36)admin    pts/4        2012-07-23 18:21 (10.13.44.57)admin    pts/6        2012-07-24 19:02 (10.13.44.67)admin    pts/7        2012-07-24 19:15 (10.13.44.57)admin    pts/9        2012-07-24 17:21 (10.13.44.36)[admin@v035114 ~]$ whoami admin

10 basename display file name and dirname display directory

[shuohai.lhl@login1.cm3 ~]$ temp=/home/shuohai.lhl/test.sh[shuohai.lhl@login1.cm3 ~]$ echo `dirname $temp`/home/shuohai.lhl[shuohai.lhl@login1.cm3 ~]$ echo `basename $temp`test.sh

11 top system load

Z color highlighted

The column highlighted by X
<> Switch the sorting Column

top - 11:46:41 up 156 days, 16:52,  2 users,  load average: 0.03, 0.05, 0.02Tasks: 134 total,   1 running, 132 sleeping,   0 stopped,   1 zombieCpu(s):  1.3%us,  0.2%sy,  0.0%ni, 98.5%id,  0.0%wa,  0.0%hi,  0.1%si,  0.0%stMem:   4046860k total,  3537732k used,   509128k free,   416172k buffersSwap:  8388600k total,      112k used,  8388488k free,  1464580k cached  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                   25795 admin     25   0 1374m 518m  10m S  5.3 13.1 146:29.76 java                       4404 admin     18   0  415m  97m  11m S  0.0  2.5  57:12.77 java                       7386 admin     20   0  753m 418m  12m S  0.0 10.6  40:42.34 java                       7521 admin     20   0  648m 402m  12m S  0.0 10.2  42:00.87 java                      10066 admin     16   0 88080 1720  992 S  0.0  0.0   0:00.00 sshd                      10067 admin     15   0 66304 1748 1200 S  0.0  0.0   0:00.01 bash                      21329 admin     15   0 12760 1128  836 R  0.0  0.0   0:05.00 top                       29745 admin     15   0 88080 1736  996 S  0.0  0.0   0:00.47 sshd                      29746 admin     15   0 66300 1716 1184 S  0.0  0.0   0:00.03 bash 

12 tar compressed and decompressed archive file-Z indicates to redirect the output to gzip-X indicates to decompress-V indicates to list the files involved in the processing-F specified files

[admin@v035114 ~]$ tar -zxvf jingwei-server-v2.1.1.tar.gz

-C indicates creating a file [admin @ v035114 ~] $ Tar-zcvf jingwei-server-2.1.1.tgz jingwei-server-2.1.1/

If Gzip is not involved, you do not need to add the-Z option.

13 redirection output redirection is represented by a greater sign, and input redirection (file flow direction command) is represented by a smaller sign,> two smaller signs represent append;

Number of lines in WC command result

[admin@v035114 shuohai]$ date > nihao ; cat nihao Sun Aug 12 10:22:23 CST 2012[admin@v035114 shuohai]$ date > nihao ; cat -n nihao     1  Sun Aug 12 10:22:32 CST 2012[admin@v035114 shuohai]$ date >> nihao ; cat -n nihao     1  Sun Aug 12 10:22:32 CST 2012     2  Sun Aug 12 10:22:52 CST 2012[admin@v035114 shuohai]$ date >> nihao ; cat -n nihao     1  Sun Aug 12 10:22:32 CST 2012     2  Sun Aug 12 10:22:52 CST 2012     3  Sun Aug 12 10:22:56 CST 2012[admin@v035114 shuohai]$ wc < nihao  3 18 87

 

 

 

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.