Linux basic commands (commonly used finishing)

software operation command

  • Install software: yum install xx
  • Uninstall software: yum remove xxx
  • Search software: yum serach xxx
  • Clean cache: yum clean packages
  • List installed: yum list
  • Package info: yum info xxx

Server hardware resource information

  • memory: free -m
  • hard disk: df -h
  • load: w/top
  • Number of CPUs and cores: cat /proc/cpuinfo

ps: control the average load at 0.6~0.7

Enter image description

file manipulation commands

  • View the files in the directory: ls
  • New file: touch
  • New folder: mkdir(mkdir -p test/test1)
  • Delete files and directories: rm, rm -r, rm -rf
  • Copy: cp(cp file path)
  • move: mv(mv file path)
  • pwd: display path

File search, find, read

  • Read from the end of the file: tail
  • Read from the head of the file: head
  • Read the whole file: cat
  • Paging read: more
  • Controllable paging: less
  • Search keyword: grep
  • Find files: find
  • Statistics: wc

file decompression

  • File compression (tar): tar -cf target.tar source
  • File compression (gz): tar -czf target.tar.gz source, tar -czvf target.tar.gz source
  • File decompression (tar): tar -xf target.tar
  • File decompression (gz): tar -xzf target.tar.gz, tar -xzvf target.tar.gz

System User Operation Commands

  • Add users: useradd, adduser
  • Delete user: userdel, userdel -r (completely delete user)
  • Set password: passwd

firewall

  • Installation: yum install firewalld
  • Start: service firewalld start
  • Check status: service firewalld status
  • Turn off or disable the firewall: service firewalld stop/disable

Available commands after starting the firewall :

  • Check status: firewall-cmd --state
  • View all zones in the firewall: firewall-cmd --get-zones
  • View the default zone: firewall-cmd --get-default-zone
  • List configuration information for all zones: firewall-cmd --list-all-zone
  • View the configuration information of a zone: firewall-cmd --zone=zone --list-all
  • Query all services in a zone: firewall-cmd --list-service
  • Query whether a service exists: firewall-cmd --query-service=service name
  • Query all ports in a zone: firewall-cmd --list port
  • Query whether a port exists: firewall-cmd --query-port=port/tcp (or http)
  • Add service: firewall-cmd --add-service=service name
  • Remove service: firewall-cmd -remove-service=service name
  • Add port: firewall-cmd --add-port=port/tcp|udp|sctp|dccp
  • Remove the port: firewall-cmd -remove-port=port/tcp (or udp...)

The above command can be specified to be executed in a certain area, for example: firewall-cmd --zone=work --add service=ssh, which means adding an ssh service under the work area. If no zone is specified, the above commands are executed in the default zone. Generally, the default zone is under public, so firewall-cmd --zone=public --add service=ssh is equivalent to firewall-cmd --add-service=ssh.

Privilege Escalation and File Upload and Download

  • Privilege escalation command: sudo

  • Configure user privilege escalation

Enter image description

Execute the visudo command with the root account, enter the configuration file, and add a user.

  • download file:
  1. wget source address
  2. curl -0 filename source address
  • Upload the file to the server: scp test.txt [email protected] :/tmp

  • Download the file from the server: scp [email protected] :/tmp/test.txt ./

  • Upload and download under windows:

  1. yum install lrzsz
  2. Upload: sz test.txt
  3. download: rz

soft chain

ln -s 目标执行程序 /usr/bin/执行程序

Soft-link the target execution program to the /usr/bin directory, and the system scans the programs in this directory by default. E.g:

ln -s ~/maven/bin/mvn /usr/bin/mvn

At this point, you can execute maven commands anywhere.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325818764&siteId=291194637