Linux Practice
Coreutils - GNU core utilities
https://www.gnu.org/software/coreutils/
System context
uname: Print system information
Print all information
$ uname -a
Linux debian-512mb-sgp1-01 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2+deb8u2 (2017-06-26) x86_64 GNU/Linux
Print the kernel release
$ uname -r
3.16.0-4-amd64
Print the kernel version
$ uname -v
#1 SMP Debian 3.16.43-2+deb8u2 (2017-06-26)
hostname: Print or set system name
Get the hostname
$ hostname
mysql.example.com
$ cat /etc/hostname
mysql.example.com
Set the hostname. Note, that this is effective only until the next reboot. Edit /etc/hostname for permanent change.
$ hostname redis.example.com
$ hostname
redis.example.com
$ cat /etc/hostname
mysql.example.com
$ echo redis.example.com > /etc/hostname
$ reboot ## REBOOT!!! ##
$ hostname
redis.example.com
uptime: Print system uptime and load
uptime prints the current time, the system's uptime, the number of logged-in users and the current load average.
$ uptime
03:48:42 up 28 min, 2 users, load average: 0.00, 0.00, 0.00
# 讀取系統(tǒng)平均負(fù)載。后面的分?jǐn)?shù),分母表示系統(tǒng)進(jìn)程總數(shù),分子表示正在運(yùn)行的進(jìn)程數(shù),最后一個(gè)數(shù)字表示最近運(yùn)行的進(jìn)程 ID。
$ cat /proc/loadavg
0.00 0.00 0.00 1/74 1248
# 讀取 CPU 核心數(shù)目
$ grep 'model name' /proc/cpuinfo | wc -l
1