linux 的目录结构:
/ : 根目录,最初的目录
/bin : 存放常用命令
/sbin : 存放常用命令,root用户有权限调用
/usr : 存放用户的文件, /usr/bin 和/usr/sbin 存放常用命令。
/boot : 存放系统启动相关文件
/dev : 存放设备文件,(光盘,鼠标,键盘等)
/etc : 存放系统配置文件
/home : 存放用户的家目录文件
/lib : 存放系统库文件,命令所依赖的库文件, 使用 ldd查看命令依赖哪些库,如 ldd /bin/ls
/lib64 : 存放系统库文件,命令所依赖的库文件
/media : 媒介目录,默认空
/mnt : 临时挂载目录,默认空
/opt : 空目录
/proc : 系统启动的进程的PID文件存放点
/root : root用户的家目录
/run : 存放进程所产生的临时文件,重启清空
/srv : 空目录,存放服务产生的文件
/sys : 存放系统内核相关文件
/tmp : 系统临时目录,
/var : /var/log 存放系统的日志
ls命令: 显示目录下的目录和文件
常用选项 :
-l :长格式显示文件详细信息,第一列 权限,第二列 inode号,第三列 所有者,第四列 所属组 , 第五列 文件大小,第六列 第七列 第八列 文件最近修改的日期时间,第九列 文件或目录的名称
[root@linux01 ~]# ls -l /
总用量 32
lrwxrwxrwx. 1 root root 7 3月 15 06:06 bin -> usr/bin
dr-xr-xr-x. 4 root root 4096 3月 15 06:17 boot
drwxr-xr-x 4 root root 32 5月 27 21:20 data
drwxr-xr-x 19 root root 3120 6月 1 23:41 dev
-h:人性化显示文件或目录的大小单位:
[root@linux01 ~]# ls -lh /
总用量 32K
lrwxrwxrwx. 1 root root 7 3月 15 06:06 bin -> usr/bin
dr-xr-xr-x. 4 root root 4.0K 3月 15 06:17 boot
drwxr-xr-x 4 root root 32 5月 27 21:20 data
drwxr-xr-x 19 root root 3.1K 6月 1 23:41 dev
-i :查看文件的iNode号:
[root@linux01 ~]# ls -i 1.txt
67560522 1.txt
-a :查看目录下所有文件和目录(包括隐藏的,名称前面加“.”为隐藏的):
[root@linux01 ~]# ls -al /
总用量 44
dr-xr-xr-x. 18 root root 4096 5月 31 23:08 .
dr-xr-xr-x. 18 root root 4096 5月 31 23:08 ..
-rw-r--r-- 1 root root 0 4月 23 20:54 .autorelabel
-rw------- 1 root root 8 5月 31 23:31 .bash_history
lrwxrwxrwx. 1 root root 7 3月 15 06:06 bin -> usr/bin
dr-xr-xr-x. 4 root root 4096 3月 15 06:17 boot
drwxr-xr-x 4 root root 32 5月 27 21:20 data
drwxr-xr-x 19 root root 3120 6月 1 23:41 dev
-t :以文件或目录的修改时间排序显示,时间越近越前:
[root@linux01 ~]# ls -lt /
总用量 32
drwxr-xr-x 22 root root 640 6月 1 23:41 run
drwxr-xr-x. 82 root root 8192 6月 1 23:41 etc
drwxr-xr-x 19 root root 3120 6月 1 23:41 dev
drwxrwxrwt. 8 root root 4096 6月 1 23:40 tmp
drwxr-xr-x. 20 root root 4096 6月 1 23:40 var
dr-xr-xr-x 13 root root 0 6月 1 23:40 sys
dr-xr-xr-x 348 root root 0 6月 1 23:40 proc
dr-xr-x---. 6 root root 4096 5月 30 01:15 root
drwxr-xr-x 4 root root 32 5月 27 21:20 data
drwxr-xr-x. 4 root root 30 5月 26 23:57 home
dr-xr-xr-x. 4 root root 4096 3月 15 06:17 boot
-d :只显示目录本身,不显示其子目录:
[root@linux01 ~]# ls -l /tmp/
总用量 0
srwxrwxrwx 1 mysql mysql 0 5月 27 23:28 mysql.sock
drwxr-xr-x 3 root root 17 5月 28 00:33 pear
[root@linux01 ~]#
[root@linux01 ~]# ls -ld /tmp/
drwxrwxrwt. 8 root root 4096 6月 1 23:40 /tmp/
文件类型:
通过 ls -l [文件名或目录名] ,长格式查看文件目录信息的第一列的第一位
-普通文件;d蓝色目录;b黄色块设备(磁盘);c黄色字符串设备(键盘,终端);l青色软链接;s粉色 socket文件(通信的)
alias :设置别名命令
直接alias 查看系统所有已经设置好的别名
设置别名格式:alias aa='ls -alht'
取消别名:unalias aa
[root@linux01 ~]# alias
alias cp='cp -i'
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 mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@linux01 ~]#
[root@linux01 ~]# alias zjy="ls -alht"
[root@linux01 ~]#
[root@linux01 ~]# alias
alias cp='cp -i'
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 mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
alias zjy='ls -alht'
[root@linux01 ~]#
[root@linux01 ~]# which zjy
alias zjy='ls -alht'
/usr/bin/ls
[root@linux01 ~]#
[root@linux01 ~]# zjy /
总用量 44K
drwxr-xr-x 22 root root 640 6月 1 23:41 run
drwxr-xr-x. 82 root root 8.0K 6月 1 23:41 etc
drwxr-xr-x 19 root root 3.1K 6月 1 23:41 dev
drwxrwxrwt. 8 root root 4.0K 6月 1 23:40 tmp
drwxr-xr-x. 20 root root 4.0K 6月 1 23:40 var
dr-xr-xr-x 13 root root 0 6月 1 23:40 sys
dr-xr-xr-x 349 root root 0 6月 1 23:40 proc
-rw------- 1 root root 8 5月 31 23:31 .bash_history
dr-xr-xr-x. 18 root root 4.0K 5月 31 23:08 .
dr-xr-xr-x. 18 root root 4.0K 5月 31 23:08 ..
dr-xr-x---. 6 root root 4.0K 5月 30 01:15 root
drwxr-xr-x 4 root root 32 5月 27 21:20 data
drwxr-xr-x. 4 root root 30 5月 26 23:57 home
-rw-r--r-- 1 root root 0 4月 23 20:54 .autorelabel
dr-xr-xr-x. 4 root root 4.0K 3月 15 06:17 boot
PS:
which :查看命令的路径,或者别名的详细