Linux CentOS knowledge and common commands

1, commonly used hotkeys

[Tab] it has a "command completion" and "document completion" function
[Ctrl + C] interrupt program execution key combination
[Ctrl + d] the end of the keyboard. It may be used instead of exit

 

2, Linux popular editors vi and vim

vi editor (vim or less the same)

(1) normal mode [can delete, copy, paste]

(2) [Edit mode can be deleted, copied, pasted, can not edit the contents, press ilo O a A r R any health will enter edit mode to return to normal mode by pressing Esc]

 

3, Linux directory configuration

1, the root directory (/)

Root directory (/) where the partition should be as small as possible, and the software applications installed preferably not on the same partition with the root directory, keeping the root of the smaller the better. So not only better performance, the root directory where the file system is also less prone to problems

2, the implementation of the file directory (/ bin)

There are many systems perform file directory placement, but the / bin special. Since / bin command is placed in the single-user maintenance mode it can be operated. In / bin following command can be used with the root account general, there are common commands cat, chmod, chown, date, mv, mkdir, cp, bash like.

3, boot files in the directory (/ boot):
The main directory file placement opportunities open to use, including the Linux kernel file and boot menu and boot the desired configuration files.

4, the drive device directory (/ dev)
on the Linux system, the interface device is any device in the form of a file in this directory among. You just by accessing a file in this directory, it means access to a device. There are more important file / dev / null, / dev / zero, / dev / tty and so on.

5, the profile directory (/ etc)
system main configuration file almost all placed in the directory, for example, account password file officers, starting various services such as file. In general, the various file attributes of this directory is that it gives the user access to the general, but only root has the right to modify. There /etc/init.d,/etc/inittab,/etc/sysconfig more important documents and so on.

6, the user home folder (/ home)
This is the default home folder of the user (home directory). When you create a normal user account, the default user home folder will be standardized to be here. ~ Represents the current user's home folder.

7, the system library (/ lib)
library system is very large, and / lib library is placed in the boot will be used, as well as in the library / bin or / sbin following command will call it.
* You can imagine the library as a "plug-in", some of these commands must have "plug-in" was intended to complete the implementation of the program smoothly.

8, third-party software installation directory (/ opt)
directory is used to install third-party applications, you can specify the installation location of the user. When you need to uninstall third-party applications, you can simply remove the installation directory, without affecting any other system settings.

9, administrator home folder (/ root)
system administrator (root) of the Home folder. The reason on here, because if they go into single-user maintenance mode while only mount the root directory, which will be able to have a primary root file folder, so we want to root master file folder and placed in the root directory of a partition with in.

10, service data storage directory (/ SRV)
SRV can be considered abbreviated "service" of some network after the service starts, these services require access to the data directory. Common services such as WWW, FTP and so on. For example, web WWW data service needs to be placed in / srv / www / in.

11, the virtual file system directory (/ proc)
The directory itself is a virtual file system (virtual filesystem). It is placed in the data memory of them, such as the system kernel process, the external devices and network status. Because the data in this directory are in memory of them, so that in itself does not account for any hard disk space.

12, the virtual file system directory (/ sys)
this fact with the directory / proc is very similar, is a virtual file system, recording information is largely related to the kernel. A hardware device information has been loaded kernel modules and detected by the kernel and the like. This directory also does not account for the hard disk capacity.

13, the system software resource directory (/ usr)
a lot of white will be mistaken for / usr is the acronym user, in fact, is the acronym usr Unix Software Resource, which is "UNIX operating system software resources" placed the directory, not the user's data, and that needs attention.

 

5, sudo command

Execute root commands. And requires the user to enter their secret, so when multiple people manage a host, at least the root password will not stay out!

 

6, software installation (RPM, SRPM function with YUM)

distribution representatives Software management system  Use instructions Online upgrade mechanism (directive) 
Red Hat/Fedora  RPM  rpm, rpmbuild YUM (yum)
Debian/Ubuntu DPKG dpkg APT (apt-get)

 

        rpm installation

 rpm -ivh package_name

rpm -ivh rp-pppoe-3.5-32.1.i386.rpm a mounting
RPM -ivh a.i386.rpm b.i386.rpm mounting a plurality of (separated by spaces)
RPM -ivh HTTP: mounting //xxxx/pkgname.rpm (common) on the web

rpm -e --nodeps packages to be uninstalled

Option parameters not: 
-i: the install means 
-v: View More screen installation information gentry portion 
-h: columns show the installation to installation information of Zhong

 

yum install

yum list xxx * query software 
yum install software to install 
the yum update then you want to upgrade, to upgrade the entire system, you can directly update 
yum remove xxx remove software

 

7, commonly used commands

(1) directory and path

The representative of this layer directory 
.. on behalf of parent directory
 -      before working on behalf of a directory
 - on behalf of the Master File "At present user," where the folder

cd: Change directory
pwd: Displays the current directory
mkdir: create a new directory
rmdir: delete an empty directory, ps: only empty directory

 

