Linux System overview of important documents
Automatically mount a file system
File path information: / etc / fstab
file Function Description: a storage device implemented automatically mount
[root@centos7 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Nov 26 17:31:33 2019 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=286f8545-16c5-4d3c-a06a-203215caf6d1 / xfs defaults 0 0 UUID=4cd8f346-d2ec-40db-9532-8fe546c322b8 /boot xfs defaults 0 0 UUID=0c6db736-b955-413a-a0bc-fcea22cbeb79 swap swap defaults 0 0
Learn to help explain the configuration file fatab: man fstab
. 1) mounted storage device representation information UUID information file / dev / sda3
2) mount point information of the directory / mount point
3) file system type xfs default file system centos7
4) linked upload parameter information determines whether the ro rw storage device to store data
5) whether the impact of disk backup disk storage disk utilization efficiency can reduce data recovery function is disabled 0 1 feature is turned on
6) whether the disk check affects disk storage efficiency, You can use fsck manually check
Automatically mount CD-ROM
[root@centos7 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 41922560 1684044 40238516 5% / devtmpfs 487048 0 487048 0% /dev tmpfs 497948 0 497948 0% /dev/shm tmpfs 497948 7800 490148 2% /run tmpfs 497948 0 497948 0% /sys/fs/cgroup /dev/sda1 201380 107080 94300 54% /boot tmpfs 99592 0 99592 0% /run/user/0 [root@centos7 ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Nov 26 17:31:33 2019 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=286f8545-16c5-4d3c-a06a-203215caf6d1 / xfs defaults 0 0 UUID=4cd8f346-d2ec-40db-9532-8fe546c322b8 /boot xfs defaults 0 0 UUID=0c6db736-b955-413a-a0bc-fcea22cbeb79 swap swap defaults 0 0 /dev/cdrom /mnt iso9660 defaults 0 0
[root@centos7 ~]# reboot
Connection closed by foreign host.
Disconnected from remote host(centos7-1) at 10:32:04. Type `help' to learn how to use Xshell prompt. [c:\~]$ Connecting to 10.0.0.200:22... Could not connect to '10.0.0.200' (port 22): Connection failed. Type `help' to learn how to use Xshell prompt. [c:\~]$ Connecting to 10.0.0.200:22... Connection established. To escape to local shell, press Ctrl+Alt+]. WARNING! The remote SSH server rejected X11 forwarding request. Last login: Tue Dec 3 08:24:33 2019 from 10.0.0.1 [root@centos7 ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 41922560 1682900 40239660 5% / devtmpfs 487048 0 487048 0% /dev tmpfs 497948 0 497948 0% /dev/shm tmpfs 497948 7768 490180 2% /run tmpfs 497948 0 497948 0% /sys/fs/cgroup /dev/sr0 4480476 4480476 0 100% /mnt /dev/sda1 201380 107080 94300 54% /boot tmpfs 99592 0 99592 0% /run/user/0
[root@centos7 ~]# blkid
/dev/sda1: UUID="4cd8f346-d2ec-40db-9532-8fe546c322b8" TYPE="xfs" /dev/sda2: UUID="0c6db736-b955-413a-a0bc-fcea22cbeb79" TYPE="swap" /dev/sda3: UUID="286f8545-16c5-4d3c-a06a-203215caf6d1" TYPE="xfs" /dev/sr0: UUID="2018-11-25-23-54-16-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
Two system environment variables, alias file
File path information: / etc / profile
file Function Description: Set alias variable or may be provided
Introduction (a) environment variables
1) environment variable consists of uppercase letters
2) environment variable is the default setting good
3) have a special role in the environment variable
$ PATH --- let users of the system can be run directly command
execution logic:
1) User input Commands -> System load PATH environment variable $ PATH
/ usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / root / bin save binary files directory
2) Find execute commands in the specified environment variable directory file
found in the path environment variable cat command file ---> Run function
environment variable can not find the path command ---> command prompt error message can not find the file does not exist
4) environment variable is set up, affects all user
environments setting method:
temporarily applied:
the PATH = / usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / the root / bin: / tmp
permanent:
VI / etc / Profile
PATH = / usr / local / sbin : / usr / local / bin: / usr / sbin: / usr / bin: / root / bin: / tmp
permanently configured to effect:
Method 2: Using the command to load the configuration profile file
. Source / etc / profile or / etc / profile
Create a command
Delete command to create a role: the data to the recycle bin inside
[root@centos7 ~]# vim del
#!/bin/bash
mv $* /tmp
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"del" [New] 2L, 24C written
== binary file Binary command
To become a command, move to the directory binaries which, in fact, grafting, grafting
[root@centos7 ~]# mv del /bin/ [root@centos7 ~]# ll /bin/del -rw-r--r--. 1 root root 24 Dec 3 11:18 /bin/del [root@centos7 ~]# chmod +x /bin/del [root@centos7 ~]# ll /bin/del -rwxr-xr-x. 1 root root 24 Dec 3 11:18 /bin/del
(B) the introduction alias
Action: simplify the operation command
It is suitable for multi-level file or directory, open more convenient
Also dangerous command to set the general command
(Iii) a method to set the alias
Temporary set the alias
alias View alias information
[root@centos7 ~]# 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 vinet='vi /etc/sysconfig/network-scripts/ifcfg-eth0' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
alias alias name = 'true command'
[root@centos7 ~]# alias vinet0='vi /etc/sysconfig/network-scripts/ifcfg-eth0' [root@centos7 ~]# 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 vinet0='vi /etc/sysconfig/network-scripts/ifcfg-eth0' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@centos7 ~]# vinet0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=eth0 UUID=9d9e2656-f3ac-4f75-8722-3136d239985d DEVICE=eth0 ONBOOT=yes IPADDR=10.0.0.200 PREFIX=24 GATEWAY=10.0.0.254 IPV6_PRIVACY=no DNS1=223.5.5.5 ~ "/etc/sysconfig/network-scripts/ifcfg-eth0" 20L, 356C
Permanently set
[root@centos7 ~]# cat /etc/bashrc | tail -1 alias vinet0='vi /etc/sysconfig/network-scripts/ifcfg-eth0'
Method a: re-connection to the host
Method 2: Using the command to load the configuration profile file
. Source / etc / profile or / etc / profile
[root@centos7 ~]# alias vinet='vi /etc/sysconfig/network-scripts/ifcfg-eth0' [root@centos7 ~]# 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 vinet='vi /etc/sysconfig/network-scripts/ifcfg-eth0' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [root@centos7 ~]# unalias vinet [root@centos7 ~]# 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'
(C) cancel the alias function
[root@centos7 ~]# alias vinet='vi /etc/sysconfig/network-scripts/ifcfg-eth0' [root@centos7 ~]# 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'mv =alias'mv -i' alias rm='rm -i' alias vinet='vi /etc/sysconfig/network-scripts/ifcfg-eth0' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [root@centos7 ~]# unalias vinet [root@centos7 ~]# 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'
Execute commands using an absolute path
[root@centos7 ~]# touch bb.txt [root@centos7 ~]# /bin/rm bb.txt [root@centos7 ~]# ls anaconda-ks.cfg backup del epel-7.repo
Use crowbars to make it clear
[root@centos7 ~]# 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='mv -t /tmp' alias vinet='vi /etc/sysconfig/network-scripts/ifcfg-eth0' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [root@centos7 ~]# ls anaconda-ks.cfg backup test.sh [root@centos7 ~]# touch cc.txt [root@centos7 ~]# \rm cc.txt [root@centos7 ~]# ls anaconda-ks.cfg backup test.sh
(Iv) provided to avoid dangerous operations alias
alias rm='mv -t /tmp'
Note that the original commands and their corresponding aliases will be covered && failure
[root@centos7 ~]# 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 vinet0='vi /etc/sysconfig/network-scripts/ifcfg-eth0' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [root@centos7 ~]# alias rm='mv -t /tmp' [root@centos7 ~]# 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='mv -t /tmp' alias vinet0='vi /etc/sysconfig/network-scripts/ifcfg-eth0' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@centos7 ~]# rm aa.txt [root@centos7 ~]# ls anaconda-ks.cfg backup del epel-7.repo [root@centos7 ~]# ls /tmp/aa.txt /tmp/aa.txt [root@centos7 ~]# ls /tmp/aa.txt -l -rw-r--r--. 1 root root 51 Dec 5 12:42 /tmp/aa.txt
Resolution:
Rm performed is equivalent to move the data to trash
[root@centos7 ~]# man mv
-t, --target-directory=DIRECTORY
move all SOURCE arguments into DIRECTORY
(E) provision of the relevant documents alias || environment variables
/ etc / profile / etc / bashrc global configuration (corresponding national law)
~ / ~ .bash_profile / .bashrc local configuration (corresponding to house rules)