linux常用命令-目录处理命令ls
以根目录为例
[root@localhost /]# ls
bin dev home lib64 media opt root sbin sys usr
boot etc lib lost+found mnt proc run srv tmp var
[root@localhost /]# clear
[root@localhost /]# ls -l
total 60
lrwxrwxrwx. 1 root root 7 Jan 19 20:23 bin -> usr/bin
dr-xr-xr-x. 6 root root 4096 Jan 19 20:27 boot
drwxr-xr-x. 19 root root 3220 Jan 19 20:38 dev
drwxr-xr-x. 74 root root 4096 Jan 20 14:01 etc
drwxr-xr-x. 3 root root 4096 Apr 11 2018 home
lrwxrwxrwx. 1 root root 7 Jan 19 20:23 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Jan 19 20:23 lib64 -> usr/lib64
drwx------. 2 root root 16384 Jan 19 20:22 lost+found
drwxr-xr-x. 2 root root 4096 Apr 11 2018 media
drwxr-xr-x. 2 root root 4096 Apr 11 2018 mnt
drwxr-xr-x. 2 root root 4096 Apr 11 2018 opt
dr-xr-xr-x. 100 root root 0 Jan 19 20:37 proc
dr-xr-x---. 2 root root 4096 Jan 19 20:36 root
drwxr-xr-x. 23 root root 660 Jan 20 14:00 run
lrwxrwxrwx. 1 root root 8 Jan 19 20:23 sbin -> usr/sbin
drwxr-xr-x. 2 root root 4096 Apr 11 2018 srv
dr-xr-xr-x. 13 root root 0 Jan 19 20:37 sys
drwxrwxrwt. 9 root root 4096 Jan 20 14:19 tmp
drwxr-xr-x. 13 root root 4096 Jan 19 20:23 usr
drwxr-xr-x. 19 root root 4096 Jan 19 20:28 var
[root@localhost /]#
ls -lh //h->human 人性化->文件格式以kb为单位
[root@localhost /]# ls -lh
total 60K
lrwxrwxrwx. 1 root root 7 Jan 19 20:23 bin -> usr/bin
dr-xr-xr-x. 6 root root 4.0K Jan 19 20:27 boot
drwxr-xr-x. 19 root root 3.2K Jan 19 20:38 dev
drwxr-xr-x. 74 root root 4.0K Jan 20 14:01 etc
drwxr-xr-x. 3 root root 4.0K Apr 11 2018 home
lrwxrwxrwx. 1 root root 7 Jan 19 20:23 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Jan 19 20:23 lib64 -> usr/lib64
drwx------. 2 root root 16K Jan 19 20:22 lost+found
drwxr-xr-x. 2 root root 4.0K Apr 11 2018 media
drwxr-xr-x. 2 root root 4.0K Apr 11 2018 mnt
drwxr-xr-x. 2 root root 4.0K Apr 11 2018 opt
dr-xr-xr-x. 100 root root 0 Jan 19 20:37 proc
dr-xr-x---. 2 root root 4.0K Jan 19 20:36 root
drwxr-xr-x. 23 root root 660 Jan 20 14:00 run
lrwxrwxrwx. 1 root root 8 Jan 19 20:23 sbin -> usr/sbin
drwxr-xr-x. 2 root root 4.0K Apr 11 2018 srv
dr-xr-xr-x. 13 root root 0 Jan 19 20:37 sys
drwxrwxrwt. 9 root root 4.0K Jan 20 14:19 tmp
drwxr-xr-x. 13 root root 4.0K Jan 19 20:23 usr
drwxr-xr-x. 19 root root 4.0K Jan 19 20:28 var
[root@localhost /]#
ls -a //all 显示所有文件,包括隐藏文件(隐藏文件的文件名以.开头)
[root@localhost ~]# cd /root
[root@localhost ~]# ls -a
. .. anaconda-ks.cfg .bash_history .bash_logout .bash_profile .bashrc .cshrc .tcshrc
[root@localhost ~]#
文件信息解析
- 知识补充
在linux中,每个文件都有自身的创建者user(u),所属组group(g),其他other(o),各自对应其操作权限
- eg
[root@localhost /]# ls -l /usr
total 84
dr-xr-xr-x. 2 root root 20480 Jan 19 20:30 bin
- 文件信息中的第一个字符表示文件种类
‘d’ 表示目录(directory)
‘-’ 表示文件(file)
‘l’ 表示软链接(link)
- 其它信息
其中r表示read(读),w表示write(写),x表示execute(执行文件)
na_cl
发布了15 篇原创文章 · 获赞 7 · 访问量 471
私信
关注