Linux - 信息顯示命令

  • dmesg
  • file
  • who w whoami
  • hostname uname
  • du df free

dmesg

顯示機器引導時內核顯示的狀態(tài)信息

dmesg
[    0.000000] Linux version 4.8.0-22-generic (buildd@lgw01-11) (gcc version 6.2.0 20161005 (Ubuntu 6.2.0-5ubuntu12) ) #24-Ubuntu SMP Sat Oct 8 09:15:00 UTC 2016 (Ubuntu 4.8.0-22.24-generic 4.8.0)
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.8.0-22-generic root=UUID=16516575-9911-4422-aa8c-cd183264a6f4 ro quiet splash vt.handoff=7
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000]   Centaur CentaurHauls
[    0.000000] Disabled fast string operations
[    0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[    0.000000] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[    0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
[    0.000000] x86/fpu: Using 'eager' FPU context switches.
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000dc000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000003ffebfff] usable
[    0.000000] BIOS-e820: [mem 0x000000003ffec000-0x000000003ffedfff] reserved
[    0.000000] BIOS-e820: [mem 0x000000003ffee000-0x000000003fffafff] ACPI data
[    0.000000] BIOS-e820: [mem 0x000000003fffb000-0x000000003fffffff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x00000000fd000000-0x00000000fd7fffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fed00000-0x00000000fed00fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000ffc00000-0x00000000ffffffff] reserved
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] SMBIOS 2.7 present.
[    0.000000] DMI: Parallels Software International Inc. Parallels Virtual Platform/Parallels Virtual Platform, BIOS 12.1.3 (41532) 01/18/2017
[    0.000000] Hypervisor detected: KVM
…… 后面還有很多

注:DMI Desktop Management Interface 桌面管理界面

file

顯示文件類型

shuai@ubuntu:~$ file a.txt 
a.txt: ASCII text
shuai@ubuntu:~$ file manage.py 
manage.py: Python script, ASCII text executable
shuai@ubuntu:~$ file Desktop/
Desktop/: directory

who

查看其它登錄的用戶

  • -b: 系統(tǒng)最后啟動時間
  • -a: 顯示所有信息
  • -H: 顯示項目標頭
  • -r: 查看系統(tǒng)運行等級
  • -w: 在登錄帳號后面顯示一個字符來表示用戶的信息狀態(tài):
  • +:允許寫信息;
  • -:不允許寫信息;
  • ?:不能找到終端設備。
  • -q: 統(tǒng)計當前有多少用戶登錄系統(tǒng)
shuai@ubuntu:~$ who
shuai    tty7         2017-04-19 18:22 (:0)
shuai@ubuntu:~$ who -b // 系統(tǒng)最后啟動時間
         system boot  2017-04-19 18:22
shuai@ubuntu:~$ who -a // 顯示所有信息
           system boot  2017-04-19 18:22
           run-level 5  2017-04-19 18:22
LOGIN      tty1         2017-04-19 18:22              1172 id=tty1
shuai    + tty7         2017-04-19 18:22  old         2169 (:0)
shuai@ubuntu:~$ who -H -a // 顯示項目標頭
NAME       LINE         TIME             IDLE          PID COMMENT  EXIT
           system boot  2017-04-19 18:22
           run-level 5  2017-04-19 18:22
LOGIN      tty1         2017-04-19 18:22              1172 id=tty1
shuai    + tty7         2017-04-19 18:22  old         2169 (:0)
shuai@ubuntu:~$ who -r // 系統(tǒng)運行等級(5:圖形GUI模式)
         run-level 5  2017-04-19 18:22
shuai@ubuntu:~$ who -w // 登錄帳號后面顯示一個字符來表示用戶的信息狀態(tài)(+: 允許寫)
shuai    + tty7         2017-04-19 18:22 (:0)
shuai@ubuntu:~$ who -q
shuai
# users=1

who輸出通用格式 name [state] line time [idle] [pid] [comment] [exit]

  • name用戶的登陸名
  • state寫到終端的能力
  • line在/dev中找到的行名
  • time自從用戶登陸所用的時間
  • idle自從用戶最后一次活動所經歷的時間
  • pid用戶的進程ID
  • comment注釋行
  • exit已死進程的退出狀態(tài)

