Ls -lh $(find / -type f-size +100M)

Find / -name *nginx.* By file name

Query the string in which file grep -r ‘abs’ /usr/

File string substitution | support regular sed ‘s/active: * / active: pro – docker/’ application. Yml

The following parameters are supported

Updating the System Time

# ntpdate yum -y install # ntpdate yum -y install # ntpdate yum -y install # ntpdate yum -y install Ntpdate # synchronize time ntpdate -u pool.ntp.org # Synchronize timeCopy the code

Replace the yum source

D/centos-base. repo /etc/yum. Repos. D/centos-base. repo http://mirrors.aliyun.com/repo/Centos-7.repo # update yum makecache yum - y updateCopy the code

Java environment variable configuration

# JDK config export JAVA_HOME=/usr/local/ Java /jdk1.8.0_211 export # JDK config export JAVA_HOME=/usr/local/ Java /jdk1.8.0_211 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$JAVA_HOME/bin:$PATHCopy the code

Maven environment variables

#maven config export MAVEN_HOME=/usr/local/ Java /apache-maven-3.6.1 export MAVEN_HOME export PATH=$PATH:$MAVEN_HOME/bin # MAVEN_HOME=/usr/local/ Java /apache-maven-3.6.1 export MAVEN_HOME export PATH=$PATH:$MAVEN_HOME/binCopy the code

Node environment variable

#maven config
export NODE_HOME=/usr/local/node/node-v14.15.1-linux-x64
export PATH=${NODE_HOME}/bin:$PATH
Copy the code

Custom commands

vi /etc/bashrc
alias cbd-sms="sh /usr/local/java/sh/cbd-sms.sh"
source /etc/bashrc
Copy the code

Basic script usage

#! /bin/sh PROJECT_NAME='frpc' PROCESS=`ps -ef|grep $PROJECT_NAME|grep -v grep|grep -v PPID|awk '{ print $2}'` if [ -n "$PROCESS" ]; then echo "kill PID=$PROCESS" for i in $PROCESS do echo "Kill the $PROJECT_NAME process [ $i ]" kill -9 $i done fi # Run the script in the background nohup/usr/local/FRP/client/FRPC - c/usr/local/FRP/client/FRPC. Ini > / dev/null > & 1 & 2Copy the code

Custom service

Frpc. service [Unit] Description= FRPC daemon After=network.target [service]  Type=simple ExecStart=/usr/local/frp/client/frpc -c /usr/local/frp/client/frpc.ini [Install] WantedBy=multi-user.target Systemctl start FRPC systemctl enable FRPC systemctl stop FRPC systemctl restart FRPCCopy the code

Common array judgment operations

  • Grep and pipeline transmission are mainly used
#! /bin/sh users=("a" "b" "c"); echo ${users[@]} if [ $(echo "${users[@]}" | grep -wq "a" && echo "Yes" || echo "No") = "Yes" ] then echo "Yes" fi echo "${users[@]}" | grep -wq "a" && echo "Yes" || echo "No"Copy the code

New users

#Example Add user group K8s
groupadd dev
#Add user k8s to the dev group
useradd -g dev k8s

#To add a user to a user group, do not use:
usermod -G groupA

#Doing so will cause you to leave other user groups and become only a member of groupA. I should use the plus a option
usermod -a -G groupA user


#Change the password for user K8S
passwd k8s

#Permissions to
chmod -v u+w /etc/sudoers
 
#Open sudoers file to add
#Sudo: indicates that all users in the dev group can execute sudo without password
%dev ALL=(ALL) NOPASSWD: ALL
#Indicates that the libb user can execute sudo without a password
k8s  ALL=(ALL) NOPASSWD: ALL
#Indicates that the libb user can execute sudo
k8s  ALL=(ALL) ALL
 
#Finally, cancel the sudoers file writable permission
chmod -v u-w /etc/sudoers

Copy the code