命令行学习笔记(系统信息相关)

  • date -- 显示当前时间
  • cal -- 显示当月日历
  • uptime -- 显示主机运行时间和系统负载信息。uptime命令信息显示依次为:现在时间、系统已经运行了多长时间、目前有多少登陆用户、系统在过去的1分钟、5分钟和15分钟内的平均负载。

效果如下:

➜  anyang date
2016年 12月 07日 星期三 20:52:37 CST
➜  anyang cal
      十二月 2016        
日 一 二 三 四 五 六  
             1  2  3  
 4  5  6  7  8  9 10  
11 12 13 14 15 16 17  
18 19 20 21 22 23 24  
25 26 27 28 29 30 31
➜  anyang uptime
 20:53:48 up 11:21,  1 user,  load average: 0.37, 0.28, 0.16
  • w -- 显示目前登入系统的用户,以及他们正在执行的程序
  • whoami -- 显示用户名称
  • uname -- 显示当前操作系统名称

效果如下:

➜  anyang w
 21:01:19 up 11:28,  1 user,  load average: 0.20, 0.42, 0.28
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
anyang   tty7     :0               09:33   11:28m 21:58  52.20s /sbin/upstart -
➜  anyang whoami
anyang
➜  anyang uname
Linux
  • cat /proc/cpuinfo -- 查看cpu信息
  • cat /proc/meminfo -- 查看内存信息
  • free -- 显示当前内存使用情况

效果如下:

➜  anyang cat /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 42
model name  : Intel(R) Core(TM) i3-2330M CPU @ 2.20GHz
stepping    : 7
microcode   : 0x29
cpu MHz     : 1096.508
cache size  : 3072 KB
➜  anyang cat /proc/meminfo
MemTotal:        3936712 kB
MemFree:         1280328 kB
MemAvailable:    2265304 kB
Buffers:          144236 kB
Cached:          1151004 kB
SwapCached:            0 kB
Active:          1655316 kB
Inactive:         742064 kB
Active(anon):     992800 kB
Inactive(anon):   272348 kB
Active(file):     662516 kB
Inactive(file):   469716 kB
Unevictable:          32 kB
Mlocked:              32 kB
SwapTotal:       4084732 kB
SwapFree:        4084732 kB
Dirty:               184 kB
➜  anyang free
              total        used        free      shared  buff/cache   available
Mem:        3936712     1186652     1320432      173300     1429628     2314612
Swap:       4084732           0     4084732
  • man command -- 显示命令使用手册
  • df -- 显示磁盘文件的可用空间
  • du -- 显示当前工作目录与其所有子目录的使用情况
  • du -sh -- 以可读方式(GB)显示工作目录所占总空间

效果如下:

➜  anyang df
Filesystem     1K-blocks    Used Available Use% Mounted on
udev             1946640       0   1946640   0% /dev
tmpfs             393672   31116    362556   8% /run
/dev/sda9       68215120 8197808  56509140  13% /
tmpfs            1968356    5784   1962572   1% /dev/shm
tmpfs               5120       4      5116   1% /run/lock
tmpfs            1968356       0   1968356   0% /sys/fs/cgroup
tmpfs             393668     104    393564   1% /run/user/1000
➜  anyang du
4   ./test
8   ./learngit/.git/info
4   ./learngit/.git/branches
8   ./learngit/.git/logs/refs/heads
12  ./learngit/.git/logs/refs
24  ./learngit/.git/logs
44  ./learngit/.git/hooks
8   ./learngit/.git/objects/81
8   ./learngit/.git/objects/d9
8   ./learngit/.git/objects/e6
4   ./learngit/.git/objects/info
8   ./learngit/.git/objects/25
8   ./learngit/.git/objects/2d
8   ./learngit/.git/objects/72
8   ./learngit/.git/objects/16
8   ./learngit/.git/objects/af
4   ./learngit/.git/objects/pack
8   ./learngit/.git/objects/63
8   ./learngit/.git/objects/02
8   ./learngit/.git/objects/12
8   ./learngit/.git/objects/51
8   ./learngit/.git/objects/2c
8   ./learngit/.git/objects/2f
8   ./learngit/.git/objects/8e
8   ./learngit/.git/objects/44
8   ./learngit/.git/objects/ae
12  ./learngit/.git/objects/13
12  ./learngit/.git/objects/e9
8   ./learngit/.git/objects/a5
8   ./learngit/.git/objects/5f
8   ./learngit/.git/objects/eb
8   ./learngit/.git/objects/9a
8   ./learngit/.git/objects/89
8   ./learngit/.git/objects/7b
8   ./learngit/.git/objects/f5
8   ./learngit/.git/objects/f9
236 ./learngit/.git/objects
8   ./learngit/.git/refs/heads
4   ./learngit/.git/refs/tags
16  ./learngit/.git/refs
360 ./learngit/.git
368 ./learngit
3752    .
➜  anyang du -sh
3.7M    .
  • whereis command -- 显示指令的位置
  • which command -- 搜索某个系统命令的位置,并且返回第一个搜索结果,即默认执行的命令位置

效果如下:

➜  anyang whereis grep
grep: /bin/grep /usr/share/man/man1/grep.1.gz /usr/share/info/grep.info.gz
➜  anyang which grep
grep: aliased to grep  --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}

相关资料:

  1. 29个你必须知道的Linux命令: http://www.imooc.com/article/1285
  2. 常用命令行介绍: https://github.com/iamcoach/console/blob/master/COMMANDS.md
  3. 常用命令行cheet sheet: https://bbs.excellence-girls.org/topic/167
  4. 书籍《鸟哥的Linux私房菜》: https://book.douban.com/subject/4889838/
  5. Ubuntu各种技巧:http://wiki.ubuntu.org.cn/UbuntuSkills

你可能感兴趣的:(命令行学习笔记(系统信息相关))