Linux運行級別(run-level)

|運行級別|級別說明|
|:-:||-|
|0|系統(tǒng)停機狀態(tài),系統(tǒng)默認運行級別不能設為0,否則不能正常啟動
|1|單用戶工作狀態(tài),root權限,用于系統(tǒng)維護,禁止遠程登陸
|2|多用戶狀態(tài)(沒有NFS)
|3|完全的多用戶狀態(tài)(有NFS),登陸后進入控制臺命令行模式(系統(tǒng)默認運行級)
|4|系統(tǒng)未使用,保留
|5|X11控制臺,登陸后進入圖形GUI模式
|6|系統(tǒng)正常關閉并重啟,默認運行級別不能設為6,否則不能正常啟動

whoami

查看登錄用戶自己的信息

ShuaideMacBook-Pro:~ shuai$ su
Password:
sh-3.2# whoami
root
sh-3.2# exit
exit
ShuaideMacBook-Pro:~ shuai$ whoami
shuai

hostname

查看主機名 (根據/etc/hosts文件顯示)

shuai@ubuntu:~$ hostname
ubuntu
shuai@ubuntu:~$ hostname -i // 顯示本機IP地址
127.0.1.1

/etc/hosts文件

shuai@ubuntu:/etc$ file hosts
hosts: ASCII text
shuai@ubuntu:/etc$ cat hosts
127.0.0.1   localhost
127.0.1.1   ubuntu

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

uname

顯示系統(tǒng)信息

shuai@ubuntu:~$ uname
Linux
shuai@ubuntu:~$ uname -s // 內核名
Linux
shuai@ubuntu:~$ uname -r // 內核版本
4.8.0-22-generic
shuai@ubuntu:~$ uname -I // 硬件平臺
x86_64
shuai@ubuntu:~$ uname -p // 處理器類型
x86_64
shuai@ubuntu:~$ uname -o // 操作系統(tǒng)類型
GNU/Linux
shuai@ubuntu:~$ uname -a
Linux ubuntu 4.8.0-49-generic #52-Ubuntu SMP Thu Apr 20 09:38:39 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

du

統(tǒng)計文件大小

  • -c: 統(tǒng)計大小用K表示
  • -b: 用Byte表示
  • -s: 統(tǒng)計整個目錄所占空間
  • --max-depth=N: 顯示幾級目錄
shuai@ubuntu:~$ cat a.txt 
where
who
when who is here?
1234
shuai@ubuntu:~$ du a.txt -c // K
4   a.txt
4   total
shuai@ubuntu:~$ du a.txt -b // Bytes
33  a.txt

df

報告文件系統(tǒng)磁盤空間的使用情況

shuai@ubuntu:~$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
udev              483896         0    483896   0% /dev
tmpfs             101120     13024     88096  13% /run
/dev/sda1       64760428   4993904  56447180   9% /
tmpfs             505588       224    505364   1% /dev/shm
tmpfs               5120         4      5116   1% /run/lock
tmpfs             505588         0    505588   0% /sys/fs/cgroup
Home           243831168 180531408  63299760  75% /media/psf/Home
iCloud         243831168 180531408  63299760  75% /media/psf/iCloud
Photo Library  243831168 180531408  63299760  75% /media/psf/Photo Library
tmpfs             101116       128    100988   1% /run/user/1000
ShuaideMacBook-Pro:~ shuai$ df
Filesystem    512-blocks      Used Available Capacity iused      ifree %iused  Mounted on
/dev/disk1     487662336 360552008 126598328    75% 2146204 4292821075    0%   /
devfs                370       370         0   100%     640          0  100%   /dev
map -hosts             0         0         0   100%       0          0  100%   /net
map auto_home          0         0         0   100%       0          0  100%   /home

free

查看當前內存和交換空間的使用情況

shuai@ubuntu:~$ free
              total        used        free      shared  buff/cache   available
Mem:        1011180      607588       99500        9824      304092      243476
Swap:       1046524      305244      741280
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容