当前位置:首页 > 开发 > 操作系统 > 正文

Linux: Frequently used command

发表于: 2014-11-03   作者:DavyJones2010   来源:转载   浏览次数:
摘要: 1. List disk space usage: df -hl // "l" means "local", limit listing to local file systems // "h" means "human-readable", print sizes in human readable forma

1. List disk space usage:

df -hl
// "l" means "local", limit listing to local file systems
// "h" means "human-readable", print sizes in human readable format
 du -cks *|sort -rn|head
// recurisive sort file size under current folder

2. Sort file by size:

ls -hlS
// "h": "human-readable", print sizes in human readable format
// "l" : use a long listing format
// "S": sort by file size
// "t" : sort by modification date
// "r" : reverse order while sorting
// "s" : size, with "-l" print size of each file, in blocks

// For file, the output is the size of the file.
// For directory, the output is fixed 4.0K.

3. Delete file by size:

find . -size +10240k -exec rm -rf {} \;

4. Delete file by date:

find . -mtime +5 -exec rm -rf {} \;

5. Overview of CPU, I/O, Memory:

> vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 778576 337756 3527900    0    0     1    21    0    0  1  0 98  1  0

// Processes:
//  r: The number of processes waiting for runtime.
// b: The number of processes in uninterruptible sleep.
// Memory:
// swpd: The amount of virtual memory used.
// free  : The amount of idle memory
// buff  : The amount of memory used as buffers.
// cache: the amout of memory used as cache.
// Disk/Memory Swap:
// si: Amount of memory swapped from disk.
// so: Amount of memory swapped to disk.
// I/O:
// bi: Blocks received from a block device
// bo: Blocks sent to a block device
// System:
// in: The number of interrupts per second, including the clock
// cs: The number of context switches per second
// CPU:
// us: Time spent runnning non-kernel code. (user time)
// sy: Time spent running kernel code. (system time)
// id: Time spent idel.
// wa: Time spent waiting for IO
// st: Time stolen from a virtual machine.

6. Brief overview of system load average

>uptime
03:33:32 up 271 days,  9:44,  1 user,  load average: 0.93, 1.06, 0.99
// 0.93 is the load average for last 1 minute
// 1.06 is the load average for last 5 minutes
// 0.99 is the load average for last 15 minutes
// Command above should usually used combine with command below:

> grep 'model name' /proc/cpuinfo
model name      : Intel(R) Xeon(R) CPU           X5650  @ 2.67GHz
model name      : Intel(R) Xeon(R) CPU           X5650  @ 2.67GHz
// Means our system are 2-core machine.

7. Real time CPU/Memory/Load Average usage monitor:

> top
top - 03:58:40 up 151 days, 18:50,  4 users,  load average: 0.78, 0.67, 0.28
Tasks: 157 total,   1 running, 156 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.1%sy,  0.0%ni, 99.0%id,  0.8%wa,  0.0%hi,  0.1%si,  0.0%st
Mem:   8174448k total,  4369796k used,  3804652k free,   138580k buffers
Swap:        0k total,        0k used,        0k free,  1491884k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                         
16267 rcastdev  15   0 10888 1104  800 R  0.3  0.0   0:00.01 top                                                             
16769 root      15   0     0    0    0 S  0.3  0.0   0:06.31 pdflush

8. Network statistical info:

> netstat -s
> netstat -pt
// -p: show PID which possess the port number
// t: show TCP protocol only
Proto Recv-Q Send-Q Local Address               Foreign Address             State PID  
tcp    0          0          ***.***:23010            ***.***:43333 ESTABLISHED  123

9. Memory statistical  info:

> free
             total       used       free     shared    buffers     cached
Mem:       8174448    4369228    3805220          0     138664    1492784
-/+ buffers/cache:    2737780    5436668
Swap:            0          0          0

10. SCP:

// SCP local file to remote:
scp {local-file} {username}@{remote-machine}:{remote-dir}
// SCP remote file to local:
scp {username}@{remote-machine}:{remote-file} {local-dir}

 

 

 

 

Reference Links:

1> Load average: http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages

2> SCP: http://www.hypexr.org/linux_scp_help.php

 

Linux: Frequently used command

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
Linux命令学了忘、忘了学,干脆整理一下放在这里。 一、文件权限 chgrp [-R] dirname/filename ...
【screen command of linux】   常用键:      补充:   Ctrl-a S # split terminal vertical
linux系统允许多个用户同时使用系统,并且可以同时执行不同的任务。为了确保各个用户的文件安全, l
原创文章,转载请注明: 转载自系统技术非业余研究 本文链接地址: Linux Used内存到底哪里去了? 前
原创文章,转载请注明: 转载自系统技术非业余研究 本文链接地址: Linux Used内存到底哪里去了? 前
前几天 纯上 同学问了一个问题: 我ps aux看到的RSS内存只有不到30M,但是free看到内存却已经使用了
原创文章,转载请注明: 转载自 非业余研究 本文链接地址: Linux Used内存到底哪里去了? 前几天 纯
1) Command Name: cat Command Derived From: concatenate and display files Command Path: /bin/c
User Management Related Commands 1) User management config file 1) User info config file: /et
http://www.tecmint.com/12-top-command-examples-in-linux/ [原文地址:http://os.51cto.com/art/2
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号