cd 目录 切换工作目录
[root@localhost ~]# cd /tmp
[root@localhost tmp]#
由此可见 用cd 从家目录切换到tmp目录下
cd - 切换到上次所在的目录
[root@localhost tmp]# cd /home
[root@localhost home]# cd -
/tmp
[root@localhost tmp]#
cd .. 切换到上级目录
[root@localhost home]# ls
wah
[root@localhost home]# cd wah
[root@localhost wah]# cd ..
[root@localhost home]#
cd ~ 切换到当前用户的家目录下
[root@localhost home]# cd ~
[root@localhost ~]# pwd
/root
[root@localhost ~]#
cd ../.. 切换到上两级目录
[root@localhost /]# ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
[root@localhost /]# cd /home
[root@localhost home]# ls
wah
[root@localhost home]# cd wah
[root@localhost wah]# cd ../..
[root@localhost /]#
ls 查看目录下的内容
[root@localhost home]# ls
wah
[root@localhost home]#
查看/home下的内容
-l 显示文件或者目录的详细信息 ls -l 等价于 ll
[root@localhost home]# ll
总用量 0
drwx------. 14 wah wah 271 3月 22 00:02 wah
[root@localhost home]#
-a 显示所有文件,包括以“.”开头的隐藏文件。
[root@localhost home]# ls -a
. .. wah
[root@localhost home]#
-ld 如果参数是目录,以得到目录的详细信息。
[root@localhost home]# ls -ld
drwxr-xr-x. 3 root root 17 3月 22 00:02 .
[root@localhost home]#
cat 查看文件内容
[root@localhost ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
libstoragemgmt:x:998:996:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
colord:x:997:995:User for colord:/var/lib/colord:/sbin/nologin
saslauth:x:996:76:Saslauthd user:/run/saslauthd:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
chrony:x:995:991::/var/lib/chrony:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
geoclue:x:994:989:User for geoclue:/var/lib/geoclue:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
setroubleshoot:x:993:988::/var/lib/setroubleshoot:/sbin/nologin
sssd:x:992:987:User for sssd:/:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:991:986::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
wah:x:1000:1000:wah:/home/wah:/bin/bash
nginx:x:990:985:nginx user:/var/cache/nginx:/sbin/nologin
[root@localhost ~]#
-n 选项 显示行号
[root@localhost ~]# cat -n /etc/passwd
1 root:x:0:0:root:/root:/bin/bash
2 bin:x:1:1:bin:/bin:/sbin/nologin
3 daemon:x:2:2:daemon:/sbin:/sbin/nologin
4 adm:x:3:4:adm:/var/adm:/sbin/nologin
5 lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
6 sync:x:5:0:sync:/sbin:/bin/sync
7 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
8 halt:x:7:0:halt:/sbin:/sbin/halt
9 mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
10 operator:x:11:0:operator:/root:/sbin/nologin
11 games:x:12:100:games:/usr/games:/sbin/nologin
12 ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
13 nobody:x:99:99:Nobody:/:/sbin/nologin
14 systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
15 dbus:x:81:81:System message bus:/:/sbin/nologin
16 polkitd:x:999:998:User for polkitd:/:/sbin/nologin
17 abrt:x:173:173::/etc/abrt:/sbin/nologin
18 libstoragemgmt:x:998:996:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
19 rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
20 colord:x:997:995:User for colord:/var/lib/colord:/sbin/nologin
21 saslauth:x:996:76:Saslauthd user:/run/saslauthd:/sbin/nologin
22 rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
23 pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
24 chrony:x:995:991::/var/lib/chrony:/sbin/nologin
25 rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
26 nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
27 ntp:x:38:38::/etc/ntp:/sbin/nologin
28 tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
29 usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
30 geoclue:x:994:989:User for geoclue:/var/lib/geoclue:/sbin/nologin
31 qemu:x:107:107:qemu user:/:/sbin/nologin
32 radvd:x:75:75:radvd user:/:/sbin/nologin
33 setroubleshoot:x:993:988::/var/lib/setroubleshoot:/sbin/nologin
34 sssd:x:992:987:User for sssd:/:/sbin/nologin
35 gdm:x:42:42::/var/lib/gdm:/sbin/nologin
36 gnome-initial-setup:x:991:986::/run/gnome-initial-setup/:/sbin/nologin
37 sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
38 avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
39 postfix:x:89:89::/var/spool/postfix:/sbin/nologin
40 tcpdump:x:72:72::/:/sbin/nologin
41 wah:x:1000:1000:wah:/home/wah:/bin/bash
42 nginx:x:990:985:nginx user:/var/cache/nginx:/sbin/nologin
[root@localhost ~]#
cat w1 w2 > w3 把文件w1,w2合并成一个新的文件w3
(先ls看一下主目录下有什么文件,这里我们有w1 w2 这时我们用cat w1 w2 >w3 就可以合并成w3
,执行完命令我们再ls查看一下 就有了w3这个文件)
[root@localhost ~]# ls
anaconda-ks.cfg nginx-1.8.1-1.el7.ngx.x86_64.rpm w2 模板 图片 下载 桌面
initial-setup-ks.cfg w1 公共 视频 文档 音乐
[root@localhost ~]# cat w1 w2 > w3
[root@localhost ~]# ls
anaconda-ks.cfg nginx-1.8.1-1.el7.ngx.x86_64.rpm w2 公共 视频 文档 音乐
initial-setup-ks.cfg w1 w3 模板 图片 下载 桌面
[root@localhost ~]#
more 分屏显示文件内容
enter 往下翻一行
空格 往下翻一页
q 退出
-n 往下翻页的时候,每次翻几行
[root@localhost ~]# more -3 /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
--More--(4%)
再敲一次空格,就再多看三行
[root@localhost ~]# more -3 /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
--More--(9%)
+n 从第几行开始显示
比如more +3 /etc/passwd 这时敲回车 我们就会从/etc/passwd的第三行开始查看这个文件
[root@localhost ~]# more +3 /etc/passwd
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
libstoragemgmt:x:998:996:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
colord:x:997:995:User for colord:/var/lib/colord:/sbin/nologin
saslauth:x:996:76:Saslauthd user:/run/saslauthd:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
chrony:x:995:991::/var/lib/chrony:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/
sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
geoclue:x:994:989:User for geoclue:/var/lib/geoclue:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
setroubleshoot:x:993:988::/var/lib/setroubleshoot:/sbin/nologin
sssd:x:992:987:User for sssd:/:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:991:986::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
wah:x:1000:1000:wah:/home/wah:/bin/bash
nginx:x:990:985:nginx user:/var/cache/nginx:/sbin/nologin
less 分屏显示文件内容
enter 往下翻一行
空格 往下翻一页
b 网上翻一页
/ 搜索
more 和 less 的区别就在于more 只能向下看 而less 不仅能往下看 还能往上翻(查看区别请在最小化实验)
head 查看文件前十行内容
[root@localhost ~]# head /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
[root@localhost ~]#
-n 显示文件前几行
[root@localhost ~]# head -3 /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
[root@localhost ~]#
加上-n(n是自然数)这时候我们就只查看n三行,例如上面我们指定的是-3 就只能看前三行。
tail 查看文件后十行内容
[root@localhost ~]# tail /etc/passwd
setroubleshoot:x:993:988::/var/lib/setroubleshoot:/sbin/nologin
sssd:x:992:987:User for sssd:/:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:991:986::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
wah:x:1000:1000:wah:/home/wah:/bin/bash
nginx:x:990:985:nginx user:/var/cache/nginx:/sbin/nologin
[root@localhost ~]#
-n 显示文件后几行
[root@localhost ~]# tail -3 /etc/passwd
tcpdump:x:72:72::/:/sbin/nologin
wah:x:1000:1000:wah:/home/wah:/bin/bash
nginx:x:990:985:nginx user:/var/cache/nginx:/sbin/nologin
[root@localhost ~]#
加上-n(n是自然数)这时候我们就只查看n三行,例如上面我们指定的是-3 就只能看前三行。
cp 复制 (copy)
cp 源文件 目标文件
cp A B
我们先查看一下home目录下只有一个 wah 这时我们使用cp复制命令 把/etc/passwd复制到home目录下 再ls查看home 就可以看到我们复制过去的passwd的文件了
[root@localhost ~]# ls /home
wah
[root@localhost ~]# cp /etc/passwd /home
[root@localhost ~]# ls /home
passwd wah
[root@localhost ~]#
管道 | 作用是把前面命令的结果传递给后面的命令
eg.head -6 passwd |tail -1 只显示passwd文件的第六行
[root@localhost ~]# head -6 /etc/passwd |tail -1
sync:x:5:0:sync:/sbin:/bin/sync
[root@localhost ~]#
wc -l 文件名 统计文件的行数
[root@localhost ~]# wc -l /etc/passwd
42 /etc/passwd
[root@localhost ~]#
rm 删除 (remove)
rm 文件 删除文件
[root@localhost home]# touch w1
[root@localhost home]# ls
w1 wah
[root@localhost home]# rm w1
rm:是否删除普通空文件 "w1"?y
[root@localhost home]#
rm -rf 删除目录
-r 递归
-f force 强制
先查看w2的路径,可以看出来是一个递归目录,之后切换到/home 进行强制递归删除,用-rf选项就不会一步一步的询问我们。直接强制删除。
[root@localhost w2]# pwd
/home/w1/w2
[root@localhost w2]# cd /home
[root@localhost home]# ls
w1 wah
[root@localhost home]# rm -rf w1
[root@localhost home]# ls
wah
[root@localhost home]#
mv 移动(move)移动文件或目录的位置
[root@localhost home]# touch w1
[root@localhost home]# ls
w1 wah
[root@localhost home]# mv w1 /
[root@localhost home]# ls /
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr w1
[root@localhost home]#
- clear 清屏
ctrl +l 清屏
ctrl+c 中断当前命令
uname 查看系统信息 uname (user name)
uname -a 查看系统详细信息
[root@localhost ~]# uname
Linux
[root@localhost ~]#
uname -r查看内核版本
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]#
shutdown
关机
shutdown [参数]
-r now reboot 重启 立马重启
eg:shutdown -r now 立即重启 等价于 reboot
[root@localhost ~]# shutdown -r now
-h halt 关机
[root@localhost ~]# shutdown -h
now 立即关机
shutdown -h now 立即关机 等价于 poweroff
[root@localhost ~]# shutdown -h now
hh:mm 小时:分钟
eg:shutdown -h hh:mm 指定时间关机
[root@localhost ~]# shutdown -h 12:00
+m 在多少分钟之后关机
eg:shutdown -h +m 在多少分钟之后关机
[root@localhost ~]# shutdown +20
halt
需要手动关闭电源
history
列出使用过的命令
!1
!2
!3
重复利用1,2,3条命令
[root@localhost ~]# history
1 cd
2 ping baidu
3 service network restart
4*
5 service network restart
6 ping baidu.com
7 ifconfig
8 vim ifcfg-ens33
9 ls\
10 ls
11 cd /etc/sysconfig/network-scripts/
12 vim ifcfg-ens33
13 service network restart
14 ping baidu.com
15 echo "- - -" /sys/class/scsi_host/host0/scan
16 fdisk -l
17 cd /dev
18 ls
19 echo "- - -" /sys/class/scsi_host/host1/scan
20 echo "- - -" /sys/class/scsi_host/host2/scan
21 cd /sys/class/scsi_host
22 ls
23 echo "- - -" /sys/class/scsi_host/host~3/scan
24 ls
25 echo "- - -" /sys/class/scsi_host/host3/scan
26 ls
27 fdisk -l
28 echo "- - -" /sys/class/scsi_host/host0/scan
29 echo "- - -" /sys/class/scsi_host/host1/scan
30 echo "- - -" >> /sys/class/scsi_host/host1/scan
31 echo "- - -" >> /sys/class/scsi_host/host2/scan
32 echo "- - -" >> /sys/class/scsi_host/host0/scan
33 ls
34 fdisk -l
35 ping 192.168.190.128
36 ip a
37 cd
38 yum sougoushurufa
39 lls
40 ls
41 cd -
42 ls
43 cd
44 ls
45 vipw
46 ls -l /dev/sad
47 ls -l /dev/snd
48 usermod -a -G audio username
49 ls
50 cd /home
51 ls
52 touch w1
53 ls
54 rm w1
55 touch w1
56 cd w1
57 ls
58 rm w1
59 mkdir w1
60 ls
61 cd w1
62 touch w2
63 rm w2
64 mkdir w2
65 cd w2
66 pwd
67 rm -rf w1
68 ls
69 pwd
70 cd /homew
71 cd /home
72 cd w1
73 cdw2
74 cd w2
75 pwd
76 cd /home
77 ls
78 rm -rf w1
79 ls
80 touch w1
81 ls
82 mv w1 /
83 ls /
84 cd /w1
85 cd //w1
86 cd /../w1
87 pwd //w1
88 cd
89 uname
90 uname -a
91 history
[root@localhost ~]#
[root@localhost ~]# !89
uname
Linux
[root@localhost ~]#
- man
man ls
查看ls命令的使用方法或帮助信息
man ls 等价于 ls --help
[root@localhost ~]# man ls
LS(1) General Commands Manual LS(1)
NAME
ls, dir, vdir - 列目录内容
提要
ls [选项] [文件名...]
POSIX 标准选项: [-CFRacdilqrtu1]
GNU 选项 (短格式):
[-1abcdfgiklmnopqrstuxABCDFGLNQRSUX] [-w cols] [-T cols] [-I pattern]
[--full-time] [--format={long,verbose,commas,across,vertical,single-column}]
[--sort={none,time,size,extension}] [--time={atime,access,use,ctime,status}]
[--color[={none,auto,always}]] [--help] [--version] [--]
描述( DESCRIPTION )
程序ls先列出非目录的文件项,然后是每一个目录中的“可显示”文件。如果
没有选项之外的参数【译注:即文件名部分为空】出现,缺省为 "." (当前目录)。
选项“ -d ”使得目录与非目录项同样对待。除非“ -a ” 选项出现,文
件名以“.”开始的文件不属“可显示”文件。
以当前目录为准,每一组文件(包括非目录文件项,以及每一内含文件的目录)分
别按文件名比较顺序排序。如果“ -l ”选项存在,每组文件前显示一摘要行:
给出该组文件长度之和(以 512 字节为单位)。
Manual page ls(1) line 1 (press h for help or q to quit)
按q退出
[root@localhost ~]# ls --help
用法:ls [选项]... [文件]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-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 显示版本信息并退出
SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).
使用色彩来区分文件类型的功能已被禁用,默认设置和 --color=never 同时禁用了它。
使用 --color=auto 选项,ls 只在标准输出被连至终端时才生成颜色代码。
LS_COLORS 环境变量可改变此设置,可使用 dircolors 命令来设置。
退出状态:
0 正常
1 一般问题 (例如:无法访问子文件夹)
2 严重问题 (例如:无法使用命令行参数)
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
请向<http://translationproject.org/team/zh_CN.html> 报告ls 的翻译错误
要获取完整文档,请运行:info coreutils 'ls invocation'
[root@localhost ~]#
- echo
echo xxxxxxxx 打印出xxxxxxxx
[root@localhost ~]# echo wah
wah
echo $SHELL
加上$打印定义值
[root@localhost ~]# wah=hdl
[root@localhost ~]# echo $wah
hdl
[root@localhost ~]#