centos 7 系统目录结构、ls命令、文件类型、alias命令

linux系统的目录结构

tree命令

在Linux系统中,使用tree命令能够比较直观的看出系统的目录结构。在最小化安装的系统中是没有tree命令的,须要运行yum install -y tree 命令来安装tree命令。node

[root@localhost ~]# tree /
-bash: tree: 未找到命令
[root@localhost ~]# yum install -y tree

安装完tree命令就能够直接使用了,好比咱们要列出/boot下的目录结构,就可使用tree /boot命令实现linux

[root@localhost ~]# tree /boot
/boot
├── config-3.10.0-123.el7.x86_64
├── grub
│   └── splash.xpm.gz
├── grub2
│   ├── device.map
│   ├── fonts
│   │   └── unicode.pf2
│   ├── grub.cfg
│   ├── grubenv
│   ├── i386-pc
│   │   ├── acpi.mod
│   │   ├── adler32.mod
│   │   ├── affs.mod

tree命令能够利用一些参数来实现特定的显示结果:bash

  • tree -C 显示颜色
  • tree -L 后面跟数字,显示深度为多少
  • tree -f 显示文件全路径 -tree -help 帮助手册

man命令

man 命令能够打开其余命令的手册,好比咱们要查看tree命令的用法,可使用man tree 来查看。日志

系统目录结构

/root ,/home 目录

/root 目录就是超级用户root的家目录,/home目录是存放普通用户家目录的目录。code

/bin , /sbin , /usr/bin , /usr/sbin 目录

/bin , /sbin , /usr/bin , /usr/sbin 目录是存放命令的目录,/sbin/目录是存放超级用户命令的目录,普通用户没法直接调用该目录下的命令。/bin 、/usr/bin是存放普通用户的经常使用命令的目录。排序

/boot 目录

/boot目录是存放系统启动相关的关键文件的目录 ,例如:grub 、grub 2等文件接口

/dev 目录

/dev目录是Linux系统里特有的设备目录,例如鼠标,键盘,光驱 等设备文件。进程

/etc 目录

/etc 目录是Linux系统中存放配置文件的目录,好比网卡配置文件unicode

/lib , /lib64目录

/lib , /lib64目录是Linux系统存放库文件的目录。不少命令都会依赖库文件,库文件相似于Windows下的.dll 的文件。可使用ldd +命令绝对路径,能够查看该命令所依赖的库文件源码

[root@localhost ~]# ldd /bin/ls
	linux-vdso.so.1 =>  (0x00007fff5d7fe000)

/media目录

/media=媒介目录,通常为空,能够挂载光驱等到这个目录

/mnt 目录

/mnt/=临时挂载目录,默认为空;也能够挂载光驱

/proc目录

/proc=系统启动的一些进程,生成PID进程

/run目录

/run=存放一些进程产生的临时文件

/srv目录

/srv=存放服务产生的文件

/sys目录

/sys=存放系统内核相关的文件

/tmp目录

/tmp=存放系统的临时目录

/usr目录

/usr=存放用户的一些文件

/var目录

/var=存放日志文件

ls命令

ls命令是最经常使用的命令之一,它的经常使用参数信息以下:

  • l 把文件的详细信息列出来

  • i 查看文件的Inode号

  • lh 更清楚的显示文件的大小

  • la 能够查看到目录下的隐藏文件

  • lt 按时间排序时间越早的排的越下面

  • ld 只列出目录自己 ,不加 d 会把目录下面的目录和文件都列出来

alias 命令

alias 命令能够查看系统中哪些命令作过别名

[root@localhost ~]# 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还能够自定义命令别名:

[root@localhost ~]# alias lcc=ls
[root@localhost ~]# lcc /root
anaconda-ks.cfg
[root@localhost ~]# lcc /boot
config-3.10.0-123.el7.x86_64  initramfs-0-rescue-bbcff2ae8dce4e4999a6cf3ad595fc62.img  initrd-plymouth.img               vmlinuz-0-rescue-bbcff2ae8dce4e4999a6cf3ad595fc62
grub                          initramfs-3.10.0-123.el7.x86_64.img                      symvers-3.10.0-123.el7.x86_64.gz  vmlinuz-3.10.0-123.el7.x86_64
grub2                         initramfs-3.10.0-123.el7.x86_64kdump.img                 System.map-3.10.0-123.el7.x86_64

which命令能够查看命令的原名是什么

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

文件类型

linux下还能够用颜色来表示文件类型:   

  • 蓝色文件------------ 目录   
  • 白色文件------------ 通常性文件,如文本文件,配置文件,源码文件等   
  • 浅蓝色文件---------- 连接文件,主要是使用ln命令创建的文件   
  • 绿色文件------------ 可执行文件,可执行的程序

如今使用 ls -l 命令,查看详细信息格式的文件列表

[root@localhost ~]# ls -l /boot
总用量 57204
-rw-r--r--. 1 root root   122059 6月  30 2014 config-3.10.0-123.el7.x86_64
drwxr-xr-x. 2 root root       26 5月  29 00:50 grub
drwxr-xr-x. 6 root root      104 5月  29 00:53 grub2
-rw-r--r--. 1 root root 25082768 5月  29 00:52 initramfs-0-rescue-bbcff2ae8dce4e4999a6cf3ad595fc62.img
-rw-r--r--. 1 root root  9772421 5月  29 00:53 initramfs-3.10.0-123.el7.x86_64.img
-rw-r--r--. 1 root root 10128090 5月  29 00:58 initramfs-3.10.0-123.el7.x86_64kdump.img
-rw-r--r--. 1 root root   589618 5月  29 00:51 initrd-plymouth.img
-rw-r--r--. 1 root root   228562 6月  30 2014 symvers-3.10.0-123.el7.x86_64.gz
-rw-------. 1 root root  2840084 6月  30 2014 System.map-3.10.0-123.el7.x86_64
-rwxr-xr-x. 1 root root  4902656 5月  29 00:52 vmlinuz-0-rescue-bbcff2ae8dce4e4999a6cf3ad595fc62
-rwxr-xr-x. 1 root root  4902656 6月  30 2014 vmlinuz-3.10.0-123.el7.x86_64

每一行都有七组字符,分别表示 权限、文件数、归属用户、归属群组、文件大小、建立日期、文件名称

第一组的第一个字符分别表明:   

  • d =文件夹   
  • -=普通文件   
  • l =连接   
  • b =块设备文件   
  • c =字符设备文件  
  • s =套接口文件
相关文章
相关标签/搜索