ls命令+文件类型+别名(alias)

一.ls命令的用法
1.    ls -l   列出文件的详细信息
[root@lx02 ~]# ls -l
总用量 4
-rw-------. 1 root root 1418 11月  9 14:16 anaconda-ks.cfg 
2.    ls -i   列出文件的inode号,如果两个文件使用相同的inode号,那么意味着这两个文件在磁盘上存放的数据块是一样的,这是一个文件
[root@lx02 ~]# ls -i
16797762 anaconda-ks.cfg        #167797762就是 anaconda-ks.cfg  这个文件的inode号
3.    ls -a   列出全部的文件,包括隐藏文件,"."开头的就是隐藏文件
       每一个目录下都有一个"."和".."目录,"."表示当前目录,".."表示上一级目录
[root@lx02 ~]# ls -la
总用量 28
dr-xr-x---.  3 root root  147 12月 13 09:40 .
dr-xr-xr-x. 17 root root  224 12月 14 10:03 ..
-rw-------.  1 root root 1418 11月  9 14:16 anaconda-ks.cfg
-rw-------.  1 root root 2145 12月 14 20:33 .bash_history            # .开头的就是隐藏文件
4.     ls -t   按照时间从早到晚进行排序,而不是文件名
[root@lx02 ~]# ls -lat
总用量 28
-rw-------.  1 root root  2427  12月 15 09:58 .bash_history
drwx------.  2 root root   80    12月 14 17:40 .ssh
dr-xr-xr-x. 17 root root  224   12月 14 10:03 ..
dr-xr-x---.  3 root root  147    12月 13 09:40 .
-rw-------.  1 root root 1418  11月  9 14:16 anaconda-ks.cfg
-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
5.    ls -d    只列出目录本身,目录里的文件不列出来
[root@lx02 ~]# ls -ld /root/
dr-xr-x---. 3 root root 147 12月 13 09:40 /root/
6.   ls -h    显示文件大小时,自动变换单位
[root@lx02 ~]# ls -lh
总用量 4.0K
-rw-------. 1 root root 1.4K 11月  9 14:16 anaconda-ks.cfg
  
 二.文件类型
  
文件的读写权限第一列表示文件的类型,
d   directory,表示目录
-  表示普通文件,ASCII(文本文件)可以直接使用cat查看,binary(二进制文件)和 date(数据格式文件)是特殊格式的文件,不能直接cat查看
c    character,表示字符串设备,键盘鼠标等
l     link,表示软连接文件
b    block,表示块设备,比如磁盘和光盘
s    socket文件,进程之间用来通信的


三.  alias命令
1. which : PATH 变量指定的路径中搜索某个系统命令的位置并且返回第一个搜索结果
    which ls可以看到ls是一个别名,真正的命令是 ls --color=auto,自动加上颜色,并且命令的文件地址在 /usr/bin/ls
       有的命令是由别名,有的命令是没有的
    alias是一个命令加上选择组合而成的新的命令
[root@lx02 ~]# which ls
alias ls='ls --color=auto'
    /usr/bin/ls
 如果不行使用别名,直接 /usr/bin/ls也是同样可以使用的,这样的不带颜色:
[root@lx02 ~]# /usr/bin/ls  /
bin   dev  home  lib64    mnt  proc  run     srv  tmp  var
boot  etc  lib     media    opt  root  sbin  sys  usr

2.alisa 可以查看系统有哪些命令是别名
[root@lx02 ~]# 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'

3.PATH  环境变量,echo $PATH可以查看环境变量的内容
[root@lx02 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

4.使用alias命令做一个别名
[root@lx02 ~]# alias lx='ls -lah'                                      #给ls -lah设置一个别名:lx
[root@lx02 ~]# lx                                                              #可以直接运行lxmingl
总用量 28K
dr-xr-x---.  3 root root  147 12月 13 09:40 .
dr-xr-xr-x. 17 root root  224 12月 14 10:03 ..
-rw-------.  1 root root 1.4K 11月  9 14:16 anaconda-ks.cfg
-rw-------.  1 root root 2.4K 12月 15 09:58 .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
drwx------.  2 root root   80 12月 14 17:40 .ssh
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
[root@lx02 ~]# which lx                                            #查看lx命令  
alias lx='ls -lah'
    /usr/bin/ls


5.取消别名,使用unalias取消别名
[root@lx02 ~]# unalias lx
[root@lx02 ~]# lx
-bash: lx: 未找到命令


四. inode扩展:
文件储存在硬盘上,硬盘的最小存储单位叫做"扇区"(Sector)。每个扇区储存512字节(相当于0.5KB)。
操作系统读取硬盘的时候,不会一个个扇区地读取,这样效率太低,而是一次性连续读取多个扇区,即一次性读取一个"块"(block)。这种由多个扇区组成的"块",是文件存取的最小单位。"块"的大小,最常见的是4KB,即连续八个 sector组成一个 block。
文件数据都储存在"块"中,那么很显然,我们还必须找到一个地方储存文件的元信息,比如文件的创建者、文件的创建日期、文件的大小等等。这种储存文件元信息的区域就叫做inode,中文译名为"索引节点"。
每一个文件都有对应的inode,里面包含了与该文件有关的一些信息。
inode 包含文件的元信息,具体来说有以下内容:
文件的字节数
文件拥有者的User ID
文件的Group ID
文件的读、写、执行权限
文件的时间戳,共有三个:ctime指inode上一次变动的时间,mtime指文件内容上一次变动的时间,atime指文件上一次打开的时间  
链接数,即有多少文件名指向这个inode/ 文件数据block的位置




  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值