lsmod

显示已载入系统的模块

补充说明

lsmod命令 用于显示已经加载到内核中的模块的状态信息。执行lsmod命令后会列出所有已载入系统的模块。Linux操作系统的核心具有模块化的特性,应此在编译核心时,务须把全部的功能都放入核心。您可以将这些功能编译成一个个单独的模块,待需要时再分别载入。

语法

1
lsmod

实例

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
[root@LinServ-1 ~]# lsmod
Module Size Used by
ipv6 272801 15
xfrm_nalgo 13381 1 ipv6
crypto_api 12609 1 xfrm_nalgo
ip_conntrack_ftp 11569 0
xt_limit 6721 2
xt_state 6209 2
ip_conntrack 53665 2 ip_conntrack_ftp,xt_state
nfnetlink 10713 1 ip_conntrack
xt_tcpudp 7105 6
xt_multiport 7233 1
iptable_filter 7105 1
ip_tables 17029 1 iptable_filter
x_tables 17349 5 xt_limit,xt_state,xt_tcpudp,xt_multiport,ip_tables
dm_mirror 24393 0
dm_multipath 27213 0
scsi_dh 12481 1 dm_multipath
video 21193 0
backlight 10049 1 video
sbs 18533 0
power_meter 16461 0
hwmon 7365 1 power_meter
i2c_ec 9025 1 sbs
dell_wmi 8401 0
wmi 12137 1 dell_wmi
button 10705 0
battery 13637 0
asus_acpi 19289 0
ac 9157 0
lp 15849 0
snd_hda_intel 401453 0
snd_seq_dummy 7877 0
snd_seq_oss 32577 0
snd_seq_midi_event 11073 1 snd_seq_oss
snd_seq 49585 5 snd_seq_dummy,snd_seq_oss,snd_seq_midi_event
snd_seq_device 11725 3 snd_seq_dummy,snd_seq_oss,snd_seq
snd_pcm_oss 42817 0
snd_mixer_oss 19009 1 snd_pcm_oss
snd_pcm 72517 2 snd_hda_intel,snd_pcm_oss
ide_cd 40161 0
snd_timer 24517 2 snd_seq,snd_pcm
tpm_tis 16713 0
r8169 43077 0
snd_page_alloc 14281 2 snd_hda_intel,snd_pcm
tpm 19041 1 tpm_tis
i2c_i801 12737 0
mii 9409 1 r8169
serio_raw 10693 0
i2c_core 24897 2 i2c_ec,i2c_i801
snd_hwdep 12869 1 snd_hda_intel
tpm_bios 11073 1 tpm
cdrom 36577 1 ide_cd
pcspkr 7105 0
parport_pc 29669 1
sg 36973 0
snd 57797 9 snd_hda_intel,snd_seq_oss,snd_seq,snd_seq_device,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_timer,snd_hwdep
parport 37513 2 lp,parport_pc
soundcore 11553 1 snd
dm_raid45 67273 0
dm_message 6977 1 dm_raid45
dm_region_hash 15681 1 dm_raid45
dm_log 14785 3 dm_mirror,dm_raid45,dm_region_hash
dm_mod 63993 4 dm_mirror,dm_multipath,dm_raid45,dm_log
dm_mem_cache 9537 1 dm_raid45
ata_piix 23749 4
libata 158085 1 ata_piix
sd_mod 25409 6
scsi_mod 144277 4 scsi_dh,sg,libata,sd_mod
ext3 126281 3
jbd 57705 1 ext3
uhci_hcd 25421 0
ohci_hcd 24937 0
ehci_hcd 34509 0
  • 第1列:表示模块的名称。
  • 第2列:表示模块的大小。
  • 第3列:表示依赖模块的个数。
  • 第4列:表示依赖模块的内容。

通常在使用lsmod命令时,都会采用类似lsmod | grep -i ext3这样的命令来查询当前系统是否加载了某些模块。

lscpu

显示有关CPU架构的信息

补充说明

lscpu命令 是显示有关CPU架构的信息。

语法

1
lscpu [选项]

选项

