unix_command

基本指令 uname


更新記錄

item note
20150626 第一版

目錄


基本指令

顯示kernel版本

指令: uname -r
檔案: /proc/cmdline (load kernel information)
檔案: /proc/version
man uname

1
2
3
4
5
6
7
8
9
10
11
12
13
uname - print system information
-a, --all
print all information, in the following order, except omit -p and -i if unknown:
-s, --kernel-name
print the kernel name
-n, --nodename
print the network node hostname
-r, --kernel-release
print the kernel release
-v, --kernel-version
print the kernel version
-m, --machine
print the machine hardware name

example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
xx$ uname -a
Linux erwin-Aspire-4810T 3.16.0-41-generic #57~14.04.1-Ubuntu SMP Thu Jun 18 18:01:13 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
xx$ uname -s
Linux
xx$ uname -n
erwin-Aspire-4810T
xx$ uname -r
3.16.0-41-generic
xx$ uname -v
#57~14.04.1-Ubuntu SMP Thu Jun 18 18:01:13 UTC 2015
xx$ uname -m
x86_64

xx$ uname -r
3.16.0-41-generic
xx$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-3.16.0-41-generic root=UUID=b6a68548-4dfd-46eb-bd4c-6490c4d296cb ro quiet splash vt.handoff=7
xx$ cat /proc/version

Linux version 3.16.0-41-generic (buildd@allspice) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) 57~14.04.1-Ubuntu SMP Thu Jun 18 18:01:13 UTC 2015

顯示os版本

指令: lsb_release
檔案: /etc/lsb-release
檔案: /etc/os-release

man lsb_release

lang:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
lsb_release - print distribution-specific information
-v, --version
Show the version of the LSB against which your current installation is compliant. The version is expressed as a colon sepa‐
rated list of LSB module descriptions.
-i, --id
Display the distributor's ID.
-d, --description
Display a description of the currently installed distribution.
-r, --release
Display the release number of the currently installed distribution.
-c, --codename
Display the code name of the currently installed distribution.
-a, --all
Display all of the above information.
-s, --short
Use the short output format for any information displayed. This format omits the leading header(s).

example

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
32
33
34
35
36
37
38
xx$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.2 LTS
Release: 14.04
Codename: trusty
xx$ lsb_release -v
No LSB modules are available.
xx$ lsb_release -i
Distributor ID: Ubuntu
xx$ lsb_release -d
Description: Ubuntu 14.04.2 LTS
xx$ lsb_release -r
Release: 14.04
xx$ lsb_release -c
Codename: trusty
xx$ lsb_release -sc
trusty
xx$ lsb_release -si
Ubuntu

xx$ ls /etc/*-release
/etc/lsb-release /etc/os-release
xx$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.2 LTS"
xx$ cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04.2 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.2 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

取得使用者名稱

1
2
3
4
xx$ id -un
erwin
xx$ sudo id -un
root

參考來源