频道栏目
首页 > 资讯 > 其他 > 正文

系统目录结构、 ls命令 、文件类型 、 alias命令等实例介绍

18-06-05        来源:[db:作者]  
收藏   我要投稿

2.1/2.2 系统目录结构

每个用户都有用户家目录root用户、普通用户的密钥认证登陆,配置文件存放位置root用户:ls /root/.ssh/authorized_keys普通用户:ls /home/user1/.ssh/authorized_keys

tree命令安装: yum install -y treetree --help man treetree -L 2 / 显示根目录下2层目录 -L(指定目录最大的目录深度)

根目录下存放哪些文件

[root@wangshuang-01 ~]# ls /
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr

ls /sbin/ 存放root用户用的命令目录

ls /bin/ 存放普通用户用的命令目录

ls /boot/ 存放系统启动相关的文件ls /dev/ 存放linux系统设备文件ls /etc/ 存放配置文件ls /home/ 用户的家目录文件ls /lib/ 、/lib64/ 存放系统的库文件 ldd /bin/ls 查看库文件ls /media/ 媒介目录,默认空的,插u盘自动放该目录下ls /mnt/ 临时挂载目录,默认空的,新增硬盘挂载该目录下ls /opt/ 默认空的,oracle安装在该目录下ls /proc/ 系统启动的进程,生成pid ls /proc/1/ 进程1 下文件

ls /run/ 进程产生的临时文件,重启会消失ls /srv/ 服务产生的文件ls /sys/ 系统内核相关的文件ls /tmp/ 系统的临时文件ls /usr/ 用户的文件ls /var/log 存日志ls /var/log/message/系统日志ls /var/run/

2.3 ls命令 (ls -l i a t h d )

ls -l  /root/   列出文件的详细信息
-rw-------. 1 root root 1418 3月  26 01:26 anaconda-ks.cfg
-rw-r--r--. 1 root root    0 5月  30 22:36 mtu

第一列:权限第二列:有多少文件使用相同的inodels -i 文件名 查具体那个inode

[root@wangshuang-01 ~]# ls -i anaconda-ks.cfg
33582978 anaconda-ks.cfg

第三列:所有者第四列:所属组第五列:文件大小第六列:文件创建时间第七列:文件名ls -h 自动变换文件的单位

[root@wangshuang-01 ~]# ls -lh /root/
总用量 4.0K
-rw-------. 1 root root 1.4K 3月  26 01:26 anaconda-ks.cfg
-rw-r--r--. 1 root root    0 5月  30 22:36 mtu

ls -a 查看目录下隐藏文件或目录

root@wangshuang-01 ~]# ls -al
总用量 32
dr-xr-x---.  3 root root  158 5月  30 22:36 .
dr-xr-xr-x. 17 root root  224 3月  26 01:25 ..
-rw-------.  1 root root 1418 3月  26 01:26 anaconda-ks.cfg
-rw-------.  1 root root 8080 6月   3 21:47 .bash_history
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
-rw-r--r--.  1 root root    0 5月  30 22:36 mtu
drwx------.  2 root root   48 5月  31 00:26 .ssh
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc

ls -lta 按文件创建时间排序

[root@wangshuang-01 ~]# ls -alt
总用量 32
-rw-------.  1 root root 8080 6月   3 21:47 .bash_history
drwx------.  2 root root   48 5月  31 00:26 .ssh
-rw-r--r--.  1 root root    0 5月  30 22:36 mtu
dr-xr-x---.  3 root root  158 5月  30 22:36 .
-rw-------.  1 root root 1418 3月  26 01:26 anaconda-ks.cfg
dr-xr-xr-x. 17 root root  224 3月  26 01:25 ..
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc

ls -ld 只列出文件本身

[root@wangshuang-01 ~]# ls -ld /
dr-xr-xr-x. 17 root root 224 3月  26 01:25 /

ls -l 列出子文件子目录

[root@wangshuang-01 ~]# ls -l /
总用量 20
lrwxrwxrwx.   1 root root    7 3月  26 01:18 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 3月  26 01:26 boot
drwxr-xr-x.  19 root root 3240 6月   3 09:13 dev
drwxr-xr-x.  74 root root 8192 6月   3 21:07 etc
drwxr-xr-x.   7 root root   74 4月   6 21:16 home
lrwxrwxrwx.   1 root root    7 3月  26 01:18 lib -> usr/lib
lrwxrwxrwx.   1 root root    9 3月  26 01:18 lib64 -> usr/lib64
drwxr-xr-x.   2 root root    6 11月  5 2016 media
drwxr-xr-x.   2 root root    6 11月  5 2016 mnt
drwxr-xr-x.   2 root root    6 11月  5 2016 opt
dr-xr-xr-x. 101 root root    0 6月   3 09:13 proc
dr-xr-x---.   3 root root  158 5月  30 22:36 root
drwxr-xr-x.  23 root root  620 6月   3 09:13 run
lrwxrwxrwx.   1 root root    8 3月  26 01:18 sbin -> usr/sbin
drwxr-xr-x.   2 root root    6 11月  5 2016 srv
dr-xr-xr-x.  13 root root    0 6月   3 09:13 sys
drwxrwxrwt.  13 root root 4096 6月   3 10:35 tmp
drwxr-xr-x.  13 root root  155 3月  26 01:18 usr
drwxr-xr-x.  19 root root  267 3月  26 01:27 var

2.4 文件类型

[root@wangshuang-01 ~]# ls -la
总用量 32
dr-xr-x---.  3 root root  158 5月  30 22:36 .
dr-xr-xr-x. 17 root root  224 3月  26 01:25 ..
-rw-------.  1 root root 1418 3月  26 01:26 anaconda-ks.cfg
-rw-------.  1 root root 8080 6月   3 21:47 .bash_history
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout

第一列第一位:表示文件的类型d 目录- 普通文件,文本文档、二进制c 字符串设备,鼠标、键盘l 软连接 --相当于window快捷方式b块设备 ,光驱、光盘、磁盘s socket文件

2.5 alias命令alias 是由命令和选项组合形成新命令

which ls 
    alias ls='ls --color=auto'
    /usr/bin/ls
which ll
    alias ll='ls -l --color=auto'
    /usr/bin/ls

查看系统中有哪些命令有别名

[root@wangshuang-01 ~]# 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@wangshuang-01 ~]# alias haha='ls -alt'
[root@wangshuang-01 ~]# haha
总用量 32
-rw-------. 1 root root 8080 6月  3 21:47 .bash_history
drwx------. 2 root root  48 5月 31 00:26 .ssh
-rw-r--r--. 1 root root  0 5月 30 22:36 mtu
dr-xr-x---. 3 root root 158 5月 30 22:36 .
-rw-------. 1 root root 1418 3月 26 01:26 anaconda-ks.cfg
dr-xr-xr-x. 17 root root 224 3月 26 01:25 ..
-rw-r--r--. 1 root root  18 12月 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc
-rw-r--r--. 1 root root 100 12月 29 2013 .cshrc
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc

取消别名:

[root@wangshuang-01 ~]# unalias haha
[root@wangshuang-01 ~]# haha
-bash: haha: 未找到命令
相关TAG标签
上一篇:.NET Core 3支持Windows桌面应用的新特性介绍
下一篇:Linux ubuntu16.04系统下vim的安装与配置介绍
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站