1
2
3
4
5
6
7
8
9
10
-a, --all               打印在线和离线CPU(默认为-e)
-b, --online 仅打印在线CPU(-p的默认值)
-c, --offline 打印离线CPU
-e, --extended[=<list>] 打印出一个扩展的可读格式
-p, --parse[=<list>] 打印出可解析的格式
-s, --sysroot <dir> 将指定的目录用作系统根目录
-x, --hex 打印十六进制掩码,而不是CPU列表

-h, --help 显示此帮助并退出
-V, --version 输出版本信息并退出

参数

1
2
3
4
5
6
7
8
9
10
11
可用列:
CPU 逻辑CPU编号
CORE 逻辑核心号码
SOCKET 逻辑套接字号
NODE 逻辑NUMA节点号
BOOK 逻辑书号
CACHE 显示了如何在CPU之间共享高速缓存
POLARIZATION 虚拟硬件上的CPU调度模式
ADDRESS CPU的物理地址
CONFIGURED 显示管理程序是否分配了CPU
ONLINE 显示Linux是否正在使用CPU

例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@localhost ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 30
Model name: Intel(R) Xeon(R) CPU X3430 @ 2.40GHz
Stepping: 5
CPU MHz: 2394.055
BogoMIPS: 4788.11
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 8192K
NUMA node0 CPU(s): 0-3

lsb_release

显示发行版本信息

补充说明

LSB是Linux Standard Base的缩写, lsb_release命令 用来显示LSB和特定版本的相关信息。如果使用该命令时不带参数,则默认加上-v参数。

1
2
3
4
5
6
7
-v 显示版本信息。
-i 显示发行版的id。
-d 显示该发行版的描述信息。
-r 显示当前系统是发行版的具体版本号。
-c 发行版代号。
-a 显示上面的所有信息。
-h 显示帮助信息。

如果当前发行版是LSB兼容的,那么/etc/lsb_release文件中会包含LSB_VERSION域。这个域的值可以是用冒号隔开的一系列支持的模块。这些模块名是当前版本支持的LSB的模块名。如果当前版本不是LSB兼容的,就不要包含这个域。

可选的域包括DISTRIB_ID, DISTRIB_RELEASE, DISTRIB_CODENAME,DISTRIB_DESCRIPTION,它们可以覆盖/etc/distrib-release文件中的内容。注:这里的distrib要替换为当前的发行版的名字。如果存在/etc/lsb-release.d目录,会在该目录中查找文件名并作为附加的模块版本加在LSB_VERSION前面。文件/etc/distrib-release中包含了一些描述信息,用来说明应该分析哪些文件名。

一般的格式是Distributor release x.x (Codename) 注意:Debian系统中缺乏相应的描述信息(见/etc/debian-version),为了支持Debian系统,大部分信息都被加在了lsb-release文件中。

redhat和fedora系统中,还支持一个参数:

1
-s, --short  输出简短的描述信息。

lsblk

列出块设备信息

补充说明

lsblk命令 用于列出所有可用块设备的信息,而且还能显示他们之间的依赖关系,但是它不会列出RAM盘的信息。块设备有硬盘,闪存盘,cd-ROM等等。lsblk命令包含在util-linux-ng包中,现在该包改名为util-linux。这个包带了几个其它工具,如dmesg。要安装lsblk,请在此处下载util-linux包。Fedora用户可以通过命令sudo yum install util-linux-ng来安装该包。

选项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-a, --all            显示所有设备。
-b, --bytes 以bytes方式显示设备大小。
-d, --nodeps 不显示 slaves 或 holders。
-D, --discard print discard capabilities。
-e, --exclude <list> 排除设备 (default: RAM disks)。
-f, --fs 显示文件系统信息。
-h, --help 显示帮助信息。
-i, --ascii use ascii characters only。
-m, --perms 显示权限信息。
-l, --list 使用列表格式显示。
-n, --noheadings 不显示标题。
-o, --output <list> 输出列。
-P, --pairs 使用key="value"格式显示。
-r, --raw 使用原始格式显示。
-t, --topology 显示拓扑结构信息。

实例

lsblk命令默认情况下将以树状列出所有块设备。打开终端,并输入以下命令:

1
2
3
4
5
6
7
8
9
10
11
lsblk

