A rough summary of common Linux commands

The commands in this article are suitable for linux7.X, maybe linux6.x will be a bit off

Linux basic commands

Linux basic commands

1. cd command : means to switch directories

  • cd… switch to the previous level

  • cd ~ switch to user directory

    • cd / switch to the root directory

2. ls / ll command : View the file list

  • ls concisely display the file list (only display the file name)
  • ll Detailed display file list (will display the permission information and modification information)
    • You can add the parameter -a: means to view all files and display hidden files

3. cp command : copy files

Cp The target directory of the file file to be copied (can add parameter -r, recursive copy)

4 mv command : move files

Mv need to move the file file target directory

The mv command can also be used to modify the file name

5. cat / tail command : used to view the file content

​ cat filename

Cat is usually used to view relatively small files

Tail can specify which part of the file to view, according to the following parameters

6. vim command : mainly used to edit file information

​ vim filename

There may be no vim command in some Linux, you can use yum -y install vim to install vim

  • After entering the file content interface

    • Enter i to enter the editing interface, the insert character will appear at the bottom, indicating that it can be edited
    • Search string: / searchcontent, enter to search
    • File saving and exit: first press esc to exit the editing interface
      • : wq means to save and exit, you can also press two capital Z (the author likes to press shift + zz)
      • : q to abandon the modification,: q! to force quit
  • Other editing commands

    command effect
    dd Delete (cut) the entire line under the cursor
    5dd Delete (cut) 5 lines starting from the cursor
    yy Copy the entire line where the cursor is
    5yy Copy the 5 lines starting with the cursor
    n Search for the next string
    N Search to locate the previous string

7. tar command : used to compress files

  • Unzip the file: tar -zxvf compressfilename-<target address>

  • Compressed file: tar -zcvf compressed file name compressed directory

  • Parameter explanation

    parameter effect
    -with Means compressed file format, gzip
    -c Means compress
    -x Unzip
    -v Show progress
    -f Followed by the file name

yum

Introduction:

RPM :. In order to address the complexity of the software installation, upgrade, unloading operations management software designed, rpm will establish a unified database files, file records and information software can analyze dependencies braking, the equivalent of dependence maven , rpm stores the address of the file

** YUM: ** It is more intelligent than RPM, and can download all software-related programs according to dependencies

RPM installation software:

  • First upload the rpm file to the server
  • ​ rpm -ivh mongodb-org-server-4.2.3-1.el7.x86_64.rpm

rpm installation set environment variables may be omitted jdk

View local yum source : yum repolist all

View installation : yum list intalled | grep docker

yum install software :

Install the software according to the local rpm file:

​ yum localinstall mysql-…rpm

For example: install netstat command

  • Run yum provides * / netstat to see the toolkit related to the netstat command
    • [External chain image transfer failed, the source site may have an anti-theft chain mechanism, it is recommended to save the image and upload it directly (img-xaxqbgQ9-1585918484038) (D: \ notebook \ linux \ linux.assets \ image-20200211154339905.png)]
  • Type yum install net-tools to start the installation

View the installation location of a software:

​ whereis mysql

Check the rpm installation package:

rpm -qa | grep mysql

[External chain image transfer failed, the source site may have an anti-theft chain mechanism, it is recommended to save the image and upload it directly (img-X4NrMcxN-1585918484040) (linux.assets / image-20200213142552626.png)]

Uninstall mariadb

  • Method 1: rpm -e --nodeps packages to uninstall

  • 法2: yum remove mariadb*

File upload tools: lrzsz, rz

wget download file

wget can download files on the network directly to the current Linux folder

Specify file name: wget -O file name download address

For example: wget -O wordpress.zip http://www.centos.bz/download.php?id=1080

Network basic settings

View ip: ip addr

Network configuration file address:

vi /etc/sysconfig/network-scripts/ifcfg-ens33重启网络:

View the system version:

cat /etc/redhat-relase

View the ports used by the system

netstat -antple | grip 8080

netstat -tunlp | grep 8080

firewalld configuration

Introduction:
Centos6 使用的是iptables,Centos7 使用的是filewall
iptables 用于过滤数据包,属于网络层防火墙。
firewall 能够允许哪些服务可用,那些端口可用...属于更高一层的防火墙。
Configuration file location:
  • System configuration file: / usr / lib / firewalld / services

  • Port configuration file: etc / firewalld / zones / public.xml

[External chain image transfer failed, the source site may have an anti-theft chain mechanism, it is recommended to save the image and upload it directly (img-kQ5DfuKP-1585918484041) (linux.assets / image-20200211101941767.png)]

  • User configuration file: / etc / firewalld
Common commands

##查看状态
firewall-cmd --state
#查看过滤列表
firewall-cmd --list-all
#查看开启的端口号:
firewall-cmd --zone=public --list-ports
#开启80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent  
#开启3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent  
#重启防火墙:
firewall-cmd --reload
#开启防火墙:
systemctl start firewalld
Parameter Description
  1. firwall-cmd: is a tool provided by Linux to operate firewall

  2. –Permanent: indicates set to persistent;

  3. –Add-port: Identifies the added port

  • In addition, there is the concept of Zone in firewall, which can make specific ports into specific zone configuration files
 ```shell
 例如:添加8010端口
 firewall-cmd --zone=public --permanent --add-port=8010/tcp
 --zone=public:指定的zone为public;
 如果--zone=dmz 这样设置的话,会在dmz.xml文件中新增一条。
 ```

Add port by modifying configuration file

<?xml version="1.0" encoding="utf-8"?>
<zone>   
<short>Public</short>  
<description>For use in public areas.</description>   
<rule family="ipv4">    
<source address="122.10.70.234"/>     
<port protocol="udp" port="514"/>     
<accept/>   
</rule>   
<rule family="ipv4">     
<source address="123.60.255.14"/>     
<port protocol="tcp" port="10050-10051"/>     
<accept/>  
</rule>  
<rule family="ipv4">     
<source address="192.249.87.114"/> 放通指定ip,指定端口、协议     
<port protocol="tcp" port="80"/>     
<accept/>   
</rule>
<rule family="ipv4"> 放通任意ip访问服务器的9527端口     
<port protocol="tcp" port="9527"/>     
<accept/>   
</rule>
</zone>

The above configuration file can be well seen:
1. Add the required rules, open source IP is 122.10.70.234, port 514, protocol tcp;
2. Open source IP is 123.60.255.14, port 10050-10051 Protocol tcp;
3. Open source IP is arbitrary, port 9527, protocol tcp;

rpm:Yeqiang52!

yum:

Other commands

View version information:

 cat /etc/centos-release 

lrzsz-0.12.20.tar.gz is a third-party tool that supports uploading and downloading on the command-line interface under Linux, which can play a very convenient role

# rz   
选择文件进行上传

# sz 文件名
sz后面跟文件名可以进行文件从linux上面下载

  • Give permissions to the shell file: chmod a + x file name
    1. Force shutdown process:

​ kill -9 id

Wget can download files from the specified address

For example download mysql: wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz


Some of the above content is collected from the Internet. If copyright is violated, please contact me to delete it immediately

The article is only a rough summary of the commonly used commands of linux. There are many parameters that are not explained too much. If you are interested, you can read the books related to linux. Since I am also a linux white, if you find that a part of the text is wrong, please Educate me

If you are a Linux beginner, it is recommended to install several commonly used software familiar commands, such as installing jdk, mysql, tomcat, redis ... a good way to learn when you are familiar with commands during the software installation process

Published 8 original articles · won 3 · views 186

Guess you like

Origin blog.csdn.net/qq_42641075/article/details/105299816