- dmesg
- file
- who w whoami
- hostname uname
- du df free
dmesg
显示机器引导时内核显示的状态信息
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: 系统最后启动时间
- -a: 显示所有信息
- -H: 显示项目标头
- -r: 查看系统运行等级
- -w: 在登录帐号后面显示一个字符来表示用户的信息状态:
- +:允许写信息;
- -:不允许写信息;
- ?:不能找到终端设备。
- -q: 统计当前有多少用户登录系统
shuai@ubuntu:~$ who
shuai tty7 2017-04-19 18:22 (:0)
shuai@ubuntu:~$ who -b // 系统最后启动时间
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 // 系统运行等级(5:图形GUI模式)
run-level 5 2017-04-19 18:22
shuai@ubuntu:~$ who -w // 登录帐号后面显示一个字符来表示用户的信息状态(+: 允许写)
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已死进程的退出状态
|运行级别|级别说明|
|:-:||-|
|0|系统停机状态,系统默认运行级别不能设为0,否则不能正常启动
|1|单用户工作状态,root权限,用于系统维护,禁止远程登陆
|2|多用户状态(没有NFS)
|3|完全的多用户状态(有NFS),登陆后进入控制台命令行模式(系统默认运行级)
|4|系统未使用,保留
|5|X11控制台,登陆后进入图形GUI模式
|6|系统正常关闭并重启,默认运行级别不能设为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
显示系统信息
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 // 操作系统类型
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
统计文件大小
- -c: 统计大小用K表示
- -b: 用Byte表示
- -s: 统计整个目录所占空间
- --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
报告文件系统磁盘空间的使用情况
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