NAME MAJ:MIN rm SIZE RO type mountpoint
sda 8:0 0 232.9G 0 disk
├─sda1 8:1 0 46.6G 0 part /
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 190M 0 part /boot
├─sda6 8:6 0 3.7G 0 part [SWAP]
├─sda7 8:7 0 93.1G 0 part /data
└─sda8 8:8 0 89.2G 0 part /personal
sr0 11:0 1 1024M 0 rom

7个栏目名称如下:

  1. NAME :这是块设备名。
  2. MAJ:MIN :本栏显示主要和次要设备号。
  3. RM :本栏显示设备是否可移动设备。注意,在本例中设备sdb和sr0的RM值等于1,这说明他们是可移动设备。
  4. SIZE :本栏列出设备的容量大小信息。例如298.1G表明该设备大小为298.1GB,而1K表明该设备大小为1KB。
  5. RO :该项表明设备是否为只读。在本案例中,所有设备的RO值为0,表明他们不是只读的。
  6. TYPE :本栏显示块设备是否是磁盘或磁盘上的一个分区。在本例中,sda和sdb是磁盘,而sr0是只读存储(rom)。
  7. MOUNTPOINT :本栏指出设备挂载的挂载点。

默认选项不会列出所有空设备。要查看这些空设备,请使用以下命令:

1
lsblk -a

lsblk命令也可以用于列出一个特定设备的拥有关系,同时也可以列出组和模式。可以通过以下命令来获取这些信息:

1
lsblk -m

该命令也可以只获取指定设备的信息。这可以通过在提供给lsblk命令的选项后指定设备名来实现。例如,你可能对了解以字节显示你的磁盘驱动器大小比较感兴趣,那么你可以通过运行以下命令来实现:

1
2
3
4
5
lsblk -b /dev/sda

等价于

lsblk --bytes /dev/sda

你也可以组合几个选项来获取指定的输出。例如,你也许想要以列表格式列出设备,而不是默认的树状格式。你可能也对移除不同栏目名称的标题感兴趣。可以将两个不同的选项组合,以获得期望的输出,命令如下:

1
lsblk -nl

要获取SCSI设备的列表,你只能使用-S选项。该选项是大写字母S,不能和-s选项混淆,该选项是用来以颠倒的顺序打印依赖的。

1
lsblk -S

lsblk列出SCSI设备,而-s是逆序选项(将设备和分区的组织关系逆转过来显示),其将给出如下输出。输入命令:

1
lsblk -s

lsattr

查看文件的第二扩展文件系统属性

补充说明

lsattr命令 用于查看文件的第二扩展文件系统属性。

语法

1
lsattr(选项)(参数)

选项

1
2
3
4
5
-E:可显示设备属性的当前值,但这个当前值是从用户设备数据库中获得的,而不是从设备直接获得的。
-D:显示属性的名称,属性的默认值,描述和用户是否可以修改属性值的标志。
-R:递归的操作方式;
-V:显示指令的版本信息;
-a:列出目录中的所有文件,包括隐藏文件。

lsattr经常使用的几个选项-D,-E,-R这三个选项不可以一起使用,它们是互斥的,经常使用的还有-l,-H,使用lsattr时,必须指出具体的设备名,用-l选项指出要显示设备的逻辑名称,否则要用-c,-s,-t等选项唯一的确定某个已存在的设备。

参数

文件:指定显示文件系统属性的文件名。

实例

1
2
lsattr -E -l rmt0 -H
lsattr -EO -l rmt0

ls

显示目录内容列表

补充说明

ls命令 用来显示目标列表,在Linux中是使用率较高的命令。ls命令的输出信息可以进行彩色加亮显示,以分区不同类型的文件。

语法

1
ls(选项)(参数)

选项

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

