2.1/2.2 系统目录结构 2.3 ls命令 2.4 文件类型 2.5 alias命令

1、系统目录结构

#ls list的简写

#ls /root/

#ls /root/.ssh/authorizde_keys 在root的家目录下

#useradd champin 用户的文件目录在home下

ssh 的配置文件 /etc/ssh/sshd_config

根下面都有那些目录

[root@cham3 ~]# tree -L 2 / 最大指定2层

bin 和 sbin(superbin) 都是存放所有命令文件的目录。区别为。 sbin下面都是root用户用的,bin下面都是普通用户用的root也能用

boot 目录下是系统启动相关的一些文件。如grup 单用户模式就是进入grup模式, 更改了grupd的一些参数

dev 是Linux系统特有的设备文件,如光盘 硬盘,鼠标 ,键盘

etc 系统的配置文件所在的目录 如:/etc/sysconfig/network-scripts/ifcfg-ens33,包括/etc/ssh/sshd_config

home 是用户的家目录

lib以及lib64 系统的库文件 库文件类似于Windows的.dll文件

media 媒介目录,默认是空的,比如插入一个u盘会挂载到media目录下

mut 是一个空目录,是一个临时挂在的目录。比如光驱,新挂在的硬盘,在mut下面

opt 是一个空目录 orecle的一些文档 会把orecle安装在opt下面

proc是一些系统启动的进程,它会生成一个pid 每一个进程都有一个目录

root 是root用户的家目录

run 是一进程产生临时文件,一重启就会消失的存在目录

srv是空的文件,service的缩写。这个目录下面会存在service产生的一些文件

sys会存一些系统内核相关的文件,平时是不会去动的,不用太关注

tmp是系统的临时目录,它权限很大,任何一个用户都可以去修改东西

usr用户的一些文件放在这个目录。很重要的目录

var会存一些日志,系统相关的日志全部存在/var/log/messages

var/run/

重要的。

usr/bin/  usr/sbin/     /bin/ /sbin/   /etc/   /var/   /usr/local/

2、ls命令以及文件类型

#ls -l 会显示文件的详细信息

#ls -la 会查看目录下面所有的隐藏文件或者目录,. 点 开头的都是隐藏文件或者目录

-l详细信息

-i inode号

-a 全部包括隐藏的

-t 按时间顺序排序

-h 在-l的时候,显示文件大小的时候可以自由的变换单位

-d 列目录的时候只列目录本身


 

[root@cham3 ~]# ls -l

总用量 4

-rw-------. 1 root root 1422 10月 19 07:00 anaconda-ks.cfg

[root@cham3 ~]# ls -i

33574987 anaconda-ks.cfg

[root@cham3 ~]# ls -i /

95 bin 16777281 etc 82 lib64 33584771 opt 1227 run 1 sys 50331713 var

64 boot 50331740 home 83 media 1 proc 99 sbin 16777288 tmp

1026 dev 98 lib 16777681 mnt 33574977 root 50331741 srv 33584746 usr

[root@cham3 ~]# ls -l /

总用量 16

lrwxrwxrwx. 1 root root 7 10月 19 06:56 bin -> usr/bin

dr-xr-xr-x. 4 root root 4096 10月 19 07:02 boot

drwxr-xr-x 19 root root 3220 10月 19 11:54 dev

drwxr-xr-x. 77 root root 8192 10月 20 12:47 etc

drwxr-xr-x. 3 root root 21 10月 19 20:22 home

lrwxrwxrwx. 1 root root 7 10月 19 06:56 lib -> usr/lib

lrwxrwxrwx. 1 root root 9 10月 19 06:56 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 112 root root 0 10月 19 11:53 proc

dr-xr-x---. 3 root root 147 10月 19 12:44 root

drwxr-xr-x 21 root root 580 10月 19 20:26 run

lrwxrwxrwx. 1 root root 8 10月 19 06:56 sbin -> usr/sbin

drwxr-xr-x. 2 root root 6 11月 5 2016 srv

dr-xr-xr-x 13 root root 0 10月 19 11:53 sys

drwxrwxrwt. 8 root root 212 10月 19 14:10 tmp

