Linux基础命令的使用
文件查看
ls [list 列出] 列出当前目录下所有的文件
命令语法
ls [选项] [文件]
注:"[]" 内的内容为可选项,可以写,可以不写,根据实际要求来选择
ls常用的参数:
ls -l = ll
#ls -l 长格式显示 可以查看文件的类型、权限链接数 属主、属组 大小 修改时间 文件名
#ls -l = ll
#drwxr-xr-x 2 root root 4096 5月 17 15:45 0502
#-rw-r--r-- 1 root root 51202 6月 2 08:54 2102log&process.zip
#drwxr-xr-x 3 root root 113 2月 22 08:44 abc
#-rw-r--r-- 1 root root 0 5月 20 10:45 A.TXT
#-rwxr-xr-x 1 root root 278 12月 21 2020 auto_archive.sh
#-rwxr-xr-x 1 root root 487 12月 1 2020 check_upload.sh
ls -a
#ls -a 显示所有文件 包括隐藏文件
#linux中以"."开头的文件为隐藏文件
# -a all 显示所有文件,包含隐藏文件
#[root@localhost ~]# ls -a
# . .cache .ICEauthority .ssh XMind.zip
# .. .config .ipa .tcshrc zimu.tar
# .bash_history .cshrc .lesshst tengine-2.3.2 zimu.tar.bz2
# .bash_logout .dbus .local tengine-2.3.2.tar.gz zimu.tar.gz
# .bash_profile Downloads .mozilla .viminfo
# .bashrc .esd_auth .pki .vimrc
ls -lh
#ls -lh [-h human-readabel 让文件的大小以人类易读的方式显示]
#一般来说 -h 要和-l 一起使用 不然-h 的作用我们无法用肉眼观察到
#[root@localhost ~]# ls -lh
#总用量 2.8M
#drwxr-xr-x. 2 root root 6 7月 23 10:17 Downloads
#drwxrwxr-x. 14 root root 4.0K 7月 23 08:39 tengine-2.3.2
#-r--------. 1 root root 2.8M 7月 22 20:35 tengine-2.3.2.tar.gz
#-r--------. 1 root root 1.8K 8月 5 20:03 XMind.zip
#-rw-r--r--. 1 root root 40K 8月 5 11:12 zimu.tar
#-rw-r--r--. 1 root root 129 8月 5 11:39 zimu.tar.bz2
#-rw-r--r--. 1 root root 124 8月 5 11:38 zimu.tar.gz
ll -t
#ll -t [-t 以时间顺序排序,最新的文件在上]
#在一般情况下,liunx文件的排序默认以文件名排序
#也可以使用ls -t 但ll -t 可以更加直观的显示出时间排序
#[root@localhost ~]# ll -t
#总用量 2828
#-r--------. 1 root root 1753 8月 5 20:03 XMind.zip
#-rw-r--r--. 1 root root 129 8月 5 11:39 zimu.tar.bz2
#-rw-r--r--. 1 root root 124 8月 5 11:38 zimu.tar.gz
#-rw-r--r--. 1 root root 40960 8月 5 11:12 zimu.tar
#drwxr-xr-x. 2 root root 6 7月 23 10:17 Downloads
#drwxrwxr-x. 14 root root 4096 7月 23 08:39 tengine-2.3.2
#-r--------. 1 root root 2835884 7月 22 20:35 tengine-2.3.2.tar.gz
ll -d
#ll -d [-d directory 目录]
#ls 后面跟上目录,如果不加-d选项,则显示的是目录内的内容
#如果加上-d选项则显示目录本身的信息
#[root@localhost /]# ll -d root
#dr-xr-x---. 12 root root 4096 8月 6 20:56 root
ll -i
#ll -i 或者 ls -i [-i inode 显示文件inode]
#ll -i 或者 ls -i 可以查看文件的索引号
#17651230 drwxr-xr-x. 2 root root 6 7月 23 10:17 Downloads
#17834562 drwxrwxr-x. 14 root root 4096 7月 23 08:39 tengine-2.3.2
#33796781 -r--------. 1 root root 2835884 7月 22 20:35 tengine-2.3.2.tar.gz
#33574990 -r--------. 1 root root 1753 8月 5 20:03 XMind.zip
#35308842 -rw-r--r--. 1 root root 40960 8月 5 11:12 zimu.tar
#33796759 -rw-r--r--. 1 root root 129 8月 5 11:39 zimu.tar.bz2
#33796757 -rw-r--r--. 1 root root 124 8月 5 11:38 zimu.tar.gz
ls --help man ls
#ls --help [--help] 查看命令的帮助文档
#man ls 查看命令详细帮助文档
文件查看补充内容[通配符]
* 代表零个或者多个任意字符
? 代表一个任意字符
[root@localhost tmp]# ll file*
-rw-r--r--. 1 root root 0 8月 7 09:16 file10.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file1.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file2.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file3.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file4.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file5.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file6.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file7.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file8.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file9.txt
[root@localhost tmp]# ll file?.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file1.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file2.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file3.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file4.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file5.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file6.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file7.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file8.txt
-rw-r--r--. 1 root root 0 8月 7 09:16 file9.txt