-a, --all 不隐藏任何以. 开始的项目
-A, --almost-all 列出除. 及.. 以外的任何项目
--author 与-l 同时使用时列出每个文件的作者
-b, --escape 以八进制溢出序列表示不可打印的字符
--block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'--block-size=M' prints sizes in units of
1,048,576 bytes; see SIZE format below
-B, --ignore-backups do not list implied entries ending with ~
-c with -lt: sort by, and show, ctime (time of last
modification of file status information);
with -l: show ctime and sort by name;
otherwise: sort by ctime, newest first
-C list entries by columns
--color[=WHEN] colorize the output; WHEN can be 'never', 'auto',
or 'always' (the default); more info below
-d, --directory list directories themselves, not their contents
-D, --dired generate output designed for Emacs' dired mode
-f do not sort, enable -aU, disable -ls --color
-F, --classify append indicator (one of */=>@|) to entries
--file-type likewise, except do not append '*'
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
--full-time like -l --time-style=full-iso
-g 类似-l,但不列出所有者
--group-directories-first
group directories before files;
can be augmented with a --sort option, but any
use of --sort=none (-U) disables grouping
-G, --no-group 以一个长列表的形式,不输出组名
-h, --human-readable 与-l 一起,以易于阅读的格式输出文件大小
(例如 1K 234M 2G)
--si 同上面类似,但是使用1000 为基底而非1024
-H, --dereference-command-line
follow symbolic links listed on the command line
--dereference-command-line-symlink-to-dir
follow each command line symbolic link
that points to a directory
--hide=PATTERN do not list implied entries matching shell PATTERN
(overridden by -a or -A)
--indicator-style=WORD append indicator with style WORD to entry names:
none (default), slash (-p),
file-type (--file-type), classify (-F)
-i, --inode print the index number of each file
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN
-k, --kibibytes default to 1024-byte blocks for disk usage
-l 使用较长格式列出信息
-L, --dereference 当显示符号链接的文件信息时,显示符号链接所指示
的对象而并非符号链接本身的信息
-m 所有项目以逗号分隔,并填满整行行宽
-n, --numeric-uid-gid 类似 -l,但列出UID 及GID 号
-N, --literal 输出未经处理的项目名称 (如不特别处理控制字符)
-o 类似 -l,但不列出有关组的信息
-p, --indicator-style=slash 对目录加上表示符号"/"
-q, --hide-control-chars print ? instead of nongraphic characters
--show-control-chars show nongraphic characters as-is (the default,
unless program is 'ls' and output is a terminal)
-Q, --quote-name enclose entry names in double quotes
--quoting-style=WORD use quoting style WORD for entry names:
literal, locale, shell, shell-always, c, escape
-r, --reverse 逆序排列
-R, --recursive 递归显示子目录
-s, --size 以块数形式显示每个文件分配的尺寸
-S sort by file size
--sort=WORD sort by WORD instead of name: none (-U), size (-S),
time (-t), version (-v), extension (-X)
--time=WORD with -l, show time as WORD instead of default
modification time: atime or access or use (-u)
ctime or status (-c); also use specified time
as sort key if --sort=time
--time-style=STYLE with -l, show times using style STYLE:
full-iso, long-iso, iso, locale, or +FORMAT;
FORMAT is interpreted like in 'date'; if FORMAT
is FORMAT1<newline>FORMAT2, then FORMAT1 applies
to non-recent files and FORMAT2 to recent files;
if STYLE is prefixed with 'posix-', STYLE
takes effect only outside the POSIX locale
-t sort by modification time, newest first
-T, --tabsize=COLS assume tab stops at each COLS instead of 8
-u with -lt: sort by, and show, access time;
with -l: show access time and sort by name;
otherwise: sort by access time
-U do not sort; list entries in directory order
-v natural sort of (version) numbers within text
-w, --width=COLS assume screen width instead of current value
-x list entries by lines instead of by columns
-X sort alphabetically by entry extension
-1 list one file per line

SELinux options:

--lcontext Display security context. Enable -l. Lines
will probably be too wide for most displays.
-Z, --context Display security context so it fits on most
displays. Displays only mode, user, group,
security context and file name.
--scontext Display only security context and file name.
--help 显示此帮助信息并退出
--version 显示版本信息并退出

参数

目录:指定要显示列表的目录,也可以是具体的文件。

实例

1
2
3
4
$ ls       # 仅列出当前目录可见文件
$ ls -l # 列出当前目录可见文件详细信息
$ ls -hl # 列出详细信息并以可读大小显示文件大小
$ ls -al # 列出所有文件(包括隐藏)的详细信息

显示当前目录下包括影藏文件在内的所有文件列表

1
2
3
[root@localhost ~]# ls -a
. anaconda-ks.cfg .bash_logout .bashrc install.log .mysql_history satools .tcshrc .vimrc
.. .bash_history .bash_profile .cshrc install.log.syslog .rnd .ssh .viminfo

输出长格式列表

