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)平均負載。后面的分數(shù)压恒,分母表示系統(tǒng)進程總數(shù)错邦,分子表示正在運行的進程數(shù),最后一個數(shù)字表示最近運行的進程 ID撬呢。
$ cat /proc/loadavg
0.00 0.00 0.00 1/74 1248
# 讀取 CPU 核心數(shù)目
$ grep 'model name' /proc/cpuinfo | wc -l
1