一,系统目录

1、ls   -->list    显示当前目录下的目录和文件

[root@localhost ~]# ls
123 dirb error.log newdir splash.xpm.gz 公共 文档
aak down ll ok.log t1.sh 模板 音乐
aming error my.cnf outputfile test1 视频 桌面
dira error1 mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz rsync users.csv 图片

2. ls /  列出根目录下的文件和目录。

root@localhost ~]# ls /
1.txt boot dev home lib64 mnt proc run srv test usr
bin data etc lib media opt root sbin sys tmp var

3、目录结构。tree 以树形显示目录结构 ,如果没有,需要安装

yum install -y tree

[root@localhost ~]# tree
.
├── my.cnf
├── mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
├── newdir
│   └── 1.txt
├── outputfile
├── rsync
│   ├── test1
│   │   ├── 1.sh -> /root/1.sh
│   │   ├── 2
│   │   ├── 3
│   │   └── test.txt
│   └── test2
│   ├── 1.sh -> /root/1.sh
│   ├── 2
│   ├── 3
│   └── text.txt

4、tree 的用法  man tree

TREE(1) General Commands Manual TREE(1)

NAME
tree - list contents of directories in a tree-like format.

SYNOPSIS
tree [-acdfghilnpqrstuvxACDFQNSUX] [-L level [-R]] [-H baseHREF] [-T title] [-o filename]
[--nolinks] [-P pattern] [-I pattern] [--inodes] [--device] [--noreport] [--dirsfirst] [--ver‐
sion] [--help] [--filelimit #] [--si] [--prune] [--du] [--timefmt format] [directory ...]

5、home 普通用户家目录,存放普通用户的文件等 ,root root家目录

[root@localhost ~]# ls /home
apple mysql nihao rich test test3 tim user user1 user12 user13 user14 win

6、bin sbin 存放命令的目录,bin 存放普通用户命令 sbin存放root用户命令。

7、boot 存放一些系统启动的相关文件,如标红的grub文件

[root@localhost ~]# ls /boot/
config-3.10.0-693.el7.x86_64
efi
grub
grub2
initramfs-0-rescue-8d457b4879a04777b52a8993591a7ae8.img
initramfs-3.10.0-693.el7.x86_64.img
initrd-plymouth.img
symvers-3.10.0-693.el7.x86_64.gz
System.map-3.10.0-693.el7.x86_64
vmlinuz-0-rescue-8d457b4879a04777b52a8993591a7ae8
vmlinuz-3.10.0-693.el7.x86_64

8、etc  存放系统配置文件,dev 存放设备文件,光盘,内存等

9、lib lib64 存放系统库文件,ldd /bin/ls 查看库依赖关系

[root@localhost ~]# ldd /bin/ls
linux-vdso.so.1 => (0x00007ffdc575c000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f3d30670000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007f3d3046b000)
libacl.so.1 => /lib64/libacl.so.1 (0x00007f3d30261000)
libc.so.6 => /lib64/libc.so.6 (0x00007f3d2fe9e000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f3d2fc3c000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f3d2fa37000)
/lib64/ld-linux-x86-64.so.2 (0x0000562575dce000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007f3d2f832000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f3d2f616000)

10、media  媒介存放,mnt 临时挂载点

11、run 进程产生的文件存放地,重启消失,srv 服务产生的文件存放地, tmp 系统临时目录,usr 用户命令文件存放地

12、var  存放log的地方

[root@localhost ~]# ls /var
account cache db games kerberos local log mysql opt run target yp
adm crash empty gopher lib lock mail nis preserve spool tmp

二、ls 的常见用法

1、ls -l  列出当前目录或文件的详细信息,第一列权限,第二列有几个文件存在相同Inode,第三列所有者,第四列所属组,第五列所占大小,其他不再叙述,一看便知。

[root@localhost ~]# ls -l
总用量 626120
-rw-r--r--. 1 root root 570 10月 17 18:39 my.cnf
-rw-r--r--. 1 root root 641127384 10月 17 18:20 mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
drwxr-xr-x. 2 root root 19 12月 12 14:33 newdir
-rw-r--r--. 1 root root 0 10月 24 16:47 outputfile
drwxr-xr-x. 4 root root 32 10月 16 14:17 rsync
-rw-r--r--. 1 root root 1350 10月 20 17:06 splash.xpm.gz
-rw-r--r--. 1 root root 264 10月 18 11:12 t1.sh
drwxr-xr-x. 3 root root 54 12月 15 13:21 test1

2、ls -i  查看inode 

[root@localhost ~]# ls -i
35316793 my.cnf 33698595 t1.sh 33666745 图片
52611831 mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz 17481420 test1 2457464 文档

3、ls -lah ,-a 显示出所有的包括隐藏文件。-h 已合适的单位显示大小。带点的都为隐藏文件。

[root@localhost ~]# ls -lha
总用量 612M

dr-xr-x---. 21 root root 4.0K 12月 15 21:28 .
dr-xr-xr-x. 19 root root 282 12月 14 22:02 ..
-rw-r--r--. 1 root root 12K 12月 14 15:15 .1.txt.swp
-rw-------. 1 root root 14K 12月 15 20:38 .bash_history

4、ls -lt   -t 以时间排序

[root@localhost ~]# ls -lt,观察时间
总用量 626120
drwxr-xr-x. 3 root root 54 12月 15 13:21 test1
drwxr-xr-x. 2 root root 19 12月 12 14:33 newdir
-rw-r--r--. 1 root root 53 10月 27 11:21 users.csv
-rw-r--r--. 1 root root 0 10月 24 16:47 outputfile
-rw-r--r--. 1 root root 1350 10月 20 17:06 splash.xpm.gz
-rw-r--r--. 1 root root 264 10月 18 11:12 t1.sh

5、ls -ld  -d 只列目录本身,对比来看

[root@localhost ~]# ls -l newdir/
总用量 0
-rw-r--r--. 1 root root 0 12月 12 14:33 1.txt
[root@localhost ~]# ls -ld newdir/
drwxr-xr-x. 2 root root 19 12月 12 14:33 newdir/

6、ll  = ls -l   别名

三、文件类型

1、d 目录  - 文件  l 链接文件  c 设备文件 s 套接字文件,用于进程通信

[root@localhost ~]# ls -la
总用量 626208
dr-xr-x---. 21 root root 4096 12月 15 21:28 .
dr-xr-xr-x. 19 root root 282 12月 14 22:02 ..
-rw-r--r--. 1 root root 12288 12月 14 15:15 .1.txt.swp

lrwxrwxrwx. 1 root root 25 12月 15 09:38 initctl -> /run/systemd/initctl/fifo
drwxr-xr-x. 4 root root 300 12月 15 09:38 input
crw-r--r--. 1 root root 1, 11 12月 15 09:38 kmsg
srw-rw-rw-. 1 root root 0 12月 15 09:38 log

四、alias  别名

1、使用 which 查看 别名, ls 加了颜色属性, ll 相当于ls -l    

[root@localhost ~]# which ls
alias ls='ls --color=auto'
/usr/bin/ls
[root@localhost ~]# which ll
alias ll='ls -l --color=auto'
/usr/bin/ls
[root@localhost ~]# which man
/usr/bin/man

2、系统下查看那些有别名。 alias

[root@localhost ~]# alias
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

3、自己命名别名和取消别名

[root@localhost ~]# alias tarc='tar -czvf'
[root@localhost ~]# tarc newdir.tar.gz newdir/
newdir/
newdir/1.txt
[root@localhost ~]# unalias tarc
[root@localhost ~]# tarc newdir.tar.gz newdir/
bash: tarc: 未找到命令...
相似命令是: 'tar'

 

 

 



 

posted on 2017-12-15 22:55  天梭  阅读(115)  评论(0编辑  收藏  举报