1
2
3
4
5
6
[root@localhost ~]# ls -1

anaconda-ks.cfg
install.log
install.log.syslog
satools

显示文件的inode信息

索引节点(index inode简称为“inode”)是Linux中一个特殊的概念,具有相同的索引节点号的两个文本本质上是同一个文件(除文件名不同外)。

1
2
3
[root@localhost ~]# ls -i -l anaconda-ks.cfg install.log
2345481 -rw------- 1 root root 859 Jun 11 22:49 anaconda-ks.cfg
2345474 -rw-r--r-- 1 root root 13837 Jun 11 22:49 install.log

水平输出文件列表

1
2
3
[root@localhost /]# ls -m

bin, boot, data, dev, etc, home, lib, lost+found, media, misc, mnt, opt, proc, root, sbin, selinux, srv, sys, tmp, usr, var

修改最后一次编辑的文件

最近修改的文件显示在最上面。

1
2
3
[root@localhost /]# ls -t

tmp root etc dev lib boot sys proc data home bin sbin usr var lost+found media mnt opt selinux srv misc

显示递归文件

1
2
3
4
5
6
[root@localhost ~]# ls -R
.:
anaconda-ks.cfg install.log install.log.syslog satools

./satools:
black.txt freemem.sh iptables.sh lnmp.sh mysql php502_check.sh ssh_safe.sh

打印文件的UID和GID

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@localhost /]# ls -n

total 254
drwxr-xr-x 2 0 0 4096 Jun 12 04:03 bin
drwxr-xr-x 4 0 0 1024 Jun 15 14:45 boot
drwxr-xr-x 6 0 0 4096 Jun 12 10:26 data
drwxr-xr-x 10 0 0 3520 Sep 26 15:38 dev
drwxr-xr-x 75 0 0 4096 Oct 16 04:02 etc
drwxr-xr-x 4 0 0 4096 Jun 12 10:26 home
drwxr-xr-x 14 0 0 12288 Jun 16 04:02 lib
drwx------ 2 0 0 16384 Jun 11 22:46 lost+found
drwxr-xr-x 2 0 0 4096 May 11 2011 media
drwxr-xr-x 2 0 0 4096 Nov 8 2010 misc
drwxr-xr-x 2 0 0 4096 May 11 2011 mnt
drwxr-xr-x 2 0 0 4096 May 11 2011 opt
dr-xr-xr-x 232 0 0 0 Jun 15 11:04 proc
drwxr-x--- 4 0 0 4096 Oct 15 14:43 root
drwxr-xr-x 2 0 0 12288 Jun 12 04:03 sbin
drwxr-xr-x 2 0 0 4096 May 11 2011 selinux
drwxr-xr-x 2 0 0 4096 May 11 2011 srv
drwxr-xr-x 11 0 0 0 Jun 15 11:04 sys
drwxrwxrwt 3 0 0 98304 Oct 16 08:45 tmp
drwxr-xr-x 13 0 0 4096 Jun 11 23:38 usr
drwxr-xr-x 19 0 0 4096 Jun 11 23:38 var

列出文件和文件夹的详细信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@localhost /]# ls -l

total 254
drwxr-xr-x 2 root root 4096 Jun 12 04:03 bin
drwxr-xr-x 4 root root 1024 Jun 15 14:45 boot
drwxr-xr-x 6 root root 4096 Jun 12 10:26 data
drwxr-xr-x 10 root root 3520 Sep 26 15:38 dev
drwxr-xr-x 75 root root 4096 Oct 16 04:02 etc
drwxr-xr-x 4 root root 4096 Jun 12 10:26 home
drwxr-xr-x 14 root root 12288 Jun 16 04:02 lib
drwx------ 2 root root 16384 Jun 11 22:46 lost+found
drwxr-xr-x 2 root root 4096 May 11 2011 media
drwxr-xr-x 2 root root 4096 Nov 8 2010 misc
drwxr-xr-x 2 root root 4096 May 11 2011 mnt
drwxr-xr-x 2 root root 4096 May 11 2011 opt
dr-xr-xr-x 232 root root 0 Jun 15 11:04 proc
drwxr-x--- 4 root root 4096 Oct 15 14:43 root
drwxr-xr-x 2 root root 12288 Jun 12 04:03 sbin
drwxr-xr-x 2 root root 4096 May 11 2011 selinux
drwxr-xr-x 2 root root 4096 May 11 2011 srv
drwxr-xr-x 11 root root 0 Jun 15 11:04 sys
drwxrwxrwt 3 root root 98304 Oct 16 08:48 tmp
drwxr-xr-x 13 root root 4096 Jun 11 23:38 usr
drwxr-xr-x 19 root root 4096 Jun 11 23:38 var