drwxr-xr-x. 13 root root 155 10月 19 06:56 usr

drwxr-xr-x. 19 root root 267 10月 19 11:53 var

[root@cham3 ~]# ls -lh anaconda-ks.cfg

-rw-------. 1 root root 1.4K 10月 19 07:00 anaconda-ks.cfg

[root@cham3 ~]# ls -la

总用量 28

dr-xr-x---. 3 root root 147 10月 19 12:44 .

dr-xr-xr-x. 17 root root 244 10月 18 23:30 ..

-rw-------. 1 root root 1422 10月 19 07:00 anaconda-ks.cfg

-rw-------. 1 root root 1651 10月 19 20:33 .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 10月 19 13:01 .ssh

-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc

[root@cham3 ~]# ls -ld /root

dr-xr-x---. 3 root root 147 10月 19 12:44 /root

[root@cham3 ~]# ls -i /root/

33574987 anaconda-ks.cfg

[root@cham3 ~]# ls -i .

33574987 anaconda-ks.cfg

[root@cham3 ~]# ls -i .ssh/..

33574987 anaconda-ks.cfg

[root@cham3 ~]#

[root@cham3 ~]#

[root@cham3 ~]#

[root@cham3 ~]# ls -a

. .. anaconda-ks.cfg .bash_history .bash_logout .bash_profile .bashrc .cshrc .ssh .tcshrc

[root@cham3 ~]# ls -lta

总用量 28

-rw-------. 1 root root 1651 10月 19 20:33 .bash_history

drwx------ 2 root root 80 10月 19 13:01 .ssh

dr-xr-x---. 3 root root 147 10月 19 12:44 .

-rw-------. 1 root root 1422 10月 19 07:00 anaconda-ks.cfg

dr-xr-xr-x. 17 root root 244 10月 18 23:30 ..

-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@cham3 ~]# ls -la

总用量 28

dr-xr-x---. 3 root root 147 10月 19 12:44 .

dr-xr-xr-x. 17 root root 244 10月 18 23:30 ..

-rw-------. 1 root root 1422 10月 19 07:00 anaconda-ks.cfg

-rw-------. 1 root root 1651 10月 19 20:33 .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 10月 19 13:01 .ssh

-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc

[root@cham3 ~]# ls -d

.

[root@cham3 ~]# ls -d /rrot/

ls: 无法访问/rrot/: 没有那个文件或目录

[root@cham3 ~]# ls -d /root/

/root/

[root@cham3 ~]# ls -l /root/

总用量 4

-rw-------. 1 root root 1422 10月 19 07:00 anaconda-ks.cfg

[root@cham3 ~]# ls -ld /root/

dr-xr-x---. 3 root root 147 10月 19 12:44 /root/

[root@cham3 ~]# ls -d /root

/root

[root@cham3 ~]# ls -d /

/

[root@cham3 ~]# ls -l /

总用量 16

lrwxrwxrwx. 1 root root 7 10月 19 06:56 bin -> usr/bin

dr-xr-xr-x. 4 root root 4096 10月 19 07:02 boot

drwxr-xr-x 19 root root 3220 10月 19 11:54 dev

drwxr-xr-x. 77 root root 8192 10月 20 12:47 etc

drwxr-xr-x. 3 root root 21 10月 19 20:22 home

lrwxrwxrwx. 1 root root 7 10月 19 06:56 lib -> usr/lib

lrwxrwxrwx. 1 root root 9 10月 19 06:56 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 113 root root 0 10月 19 11:53 proc

dr-xr-x---. 3 root root 147 10月 19 12:44 root

drwxr-xr-x 21 root root 580 10月 19 20:26 run

lrwxrwxrwx. 1 root root 8 10月 19 06:56 sbin -> usr/sbin

drwxr-xr-x. 2 root root 6 11月 5 2016 srv

dr-xr-xr-x 13 root root 0 10月 19 11:53 sys

drwxrwxrwt. 8 root root 212 10月 19 14:10 tmp

drwxr-xr-x. 13 root root 155 10月 19 06:56 usr

drwxr-xr-x. 19 root root 267 10月 19 11:53 var