mkdir -p test1 / test2 / test3 direct recursion create the desired path
mkdir -m 711 test created folder permissions
rmdir -p test1 / test2 / test3 can be deleted directly

 

(2) Copy

cp / var / log / wtmp wtmp will copy the same name wtmp2 # Name wtmp2 (PS: permission to copy, create time will change) 
cp -a / var / log / wtmp wtmp will copy the same name wtmp2 # Name wtmp2 (PS: full copy permissions, creating consistent time) 
cp -i / var / log / wtmp wtmp2 - If the current address of the file will be asked whether there is coverage 
cp -p / var / log / wtmp wtmp2 - along with the copy file attributes together in the past, and use non-default attribute 
cp -r / the Test / / test2 - recursive continuous replication, the directory replication behavior 
cp -r elasticsearch- 6.5 . 4 / * /home/elasticsearch6.5.4

 

(3) Move / Cut

mv bashrc mvtest bashrc will move a file to a directory
mv mvtest mvtest2 rename

 

(4) the shutdown command

- the shutdown H now # immediately shut down 
the shutdown -h 0    # immediately shut down 
the shutdown -h 20 : 15 # The system will shut down at a specified time today 
the shutdown - r now # immediately restart 
the shutdown -r + 10  ' to restart the server '    # another 10 minutes to restart the system, behind the display information to all online users 
the shutdown -k now ' server warning messages ' # parameter only a warning message, the system will not shut down

 

(5) File Permissions

chgrp # change file user group 
chown # change file owner 
permission to change the file chmod # 

R & lt: . 4    # read permission (corresponding to the digital rights) 
W: 2    #-writable 
X: . 1    # execute permissions 

rwx = . 4 + 2 + 1 = 7 
- 777   # ACCESS

 

(6) Find 

find  /  -name  *.sh

 

(7) download (wget)

yum install wget # installation
Download the specified address # 
wget HTTPS: // nginx.org/download/nginx-1.16.0.tar.gz 

# - c HTTP 
wget -c HTTPS: // nginx.org/download/nginx-1.16.0. tar.gz 

# case of batch downloading, all you need to download the file address into the filename.txt, and then CentOS wget will automatically download all your files 
wget -i filename.txt

 

 (8) decompression

PIP--xvzf the tar 10.0 . . 1 .tar.gz 
# copy ROOT file package to the following war, decompress: JAR -xvf xxxx.war

 

 (9) to view the port number occupied

lsof -i: port number

 

(10) View occupy the port number

1 , PS command to view processes that are currently running, grep search 
for example: PS -ef | grep java, expressed view all processes in the CMD process information is java
 2 , PS -aux | grep java, - the AUX display all states
 3 . the kill command to terminate the process - 9 represents a forced process stops immediately, such as: the kill - 9 [PID]

 

(11) Firewall (CentOS firewalld)

 The basic use of 1.firewalld

# Start: 
systemctl Start firewalld 

# close: 
systemctl STOP firewalld 

# View state: 
systemctl Status firewalld 

# disable boot: 
systemctl disable firewalld 

Power On: 
systemctl enable firewalld

2.systemctl is CentOS7 service management tool in the main tool before it blends service and chkconfig functions in one.

# Start a service: 
systemctl Start firewalld.service 

# shut down a service: 
systemctl STOP firewalld.service 

# restart a service: 
systemctl restart firewalld.service 

# displays the status of a service: 
systemctl Status firewalld.service 

# enable a service at boot: 
enable firewalld.service systemctl 

# at boot disable a service: 
systemctl disable firewalld.service 

# see if the service startup: 
systemctl iS - Enabled firewalld.service 

# view a list of services have been started: 
systemctl list -unit-Files | grep Enabled 

# View a list of services failed to start: 
systemctl --failed

 

3. Configure firewalld-cmd

# View Version: 
Firewall -cmd - Version 

# view help: 
Firewall -cmd - Help 

# display status: 
Firewall -cmd - State 

# view all open ports: 
Firewall -cmd --zone = public --list- the ports 

# update the firewall rules: 
firewall -cmd - reload 

# viewing area information: 
firewall -cmd - GET -active- Zones 

# View the specified interface belongs: 
firewall -cmd - GET -zone-of- interface = eth0 

# reject all package: 
Firewall -cmd --panic- ON 

# unblock status:
Firewall -cmd --panic- OFF 

# see if refused: 
Firewall -cmd --query-panic

4. Port Configuration firewalld

# Add 
Firewall -cmd --zone = public --add-Port = 80 / tcp --permanent (- Permanent permanent, this argument does not restart after failure) 

# reload 
Firewall -cmd - reload 

# View 
Firewall - --zone = cmd public --query-Port = 80 / tcp 

# delete 
Firewall -cmd --zone = public --remove-Port = 80 / tcp --permanent

 

Guess you like

Origin www.cnblogs.com/songl/p/11069848.html