列出可读文件和文件夹详细信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@localhost /]# ls -lh

total 254K
drwxr-xr-x 2 root root 4.0K Jun 12 04:03 bin
drwxr-xr-x 4 root root 1.0K Jun 15 14:45 boot
drwxr-xr-x 6 root root 4.0K Jun 12 10:26 data
drwxr-xr-x 10 root root 3.5K Sep 26 15:38 dev
drwxr-xr-x 75 root root 4.0K Oct 16 04:02 etc
drwxr-xr-x 4 root root 4.0K Jun 12 10:26 home
drwxr-xr-x 14 root root 12K Jun 16 04:02 lib
drwx------ 2 root root 16K Jun 11 22:46 lost+found
drwxr-xr-x 2 root root 4.0K May 11 2011 media
drwxr-xr-x 2 root root 4.0K Nov 8 2010 misc
drwxr-xr-x 2 root root 4.0K May 11 2011 mnt
drwxr-xr-x 2 root root 4.0K May 11 2011 opt
dr-xr-xr-x 235 root root 0 Jun 15 11:04 proc
drwxr-x--- 4 root root 4.0K Oct 15 14:43 root
drwxr-xr-x 2 root root 12K Jun 12 04:03 sbin
drwxr-xr-x 2 root root 4.0K May 11 2011 selinux
drwxr-xr-x 2 root root 4.0K May 11 2011 srv
drwxr-xr-x 11 root root 0 Jun 15 11:04 sys
drwxrwxrwt 3 root root 96K Oct 16 08:49 tmp
drwxr-xr-x 13 root root 4.0K Jun 11 23:38 usr
drwxr-xr-x 19 root root 4.0K Jun 11 23:38 var

显示文件夹信息

1
2
3
[root@localhost /]# ls -ld /etc/

drwxr-xr-x 75 root root 4096 Oct 16 04:02 /etc/

按时间列出文件和文件夹详细信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@localhost /]# ls -lt

total 254
drwxrwxrwt 3 root root 98304 Oct 16 08:53 tmp
drwxr-xr-x 75 root root 4096 Oct 16 04:02 etc
drwxr-x--- 4 root root 4096 Oct 15 14:43 root
drwxr-xr-x 10 root root 3520 Sep 26 15:38 dev
drwxr-xr-x 14 root root 12288 Jun 16 04:02 lib
drwxr-xr-x 4 root root 1024 Jun 15 14:45 boot
drwxr-xr-x 11 root root 0 Jun 15 11:04 sys
dr-xr-xr-x 232 root root 0 Jun 15 11:04 proc
drwxr-xr-x 6 root root 4096 Jun 12 10:26 data
drwxr-xr-x 4 root root 4096 Jun 12 10:26 home
drwxr-xr-x 2 root root 4096 Jun 12 04:03 bin
drwxr-xr-x 2 root root 12288 Jun 12 04:03 sbin
drwxr-xr-x 13 root root 4096 Jun 11 23:38 usr
drwxr-xr-x 19 root root 4096 Jun 11 23:38 var
drwx------ 2 root root 16384 Jun 11 22:46 lost+found
drwxr-xr-x 2 root root 4096 May 11 2011 media
drwxr-xr-x 2 root root 4096 May 11 2011 mnt
drwxr-xr-x 2 root root 4096 May 11 2011 opt
drwxr-xr-x 2 root root 4096 May 11 2011 selinux
drwxr-xr-x 2 root root 4096 May 11 2011 srv
drwxr-xr-x 2 root root 4096 Nov 8 2010 misc

按修改时间列出文件和文件夹详细信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@localhost /]# ls -ltr