[root@cham3 ~]# ls-ld /

-bash: ls-ld: 未找到命令

[root@cham3 ~]# ls -ld /

dr-xr-xr-x. 17 root root 244 10月 18 23:30 /

[root@cham3 ~]#

[root@cham3 ~]#

[root@cham3 ~]# ll

总用量 4

-rw-------. 1 root root 1422 10月 19 07:00 anaconda-ks.cfg

[root@cham3 ~]# 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@cham3 ~]# which ll

alias ll='ls -l --color=auto'

/usr/bin/ls

[root@cham3 ~]# /bin/ls /

bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

[root@cham3 ~]# which ls

alias ls='ls --color=auto'

/usr/bin/ls

[root@cham3 ~]#

文件类型

- 普通文件
d =directory 目录文件   ,d表示蓝色的dr-xr-x这样的是目录 directory list
c 串行端口设备文件(eg:键盘、鼠标) c表示黄色的 字符串设备文件,如鼠标键盘
b =block 块文件
s =socket 套接文件,用于进程间通信  ,s表示粉色的 是用来通信的,进程和进程之间的通信 TCP/IP

绿色的编译过得文件无法打开

-rw的是文本文件,可以用#ca打开

c表示黄色的 字符串设备文件,如鼠标键盘

b都是块设备 如光盘,磁盘

l表示青色的是软连接文件 类似windows的快捷方式

d -  c  b  s  l

3、alias which命令

alias 设置指令的别名
语法: alias [别名]=[指令名称]
用法:

# alias    罗列出系统所有设有别名的指令
# alias adai=‘ls -lha’  即命名‘ls -lha’的别名为adai  
# unalias adai   取消adai的别名设置

注:alias的效力仅限于该次登录的操作,重启后失效。 若要使得该别名永久生效,需要编辑 .profile 或 .cshrc文件

别名怎么用

[root@cham3 ~]#

[root@cham3 ~]# ll

总用量 4

-rw-------. 1 root root 1422 10月 19 07:00 anaconda-ks.cfg

[root@cham3 ~]# 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@cham3 ~]# which ll

alias ll='ls -l --color=auto'

/usr/bin/ls

[root@cham3 ~]# /bin/ls /

bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

[root@cham3 ~]# which ls

alias ls='ls --color=auto'

/usr/bin/ls

[root@cham3 ~]# ls ll

ls: 无法访问ll: 没有那个文件或目录

[root@cham3 ~]# which ls

alias ls='ls --color=auto'

/usr/bin/ls

[root@cham3 ~]# which ll

alias ll='ls -l --color=auto'

/usr/bin/ls

[root@cham3 ~]# which man

/usr/bin/man

[root@cham3 ~]# which yum

/usr/bin/yum

[root@cham3 ~]# which ls

alias ls='ls --color=auto'

/usr/bin/ls

[root@cham3 ~]# 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@cham3 ~]# ehco $PATH

-bash: ehco: 未找到命令

[root@cham3 ~]# echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

[root@cham3 ~]# which mv

alias mv='mv -i'

/usr/bin/mv

[root@cham3 ~]# 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@cham3 ~]# alias cham

-bash: alias: cham: 未找到

[root@cham3 ~]# cham

-bash: cham: 未找到命令

[root@cham3 ~]# alias cham='ls -lha'

[root@cham3 ~]# cham

总用量 28K

dr-xr-x---. 3 root root 147 10月 19 12:44 .

dr-xr-xr-x. 17 root root 244 10月 18 23:30 ..

-rw-------. 1 root root 1.4K 10月 19 07:00 anaconda-ks.cfg

-rw-------. 1 root root 1.7K 10月 19 20:33 .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 10月 19 13:01 .ssh

-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc

[root@cham3 ~]# wich aming

-bash: wich: 未找到命令

[root@cham3 ~]# which cham

alias cham='ls -lha'

/usr/bin/ls

[root@cham3 ~]# unalias cham

[root@cham3 ~]# cham

-bash: cham: 未找到命令

[root@cham3 ~]#

猜你喜欢

转载自my.oschina.net/u/3708120/blog/1650259