Linux常用命令一

155 阅读2分钟

帮助命令man ls

内部命令使用help帮助help cd

外部命令使用help帮助ls --help

通过type来查看是内部还是外部

[root@iZbp14pupgygkqfarefzwgZ ~]# type cd
cd 是 shell 内嵌
[root@iZbp14pupgygkqfarefzwgZ ~]# type ls
ls 是 `ls --color=auto' 的别名

显示当前目录名称pwd

显示有哪些文件ls

[root@iZbp14pupgygkqfarefzwgZ ~]# ls /
bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@iZbp14pupgygkqfarefzwgZ ~]#
[root@iZbp14pupgygkqfarefzwgZ ~]# ls /root
etc  mysql-8.0.15-linux-glibc2.12-x86_64.tar  my_tools  sub.sh

ls -l 查看当前目录下的内容

总用量 1899008
drwxr-xr-x 77 root root       4096 5月   6 2021 etc
-rw-r--r--  1 root root 1974067200 1月  27 2019 mysql-8.0.15-linux-glibc2.12-x86_64.tar
drwxr-xr-x  2 root root       4096 11月 14 09:42 my_tools
-rwxr--r--  1 root root         24 7月   1 2021 sub.sh

ls -a 查看有哪些隐藏文件

.              .bash_logout   .cache  mysql-8.0.15-linux-glibc2.12-x86_64.tar  .percona-toolkit.uuid  .rediscli_history  .tcshrc
..             .bash_profile  .cshrc  .mysql_history                           .pip                   .ssh               .viminfo
.bash_history  .bashrc        etc     my_tools                                 .pydistutils.cfg       sub.sh

ls -r 逆向显示,默认以文件名逆向显示

总用量 1899008
drwxr-xr-x 77 root root       4096 5月   6 2021 etc
-rw-r--r--  1 root root 1974067200 1月  27 2019 mysql-8.0.15-linux-glibc2.12-x86_64.tar
drwxr-xr-x  2 root root       4096 11月 14 09:42 my_tools
-rwxr--r--  1 root root         24 7月   1 2021 sub.sh
[root@iZbp14pupgygkqfarefzwgZ ~]# ls -l -r
总用量 1899008
-rwxr--r--  1 root root         24 7月   1 2021 sub.sh
drwxr-xr-x  2 root root       4096 11月 14 09:42 my_tools
-rw-r--r--  1 root root 1974067200 1月  27 2019 mysql-8.0.15-linux-glibc2.12-x86_64.tar
drwxr-xr-x 77 root root       4096 5月   6 2021 etc

ls -r -t 以时间逆向显示

总用量 1899008
drwxr-xr-x 77 root root       4096 5月   6 2021 etc
-rw-r--r--  1 root root 1974067200 1月  27 2019 mysql-8.0.15-linux-glibc2.12-x86_64.tar
drwxr-xr-x  2 root root       4096 11月 14 09:42 my_tools
-rwxr--r--  1 root root         24 7月   1 2021 sub.sh
[root@iZbp14pupgygkqfarefzwgZ ~]# ls -l -r -t
总用量 1899008
-rw-r--r--  1 root root 1974067200 1月  27 2019 mysql-8.0.15-linux-glibc2.12-x86_64.tar
drwxr-xr-x 77 root root       4096 5月   6 2021 etc
-rwxr--r--  1 root root         24 7月   1 2021 sub.sh
drwxr-xr-x  2 root root       4096 11月 14 09:42 my_tools

ls -R 递归显示

.:
test.txt  w1

./w1:
2.txt