total 254
drwxr-xr-x 2 root root 4096 Nov 8 2010 misc
drwxr-xr-x 2 root root 4096 May 11 2011 srv
drwxr-xr-x 2 root root 4096 May 11 2011 selinux
drwxr-xr-x 2 root root 4096 May 11 2011 opt
drwxr-xr-x 2 root root 4096 May 11 2011 mnt
drwxr-xr-x 2 root root 4096 May 11 2011 media
drwx------ 2 root root 16384 Jun 11 22:46 lost+found
drwxr-xr-x 19 root root 4096 Jun 11 23:38 var
drwxr-xr-x 13 root root 4096 Jun 11 23:38 usr
drwxr-xr-x 2 root root 12288 Jun 12 04:03 sbin
drwxr-xr-x 2 root root 4096 Jun 12 04:03 bin
drwxr-xr-x 4 root root 4096 Jun 12 10:26 home
drwxr-xr-x 6 root root 4096 Jun 12 10:26 data
dr-xr-xr-x 232 root root 0 Jun 15 11:04 proc
drwxr-xr-x 11 root root 0 Jun 15 11:04 sys
drwxr-xr-x 4 root root 1024 Jun 15 14:45 boot
drwxr-xr-x 14 root root 12288 Jun 16 04:02 lib
drwxr-xr-x 10 root root 3520 Sep 26 15:38 dev
drwxr-x--- 4 root root 4096 Oct 15 14:43 root
drwxr-xr-x 75 root root 4096 Oct 16 04:02 etc
drwxrwxrwt 3 root root 98304 Oct 16 08:54 tmp

按照特殊字符对文件进行分类

1
2
3
[root@localhost nginx-1.2.1]# ls -F

auto/ CHANGES CHANGES.ru conf/ configure* contrib/ html/ LICENSE Makefile man/ objs/ README src/

列出文件并标记颜色分类

1
2
3
[root@localhost nginx-1.2.1]# ls --color=auto

auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src

lpstat

显示CUPS中打印机的状态信息

补充说明

lpstat命令 用于显示CUPS中打印机的状态信息。

语法

1
lpstat(选项)

选项

1
2
3
4
5
6
7
8
9
10
11
-E:与打印机连接时加密;
-R:显示打印任务的等级;
-U:指定可选用户名;
-a:显示接受打印任务的打印机;
-c:显示打印机类;
-d:显示默认打印机;
-h:指定可选的服务器信息;
-l:显示长格式;
-p:显示指定打印机,以及打印机是否接受打印任务;
-s:显示汇总信息;
-t:显示所有的状态信息。

lprm

删除打印队列中的打印任务

补充说明

lprm命令 用于删除打印队列中的打印任务。尚未完成的打印机任务会被放在打印机贮列之中,这个命令可用来将常未送到打印机的任务取消。

语法

1
lprm(选项)(参数)

选项

1
2
3
-E:与打印服务器连接时强制使用加密;
-P:指定接受打印任务的目标打印机;
-U:指定可选的用户名。

参数

打印任务:指定需删除的打印任务号。

实例

将打印机hpprint中的第102号任务移除:

1
lprm -Phpprint 102

将第101号任务由预设打印机中移除:

1
lprm 101

lpr

将文件发送给指定打印机进行打印

补充说明

lpr命令 用于将文件发送给指定打印机进行打印,如果不指定目标打印机,则使用默认打印机。

语法

1
lpr(选项)(参数)

选项

1
2
3
4
5
6
7
8
9
-E:与打印服务器连接时强制使用加密;
-H:指定可选的打印服务器;
-C:指定打印任务的名称;
-P:指定接受打印任务的目标打印机;
-U:指定可选的用户名;
-#:指定打印的份数;
-h:关闭banner打印;
-m:打印完成后发送E-mail;
-r:打印完成后删除文件。

参数

文件:需打印的文件。

实例

将man1和man2送到打印机lp进行打印:

1
lpr -P lp man1 man2

lpq

显示打印队列中的打印任务的状态信息

补充说明

lpq命令 用于显示打印队列中的打印任务的状态信息。

语法

1
lpq(选项)

选项

1
2
3
4
5
6
7
-E:强制使用加密方式与服务器连接;
-P:显示中的打印机上的打印队列状态;;
-U:自动可选的用户名;
-a:报告所有打印机的定义任务;
-h:指定打印服务器信息;
-l:使用长格式输出;
+:指定显示状态的间隔时间。