5 系统目录结构 ls 文件类型 alias

来源:互联网 发布:windows thin pc安装 编辑:程序博客网 时间:2024/05/17 23:42
2.1/2.2 系统目录结构
yum -y install tree
tree - list contents of directories in a tree-like format.
-L level
Max display depth of the directory tree.
# tree -L 2 /
/
├── bin -> usr/bin
├── boot
│   ├── config-3.10.0-693.el7.x86_64
│   ├── efi
│   ├── grub
│   ├── grub2

/bin:bin是Binary的缩写,该目录下存放的是最常用的命令。bin -> usr/bin
/sbin:该目录存放的是系统管理员使用的系统管理程序。
/boot:该目录下存放的是启动Linux时使用的一些核心文件,包括一些连接文件以及镜像文件。
/dev:dev是Device(设备)的缩写。该目录下存放的是Linux的外部设备。在Linux中,访问设备的方式和访问文件的方式是相同的。
/etc:该目录下存放的是所有系统管理所需要的配置文件和子目录。
/home:用户的主目录。
/lib和/lib64:这两个目录下存放的是系统最基本的动态连接共享库,其作用类似于Windows里的DLL文件,几乎所有的应用程序都需要用到这些共享库。
/media:系统会自动识别一些设备(如U盘、光驱等),当识别后,Linux会把识别的设备挂载到该目录下。
/mnt:系统提供该目录是为了让用户临时挂载别的文件系统。我们可以将光驱挂载到/mnt/上,然后进入该目录查看光驱里的内容。
/opt:这是给主机额外安装软件所设置的目录,该目录默认为空。
/proc:该目录是一个虚拟的目录,是系统内存的映射,我们可以通过直接访问来获取系统信息。该目录的内容在内存里,我们可以直接修改里面的某些文件。比如可以通过下面的命令来屏蔽主机的ping命令,使其他人无法ping你的机器。
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all //临时
echo "net.ipv4.conf.icmp_echo_ignore_all = 1" > /etc/sysctl.conf //永久
/root:该目录是root的用户主目录。
/run:这个目录其实和/var/run是同一个目录,这里面存放的是一些服务的pid
/srv:该目录存放的是一些服务启动之后需要提取的数据。
/sys:该目录存放的是与硬件驱动程序相关的信息。
/tmp:该目录是用来存放一些临时文件的。
/usr:这是一个非常重要的目录,类似于Windows下的Program Files目录,用户的很多应用程序和文件都存放在该目录下。
/usr/bin:该目录存放的是系统用户使用的应用程序。
/usr/sbin: 该目录存放的是超级用户使用的比较高级的管理程序和系统守护程序。
/usr/src :该目录是内核源代码默认的放置目录。
/var:该目录存放的是在不断扩充且经常被修改的目录,包括各种日志文件或者pid文件,刚刚提到的/var/run就是在/var目录下面

2.3 ls命令
ls - list directory contents
ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
-a, --all
do not ignore entries starting with .
# ls -a
. .. anaconda-ks.cfg .bash_history .bash_logout .bash_profile .bashrc .cshrc .ssh

-A, --almost-all
do not list implied . and ..
# ls -A
anaconda-ks.cfg .bash_history .bash_logout .bash_profile .bashrc .cshrc .ssh .tcshrc

--author
with -l, print the author of each file
# ls -l /root --author
总用量 4
-rw-------. 1 root root root 1418 12月 13 10:27 anaconda-ks.cfg

-d, --directory
list directories themselves, not their contents
# ls -ld /root
dr-xr-x---. 3 root root 147 12月 15 00:58 /root

-h, --human-readable
with -l, print sizes in human readable format (e.g., 1K 234M 2G)
# ls -lh anaconda-ks.cfg
-rw-------. 1 root root 1.4K 12月 13 10:27 anaconda-ks.cfg

-i, --inode
print the index number of each file
# ls -i anaconda-ks.cfg
33574978 anaconda-ks.cfg

-l use a long listing format
# ls -l
总用量 4
-rw-------. 1 root root 1418 12月 13 10:27 anaconda-ks.cfg

-n, --numeric-uid-gid
like -l, but list numeric user and group IDs
# ls -n /root
总用量 4
-rw-------. 1 0 0 1418 12月 13 10:27 anaconda-ks.cfg

-r, --reverse
reverse order while sorting
# ls -lart
总用量 28
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
-rw-r--r--. 1 root root 100 12月 29 2013 .cshrc
-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc
-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile
-rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout
-rw-------. 1 root root 1418 12月 13 10:27 anaconda-ks.cfg
dr-xr-x---. 3 root root 147 12月 15 00:58 .
dr-xr-xr-x. 17 root root 245 12月 18 01:38 ..
drwx------. 2 root root 80 12月 18 03:02 .ssh
-rw-------. 1 root root 2229 12月 18 09:29 .bash_history

-R, --recursive
list subdirectories recursively
# ls /root -laR
/root:
总用量 28
dr-xr-x---. 3 root root 147 12月 15 00:58 .
dr-xr-xr-x. 17 root root 245 12月 18 01:38 ..
-rw-------. 1 root root 1418 12月 13 10:27 anaconda-ks.cfg
-rw-------. 1 root root 2229 12月 18 09:29 .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月 18 03:02 .ssh
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc

/root/.ssh:
总用量 16
drwx------. 2 root root 80 12月 18 03:02 .
dr-xr-x---. 3 root root 147 12月 15 00:58 ..
-rw-r--r--. 1 root root 1179 12月 18 03:02 authorized_keys
-rw-------. 1 root root 1679 12月 18 02:57 id_rsa
-rw-r--r--. 1 root root 400 12月 18 02:57 id_rsa.pub
-rw-r--r--. 1 root root 177 12月 18 02:39 known_hosts

-S sort by file size
# ls /root -laS
总用量 28
-rw-------. 1 root root 2229 12月 18 09:29 .bash_history
-rw-------. 1 root root 1418 12月 13 10:27 anaconda-ks.cfg
dr-xr-xr-x. 17 root root 245 12月 18 01:38 ..
-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc
dr-xr-x---. 3 root root 147 12月 15 00:58 .
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
-rw-r--r--. 1 root root 100 12月 29 2013 .cshrc
drwx------. 2 root root 80 12月 18 03:02 .ssh
-rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout

-t sort by modification time, newest first
# ls -lat
总用量 28
-rw-------. 1 root root 2229 12月 18 09:29 .bash_history
drwx------. 2 root root 80 12月 18 03:02 .ssh
dr-xr-xr-x. 17 root root 245 12月 18 01:38 ..
dr-xr-x---. 3 root root 147 12月 15 00:58 .
-rw-------. 1 root root 1418 12月 13 10:27 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

2.4 文件类型
find - search for files in a directory hierarchy
-type c
File is of type c:
b block (buffered) special
c character (unbuffered) special
d directory
p named pipe (FIFO)
f regular file
l symbolic link
s socket
D door (Solaris)

2.5 alias命令
# alias
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --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 "别名"='命令参数'
alias lll='ll -ha'
unalias lll



阅读全文
0 0
原创粉丝点击