Common Linux basic commands

1, base

  pwd view the current working directory

  . * Wildcard any; .., on a path; current path; / root path; |, pipeline breaks, the next command on a result of a command

  Environment Variables: Add the environment variable: export PATH = $ PATH: / sbin, add / sbin in the current PATH; to see the current environment variable: echo $ PATH

  ip: Check ip: ifconfig; set ip: netconfig

  Transfer files, use xshell client

    rz: Move to Linux, Windows file

    sz: Move to Windows, Linux file

2, folder manipulation

  Switching paths: cd

  Create a folder: mkdir

  To delete a folder: rmdir

3, file operations

  Lists the files in the current directory: ls, ll

  Create a file: touch

  Delete files: rm, (rm -rf caution)

  Mobile: mv file newPath

  Copy: cp file newPath

  Find: find -type f -name file path name; -type type, f general, d folder

  Edit the file 

    vi filename, i enter insert mode edit content, esc (Exit) to exit the insert mode, exit the editing: wq (w save, q quit, forced, mandatory caution!)!

    Copy a row yy, Paste p; delete a row dd, revocation go back u,  

    Find / Content, a n, a shift (key) + n

  View the file contents

    cat -n, line numbers; head -n, n Pre document; tail -n, n-file row; tail -f xxx.log, monitoring logs; head -100 xxx.log | tail -50, use the pipe View files middle section

  Find content in files 

    grep content files, such as grep "admin" login.log, often with the use and tail tail -f xxx.log | grep "admin"

    You can also use regular expressions, grep -E regular, regular reference links:  https://deerchao.cn/tutorials/regex/regex.htm

4, switching users: su - user name, such as su - admin

5, file permissions chmod

  chmod u + w file

    ---- u, file owner; g, file owning group; o, others

    ---- +, increasing the authority; - to reduce the rights

    ---- w, write permissions; r, read permission; x, execute permissions

  chmod -R 777 Folder: Open all permissions for this folder, caution

6, packing

  zip file: Compression: zip xxx.zip file; unzip: unzip xxx.zip

  tar.gz file: Compression: tar -zcvf xxx.tar.gz file; unpack: tar -zxvf xxx.tar.gz

  tar file: Compression: tar -cvf xxx.tar target file; decompressing: tar -xvf xxx.tar       

7, software installation

(1) binaries are installed

  ./xxx.bin

(2) other software installed rpm

  rpm -qa | grep program name: View what computers are installed with the program

  rpm -ivh package names: Software Installation

  rpm -Uvh upgrade package: software upgrade  

  rpm -e program-name: Uninstaller

8, find the process

  Find a process :: ps -ef | grep "program name"

  Forced to shut down a process: kill -9 process ID or process name

9, see the port

  netstat -anop | grep 8080, see the 8080 occupation of the port process information

  netstat -ano, port numbers to view all

10, resource-related

  top: View CPU, memory usage, similar to Windows Task Manager

  df: disk usage statistics, including mount points (Disk C / D / E), the total size, the use of size 

  du: displays the file size occupied by the current path



Guess you like

Origin www.cnblogs.com/yjh1995/p/12122267.html