Centos use
1. Shell Foundation
1.1 Shell type
- Bash (Bourne-Again Shell, default Linux shell, enhanced version of SH including centos ubuntu, sh soft chain to bash, GNU R&D) http://www.gnu.org/software/bash/manual/html_node/index.html
- ash (Almquist shell, Kenneth Almquist and 1980s, almost replaced by bash in addition to the use of embedded linux such as OpenWrt, but recently used by docker alpine system and new application scenarios) https://www.in-ulm.de/~mascheck/various/ash/
- CSH (R&D by C Shell, University of California, Berkeley)
- sh (History: Bourne Shell, unix default shell, bell Lab R&D)
# View all shell s cat /etc/shells # View the shell currently in use echo $SHELL
1.2 Command Character
- Pipe character | The output of the first command is the input of the second command
https://en.wikipedia.org/wiki/Pipeline_(Unix)
- Redirector (by modifying the process to open the actual file corresponding to the corresponding descriptor in the file list, you can see the actual redirection in / proc//fd)
# [File Descriptor]> [File Name | & File Descriptor] > Data to Clear the original file > Indicates that the input file appended to the original content defaults to Standard Output (STDOUT 1) Command > File: Redirect standard output to a file (empty the data of the original file) Command 2 > File: Redirect the error output to a file (empty the data of the original file) Command > File: Redirect standard output to a file (appended to the original content) Command 2 > File: Redirect the error quasi-output to a file (append to the original content) Command > File 2 > & 1 or Command & > File: Write standard output and error output together into the file (appended to the original content) # Double redirection tee Redirect output to standard output as well as to files
http://blog.csdn.net/Wee_Mita/article/details/52728285
2. environment
PATH system is used to find the path of binary executable file (/ etc/profile.d / configuration profile file will be restored due to system upgrade)
LD_LIBRARY_PATH (/etc/ld.so.conf.d/configuration to prevent global pollution)
In-line valid environmental variables
SQLITE3_BINARY_SITE=http://npm.taobao.org/mirrors/sqlite3 npm install sqlite3
System configuration parameters
The system configuration parameters are located in the / etc/sysctl.conf file, which is not normally recommended to be modified, so the file will be restored after the system upgrade.
It is recommended that user configurations be placed in / etc/sysctl.d / folder
## Temporary configuration sysctl -w net.ipv4.tcp_keepalive_time = 900 ## Permanent configuration Configure Write/etc/sysctl.d/Folder sysctl -p /etc/sysctl.d/xxx.conf Note that sysctl-p without parameters will only apply the configuration in the / etc/sysctl.conf file, not the configuration in / etc/sysctl.d/, and the configuration in / etc/sysctl.d / will only be checked at startup, and the restart will take effect.
2. Document management
- View folder size
du -sh
- Intersystem File Replication
#For security reasons, rsync account should be used to backup, because ssh privileges are too large - r means recursive - l means keeping soft chain - programs can be used to display progress and speed when command line input. yum -y install rsync ## - l Reserve Soft Chain - t Reserve Modification Time - P Reserve Permission - g Reserve group -o Reserve onwer -v Display Transfer Details File Name - P Display Transfer Progress of Each File ## Exclude'sources'exclude folders rsync -rltpgov [source] [target] rsync -rl lighttpd-mirrors root@10.0.30.141:/data/docker/data/volume/ (Permission loss may occur in replication) rsync -rl -e 'ssh -p 46358' /data/* root@10.176.101.7:/data/ #Modify Port Send #Flexible chains will be lost and original files will be copied scp -r /data/docker-volume/mariadb-1 root@10.0.10.75:/data/docker-volume/ (Speed up to 80-100M/s)
- File download
## The most common Downloads curl -o gradle-5.2.1-bin.zip https://mirrors.d.com/gradle/gradle-5.2.1-bin.zip ## If the link address contains 302 jumps curl -L -o gradle-5.2.1-bin.zip https://mirrors.d.com/gradle/gradle-5.2.1-bin.zip ## If the link address is issued with a trusted account curl -k -o gradle-5.2.1-bin.zip https://mirrors.d.com/gradle/gradle-5.2.1-bin.zip ## If the target address requires http basic auth curl --user username:password -o gradle-5.2.1-bin.zip https://mirrors.d.com/gradle/gradle-5.2.1-bin.zip ## If the target address cert authentication
3. Interprocess Communication (IPC)
- Domain socket (AF_UNIX)
Unix Domain Socket (UDS) is usually an extension of. sock. It uses file system API (only inode to identify, no actual hard disk to read and write) instead of network to communicate between processes.
Restrictions:- Interprocess communication within the same host
- Speed is slower than shared memory
- Unable to use tcpdump to monitor and debug (because no actual data packet passes through physical or virtual network card)
Advantages:
1. No network protocol stack, no packing, unpacking, checking and answering, good performance, fast, traditional host performance is twice as good as internet socket.
2. File permissions can be used for permission control
http://www.bubuko.com/infodetail-1286548.html
http://www.cnxct.com/default-configuration-and-performance-of-nginx-phpfpm-and-tcp-socket-or-unix-domain-socket/
https://blog.csdn.net/timebomb/article/details/38417547
https://stackoverflow.com/questions/36118693/does-unix-domain-socket-perform-any-file-system-read-write/36118927#36118927
- Pipelines and named pipes
See Command Prompt - Message queue
- Shared Memory (SHM)
- internet socket
- file
- Synchronization mechanism
- Memory Mapping File
Disk adjustment
lvm management
Umount/home# Uninstall Logical Volume
/ etc/fstab # Delete mount information or restart will automatically mount
Lvremove/dev/centos/home # Use lvpath to delete the logical volume lvdisplay to view
Lvextend-L+40G/dev/centos/root# Increase 40G (non-xfs file system)
Lvresize-L +100G/dev/centos/root # Increase 100G (Non-xfs File System)
Resize2fs/dev/mapper/centos-root (non-xfs file system)
Xfs_growfs/dev/mapper/centos-root (xfs file system)
Partition formatting
mkfs.xfs -f /dev/sdb1
Partition mounted to directory
mount /dev/sdb1 /data/nfs
Network management
- View Port Correspondence Program
netstat -nlp | grep 179
Planning tasks
yum install crontabs
Change vi/etc/pam.d/crond required to sufficient
https://my.oschina.net/thmz/blog/468327
/ etc/crontab # System Task Scheduling Configuration File (not recommended)
/ The configuration file of var/spool/cron/username# User Task Scheduling should be edited using crontab-e without recommending direct modification
/ etc/crontab format
# Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed
Crontab-e-u user format (no user)
# Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * command to be executed
Common debugging tools, output environment variable $PATH > >/ data/path.log in echo cron
- Manual Opening of Planned Tasks
/usr/sbin/crond
Firewall management
iptables
View Rules - t Table Name - n Digital Display ip and Port - v Display Details (e.g. Interface Name) -- line-numbers Display rule-num iptables -t nat --list -nv --line-numbers
- - j target-chain calls the target custom rule chain (returns the invoked rule upon return)
- user-defined chain
- j chainname enters user-defined chain processing - Iptables-extensions defined target
-m matching-module-name -j target-name - Special values (most commonly used - special goals)
-j values
[values]
ACCEPT allows (passes) and proceeds to the next chain.
DROP prohibits (prohibits passage) and discards packets directly
RETURN returns (ignores this chain), ignores the processing of this chain, and returns to the next rule processing of the previous chain.
- - g target-chain jumps to the target custom rule chain (returning to the previous rule invoked by-j, not necessarily the previous rule)
Log view
## Viewing System Service Log at utc Time journalctl --utc ## View boot process log journalctl -b ## View logs over a period of time journalctl --since "2015-01-10" --until "2015-01-11 03:00" --utc journalctl --since yesterday --utc ## View in reverse chronological order journalctl -r ## View the log of a service journalctl -u nginx.service ## View Log Level journalctl -p err
Boot from boot
/etc/rc.local
system service
environment variable
Log location
user management
- Users in Distinguishing Application Permissions
Minimum privileges. If local login must be allowed, set the password to null for shell and home, and prohibit remote login for null password users.
Mandatory restart
echo 1 > /proc/sys/kernel/sysrq echo b > /proc/sysrq-trigger
Desktop installation
vnc VS xrdp (xrdp is recommended)
https://www.linuxidc.com/Linux/2017-09/147112.htm
Ubuntu system
Apt-get install x-window-system-core
Apt-get install GDM (login manager)
apt-get install ubuntu-desktop
apt-get install unity (ubuntu-desktop needs to be installed first)
xrdp (RDP,remote desktop protocol Service packages, converted to vnc Agreement) console Linux Desktop Environment |-X Display Manager(XDM) |-gdm https://wiki.gnome.org/Projects/GDM |-kdm https://www.kde.org/ |-xdm https://wiki.archlinux.org/index.php/XDM |-lightdm (Light Display Manager) |-X Server (Linux X Window System) Window Manager Version 11 is commonly referred to as X11 Use startx Script startup |-xorg rely on(xserver-xorg) (Not capable of remote access) |-x-window-system-core(Normally not now.) |-ubuntu-desktop(Desktop Environment) |-unity(ubuntu17 Later default does not install, Canonical Development, has abandoned development) |-Kubunut-desktop(Desktop Environment, kdm) |-gnome-core |-gnome2 |-gnome3 (Desktop Environment) |-gnome-session (session management) |-Xfce |-Xubuntu-desktop(Desktop Environment) https://xubuntu.org/ |-X11rdp xserver-common |-xserver-xorg-core |-xserver-xorg |-xorg (XOrg Foundation Open Source Public Implementatio It is a X Server Implementation) MATE Cinnamon vnc4server (vnc The server side, RFB Agreement) tightvncserver x11vnc
sudo apt-get install xubuntu-desktop
xrdp
Software management
## Radhat's corresponding package RPM (Redhat Package Manager) YUM (Yellow dog Updater, Modified, first used in the yellow dog linux operating system) [root@lineto ~]# rpm -qf /usr/bin/vmstat procps-ng-3.3.10-10.el7.x86_64 ## Find the yum package containing a command [root@docker140 ~]# yum provides */nslookup 1:bash-completion-extras-2.1-11.el7.noarch : Additional programmable completions : for Bash Repo : epel Matched from: Filename : /usr/share/bash-completion/completions/nslookup 32:bind-utils-9.9.4-61.el7.x86_64 : Utilities for querying DNS name servers Repo : base Matched from: Filename : /usr/bin/nslookup ## Ubuntu APT (Advanced Packaging Tool) dpkg(Debain Package) dpkg -l | grep name apt list --installed ## Alpine APK (Alpine Linux Package Keeper, called, a-packs) ## OpenWrt opkg (Open PacKaGe management) fork and ipkg(Itsy PacKaGe management system) project, therefore its software package is extended to ipk, emulating ubuntu dpkg ## DNF (Fedora) ## Tiny DNF, (Tiny Dandified Yum) Vmware PhotonOS ## Moc OS (brew)
Network agent
Using SSH to Accelerate Foreign Access (SOCKS5 Agent)
Ssh-f-C2qTnN-D 127.0.0.1:1080 root@Foreign server IP-p Port
HTTP proxy conversion of SOCKS proxy using privoxy and setting proxy using global variables
https://blog.csdn.net/brenda2314/article/details/88320012