1. System directory structure
Shorthand for #ls list
#ls /root/
#ls /root/.ssh/authorizde_keys in root's home directory
#useradd champin User's file directory is under home
ssh configuration file /etc/ssh/sshd_config
There are those directories under the root
[root@cham3 ~]# tree -L 2 / Maximum specified 2 layers
Both bin and sbin (superbin) are directories where all command files are stored. The difference is. Below sbin are all used by root users, and below bin are used by ordinary users and can also be used by root
The boot directory contains some files related to system startup. For example, grup single-user mode is to enter grup mode, and some parameters of grupd are changed.
dev is a device file specific to the Linux system, such as a CD-ROM, a mouse, and a keyboard
The directory where the configuration files of the etc system are located, such as: /etc/sysconfig/network-scripts/ifcfg-ens33, including /etc/ssh/sshd_config
home is the user's home directory
lib and lib64 system library file The library file is similar to the Windows .dll file
media The media directory, which is empty by default. For example, inserting a USB flash drive will mount it to the media directory.
mut is an empty directory, a directory that is temporarily hung. For example, CD-ROM, newly installed hard disk, under mut
opt is an empty directory some documents of orcle will install oracle under opt
proc is some system-initiated process, it will generate a pid Each process has a directory
root is the home directory of the root user
run is an existing directory where a process generates temporary files and will disappear once restarted
srv is an empty file, short for service. There will be some files generated by the service under this directory
sys will store some files related to the system kernel, usually it will not be moved, so don't pay too much attention
tmp is the temporary directory of the system, it has great permissions, any user can modify things
Some files for the usr user are placed in this directory. very important directory
Var will store some logs, and all system-related logs are stored in /var/log/messages
var/run/
important.
usr/bin/ usr/sbin/ /bin/ /sbin/ /etc/ /var/ /usr/local/
2. ls command and file type
#ls -l will display file details
#ls -la will view all hidden files or directories under the directory, . The beginning of the point is a hidden file or directory
-l details
-i inode
-a include all hidden ones
-t sort chronologically
-h When -l, you can freely convert the unit when displaying the file size
-d When listing a directory, only the directory itself is listed
[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 ~]#
file type
-Ordinary file
d =directory directory file, d means blue dr-xr-x such as directory list
c serial port device file (eg: keyboard, mouse) c means yellow string device file, such as mouse and keyboard
b =block block file
s =socket socket file, used for inter-process communication, s means pink is used for communication, communication between processes and processes TCP/IP
Green compiled files cannot be opened
-rw is a text file that can be opened with #ca
c represents a yellow string device file, such as a mouse and keyboard
b are block devices such as CDs, disks
l indicates that the cyan is a shortcut for soft link files similar to windows
d - c b s l
3. alias which command
The alias syntax of the alias setting directive : alias [alias]=[directive name]
Usage:
# alias 罗列出系统所有设有别名的指令
# alias adai=‘ls -lha’ 即命名‘ls -lha’的别名为adai
# unalias adai 取消adai的别名设置
Note: The effect of alias is limited to the operation of this login, and it will be invalid after restarting. To make this alias permanent, you need to edit the .profile or .cshrc file
how to use aliases
[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 ~]#