Linux common instruction set

Linux common commands Collection

First, file processing command

1.cd Change directory

  • cd directory name
  • cd ~ home directory switching
  • cd / change to the root directory
  • cd - Switch to the previous operation of the directory
  • cd .. or switch to the parent directory cd ../
  • cd., or switch to the current directory cd ./

2.ls display the current directory of all the files and folders

  • ls -a show hidden files containing ( . + filename), including files and folders
  • ls -l (can also use the "ll") display detailed information files / folders
  • ls -R recursively display directories and files in the directory
  • ls -t display by modification time
  • ls -r reverse display

3.pwd shows the path of the current file

When the directory is a link
- pwd -p displays the physical path of the current file, ie the actual path, rather than the link path
- pwd -L displays the current default path, that path link

4. Create a file or folder

(1) touch to create a file

  • touch the file name; space-delimited file name can create multiple files at once
  • touch want to create a file named "a b.txt" file, the file name must be enclosed in single quotes cited. eg: touch 'a b.txt'

(2) mkdir create a folder

  • mkdir folder name; space-separated folder names can create multiple folders
  • mkdir -p folder name / folder name to create a recursive folder
    eg: mkdir a / b / c / d

5. Delete a file or folder

(1) rm delete files

  • rm file name

(2) delete the folder

  • rm -rf folder name (you can delete a non-empty folder)
  • rmdir folder name (only delete empty folders)

6.cp copy a file or folder

  • cp Copy to copy the file or folder path to the path / (filename or folder)
    EG: cp /aa/1.txt /bb/2.txt will 1.txt copied to aa bb directory under the directory, and renamed 2.txt
  • Path / (folder name) cp -r to copy folder path Copy to copy folders recursively

7.mv move a file or directory to modify the file name

  • Path / (file name or folder) Music Videos file to be moved or move to the folder path
    eg: mv 001.txt ../002.txt mobile plus renamed
    eg: mv 001.txt ./002.txt renamed
    eg: mv a / home / mobile folder (default mobile recursively)
    EG: mv a / home / b mobile folder (default recursive movement) and renamed b

8. Review the contents of the file

(1) cat view the file contents

  • cat filename
  • cat -A file name display hidden content
  • cat -n the file name display line numbers

(2) more page display file contents

  • more filename
  • enter to view the contents of the next line
  • f key / spacebar to see the next page
  • q / Q Quit

Head (3) head display file

  • head -5 5 displays the first line of the file name of the file
    before the line head -n 5 5 significant file filename
  • head filename (10 lines before the default display file)

(4) tail end of the file is displayed

  • tail -5 file name is displayed after 5 lines of a file
    after 5 lines tail -n 5 significant file filename
  • tail file name (the default display 10 lines of the file)
  • Dynamic display additional content file tail -f, when files are deleted after the monitor off monitor
  • Tail -F dynamic display additional content files, when files are deleted after the monitoring, surveillance waiting, waiting for the monitoring of the same name file

9. File Search Command

(1) find find files or directories

  • -name filename find directory / folder name to find files based on file names
    eg: find / -name 1.txt find files in the root directory named 1.txt file
    (if you do not remember the file name, can be used instead of the characters? * instead of string)
  • find the file directory -size file size to find files based on file size
    eg: find / -size 204800 Find files larger than the 100M
  • find directory -type file types to find files by file type

(2) grep to find a character in a file and output

  • grep character or string file directory
  • eg: grep pub /teach/1.txt -c character appears total number of rows
  • eg: grep public /teach/1.txt -n line number
  • eg: grep public /teach/1.txt -i case-insensitive
  • eg: grep public /teach/1.txt -v output for all characters except for the field

(3) which displays the directory (absolute path and alias) system command

  • which command

(4) whichis9.4. Directory search command configuration file directory path and help documentation

  • whichis command (execute permissions: All users)

Second, management command

1. Disk Management Command

(1) df to view the file disk space

Role: Linux file system used to view status information, display capacity of each partition, used the amount of unused information such as volume and mount point. Look remaining space

  • df -h show disk space usage and displayed in a readable form
  • df -a Show all partitions of size 0 comprising
  • df -k kb units to show partition
  • df -m display unit to M partition size

Size (2) du view the file or directory

  • Size du -a display of files and subfolders
  • du -h Display M Kb degrees easily form
  • du -s capita statistics
  • The total size of the du / root / -sh statistical root directory
  • * Du command-oriented file, counting only the space occupied by the file or directory.

(3) free View using state memory and swap space

  • free -k: display in KB, the default display is in KB
  • free -m: display in MB
  • free -g: display in GB

2. The process management command

(1) ps View system processes

  • ps a: show processes from all users
  • ps u: displays the user name and start time
  • ps x: displays processes without a controlling terminal
  • ps e: all processes, including a process without a controlling terminal
  • ps l: length format
  • ps aux # View all system processes using BSD operating system format, unix

eg: ps -u or ps -l to view detailed information belonging to its own process
eg: ps -aux | grep sam view user sam process performed
eg: ps -ef | grep init specified process information

(2) pstree display process tree

  • pstree -u displays the user's progress
  • pstree -p display process PID

(3) top view the system load status

  • top -d specified refresh seconds
    eg: 10 seconds specified refresh
    * average load of the CPU
    (monocytes) Load average CPU load average parameter within five minutes of one minute fifteen minutes
    or less 1 represents normal load, when high load is greater than when 1 is greater than the representative 2 (configuration needs to be increased)
    (polynuclear) * when the number of nuclei

(4) kill kill shutdown process

  • kill -1 restart the process
  • kill -9 PID to kill a process

3. User management commands and modify user permissions

(1) Create a user

  • useradd username

(2) modify the user password

  • passwd username

(3) Delete User

  • userdel username

(4) user switching

  • su username switch user
  • exit Exit the current user

(5) chmod rights management

  • Three basic permissions
    r read permissions (the Read)
    w write permission (the Write)
    the X-execute permissions (execute)

Guess you like

Origin www.cnblogs.com/yu753526303/p/12532743.html