Linux daily common instructions and application summary

Time:2020-1-19

A recent Alibaba ECs, CentOS 7, involves some basic Linux instructions. Here is a summary of some commonly used instructions in the build environment. If you are familiar with these instructions, you can basically use CentOS for daily operations.

For more information, please refer to the “camp — help” provided by the system, which is very practical.

 Directory related instructions

/*cd directive 
 *Jump to XX directory, and the directory to log in remotely from xshell is / root
 *CD.. return to previous directory
 */
[[email protected] ~]# cd /usr/local
/*ls
 Display all files in the current directory
*/
[[email protected] local]# ls
aegis bin etc games include lib lib64 libexec sbin share src
/*mkdir
  New, can be directory, can be file
*/
[[email protected] ~]# mkdir mytest
[[email protected] ~]# ls
mytest
[[email protected] mytest]# mkdir text.txt
[[email protected] mytest]# ls
text.txt

  File processing instructions (move, delete, copy < CP basic operations similar to MV >)

/*mv
 It can be used to rename or move
*/
[[email protected] mytest]# mv text.txt newname.txt
[[email protected] mytest]# ls
newname.txt
[[email protected] mytest]# mv newname.txt newdir
[[email protected] mytest]# ls
newdir
[[email protected] mytest]# cd newdir
[[email protected] newdir]# ls

newname.txt

/*rm
 For deleting files
 RM - f XX for general file deletion
 Delete RM - RF XX from general directory
 Batch delete the same name RM - V XX * (here * similar to wildcard)
*/
[[email protected] newdir]# ls
new1 new2 new3 new4 newname.txt
[[email protected]y newdir]# rm -f newname.txt
[[email protected] newdir]# ls
new1 new2 new3 new4
[[email protected] newdir]# rm -rf new4.txt
[[email protected] newdir]# ls
new1 new2. new3
[[email protected] newdir]# rm -rf -v new*
removed directory: ‘new1'
removed directory: ‘new2'
removed directory: ‘new3'

    File download and decompression

/*wget
 File download
 WGet URL
*/
[[email protected] newdir]# wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.79/bin/apache-tomcat-7.0.79.tar.gz
--2017-08-13 23:35:56-- http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.79/bin/apache-tomcat-7.0.79.tar.gz
Resolving mirrors.hust.edu.cn (mirrors.hust.edu.cn)... 202.114.18.160
Connecting to mirrors.hust.edu.cn (mirrors.hust.edu.cn)|202.114.18.160|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8975395 (8.6M) [application/octet-stream]
Saving to: ‘apache-tomcat-7.0.79.tar.gz
100%[================================================================================>] 8,975,395 19.3KB/s in 4m 36s
2017-08-13 23:40:33 (31.8 KB/s) - ‘apache-tomcat-7.0.79.tar.gz' saved [8975395/8975395]

/*tar
 Extract the tar.gz file, and then install it as RPM file
 tar -zxvf 
*/
[[email protected] newdir]# ls
apache-tomcat-7.0.79.tar.gz
[[email protected] newdir]# tar -zxvf apache-tomcat-7.0.79.tar.gz
apache-tomcat-7.0.79/bin/catalina.sh
apache-tomcat-7.0.79/bin/configtest.sh
apache-tomcat-7.0.79/bin/daemon.sh
apache-tomcat-7.0.79/bin/digest.sh
……
[[email protected] newdir]# ls
apache-tomcat-7.0.79 apache-tomcat-7.0.79.tar.gz

File installation and uninstallation

CentOS integrates Yum and configures the source (repository) for installation

/*Yum install / uninstall
 yum install software
 yum remove software
*/
[[email protected] newdir]# yum install postgresql
/*View the packages that can be installed by yum, and cooperate with grep to query keywords, such as' Java '*/
[[email protected] newdir]# yum list
[[email protected] newdir]# yum list|grep 'java'

/*rpm
 The RPM file you just unzipped from tar needs to use rpm
 Install RPM - IVH
 Delete rpm -e
 Check that RPM - QA is installed
*/
[[email protected] newdir]# rpm -ivh software.rpm

File change / view

/*File view
 The cat instruction, more instruction and VI instruction can be viewed
*/
[[email protected] newdir]# cat /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
 case ":${PATH}:" in
  *:"$1":*)
   ;;
  *)
   if [ "$2" = "after" ] ; then
    PATH=$PATH:$1
   else
    PATH=$1:$PATH
   fi
 esac
}
if [ -x /usr/bin/id ]; then
 if [ -z "$EUID" ]; then
  # ksh workaround
  EUID=`/usr/bin/id -u`
  UID=`/usr/bin/id -ru`
 fi
 USER="`/usr/bin/id -un`"
 LOGNAME=$USER
 MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
 pathmunge /usr/sbin
 pathmunge /usr/local/sbin
else
 pathmunge /usr/local/sbin after
 pathmunge /usr/sbin after
fi
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
 export HISTCONTROL=ignoreboth
else
 export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
 umask 002
else
 umask 022
fi
for i in /etc/profile.d/*.sh ; do
 if [ -r "$i" ]; then
  if [ "${-#*i}" != "$-" ]; then 
   . "$i"
  else
   . "$i" >/dev/null
  fi
 fi
done
unset i
unset -f pathmunge
export JAVA_HOME=/usr/develop/java/jdk1.8.0_144
export PATH=$JAVA_HOME/bin/:$PATH
export CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
export CATALINA_HOME=/usr/develop/tomcat/apache-tomcat-8.5.20
/*vi
 vi directory
 Open if directory exists
 Create a new empty file if it does not exist 
*/

If you want to modify, press I to enter the insert mode and make changes;

Save: ESC first, then enter:

WQ: save exit

Q!: exit without saving

Mainly used to modify configuration files, such as: etc / Proflie

 Common port and process monitoring

/*ps
  Check whether the software is running
  Or view running processes
  ps -ef|grep 'name' 
  For example: checking the health of Tomcat
*/
[[email protected] newdir]# ps -ef|grep 'tomcat'
root   19785   1 0 Aug12 ?    00:01:05 /usr/develop/java/jdk1.8.0_144/bin/java -Djava.util.logging.config.file=/usr/develop/tomcat/apache-tomcat-8.5.20/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /usr/develop/tomcat/apache-tomcat-8.5.20/bin/bootstrap.jar:/usr/develop/tomcat/apache-tomcat-8.5.20/bin/tomcat-juli.jar -Dcatalina.base=/usr/develop/tomcat/apache-tomcat-8.5.20 -Dcatalina.home=/usr/develop/tomcat/apache-tomcat-8.5.20 -Djava.io.tmpdir=/usr/develop/tomcat/apache-tomcat-8.5.20/temp org.apache.catalina.startup.Bootstrap start
root   22647 22470 0 23:58 pts/0  00:00:00 grep --color=auto tomcat

/*netstat
  Netstat - TL view the current TCP listening port
  Netstat - TLP to view the current TCP listening port, you need to display the listening program name, which is easier to use when you are not clear about the MySQL listening port
  netstat -tl | grep 34006
  Only view the MySQL listening port. The currently started MySQL port is 34006, which is used when it is clearly known that MySQL listening port
*/

Local file upload

Need to use lrzsz


  yum install lrzsz

Then use RZ SZ to upload and download.

summary

The above is a summary of the daily instructions and applications of Linux introduced by Xiaobian to you. I hope it can help you. If you have any questions, please leave a message and Xiaobian will reply you in time. Thank you very much for your support of the developepaer website!