• 周五. 12月 9th, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Linux most commonly used instruction encyclopedia! Let’s see. Do you have it?

[db:作者]

1月 6, 2022

Linux Many of the common commands in English are required , I’ll share it here linux The basic command commonly used when getting started , I hope I can help you .

File directory directive

pwd Instructions

Basic grammar :

pwd

The path used to display the current directory

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

ls Instructions

Basic grammar :

  • ls [ Options ] [ Directory or file ]
  • Common options
  • -a : Display all files and directories in the current directory , Include hidden .
  • -l : Display information as a list , amount to ll

Practical operation cases :

List all the files and directories in the current directory :

 Practical dry goods !!Linux Common command sharing

 

cd Instructions

Basic grammar :

  • cd [ Parameters ]

Function description : Switch to the specified directory

  • Common parameters

Absolute path ( With / The starting list ) And relative path ( A directory that begins with a directory name , Start from the current directory )

cd ~ perhaps cd : Go back to your home directory

cd .. Go back to the previous level of the current directory

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

mkdir command

Basic grammar :

  • mkdir [ Options ] Directory to create
  • Common options

-p : Create multi-level directory

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

rmdir Instructions

Basic grammar :

rmdir Catalog

Function description : Delete an empty directory

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

touch Instructions

Basic grammar :

touch List of file names

Function description : Create one or more empty files

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

cp Instructions

Basic grammar :

  • cp [ Options ] source dest
  • Common options :

-r : Recursively copy entire folder

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

rm Instructions

Basic grammar :

  • rm [ Options ] Files or directories to delete
  • Common options :

-r : Recursively delete entire folder

-f : Force delete without prompting

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

mv Instructions

Basic grammar :

  • mv oldNameFile newNameFile ( Function description : rename )
  • mv /temp/movefile /targetFolder ( Function description : Moving files )

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

cat Instructions

Basic grammar :

  • cat [ Options ] The name of the file to view
  • Common options

-n : According to the line Numbers

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

 Practical dry goods !!Linux Common command sharing

 

 Practical dry goods !!Linux Common command sharing

 

more Instructions

Basic grammar :

more The name of the file to view

Functional specifications :more The instruction is based on VI Editor’s text filter , It displays the contents of the text file page by page in a full screen way .

Shortcut key :

 Practical dry goods !!Linux Common command sharing

 

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

less Instructions

Basic grammar :

less The name of the file to view

Functional specifications :less The command is used to view the file content in different screens , Its function and more Instruction similar , But compared to more More powerful instructions , Support various display terminals .less Command when displaying the contents of a file , It is not displayed until the entire file is loaded at one time , Instead, load the content according to the display needs , High efficiency for displaying large files .

Shortcut key :

 Practical dry goods !!Linux Common command sharing

 

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

head Instructions

Basic grammar :

  • head file ( Function description : Default view file header 10 Row content )
  • head -n 5 file ( Function description : View header 5 Row content ,5 Can be any number of lines )

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

tail Instructions

Basic grammar :

  • tail file ( Function description : View the end of the file by default 10 Row content )
  • tail -n 5 file ( Function description : Check the end of the file 5 Row content ,5 Can be any number of lines )

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

echo Instructions

Basic grammar :

echo [ Options ] [ Output content ]

Function is introduced : Output variable or constant content to the console

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

> Instructions

Basic grammar :

View instructions > Target file

Functional specifications : Write the result of the previous view instruction to the target file , If the target file does not exist , The new .

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

>> Instructions

Basic grammar :

View instructions >> Target file

Functional specifications : Append the result of the previous view instruction to the target file , If the target file does not exist , The new .

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

 Practical dry goods !!Linux Common command sharing

 

Time date command

date Instructions

Basic grammar :

1) date( Function description : Display current time )

2) date +%Y( Function description : Show current year )

3) date +%m( Function description : Show current month )

4) date +%d( Function description : Display the current day )

5) date “+%Y-%m-%d %H:%M:%S”( Function description : Display year, month, day, hour, minute and second )

6) date -s String time ( Function description : Setting date )

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

cal Instructions

Basic grammar :

cal [ Options ]( Function description : No option , Show calendar of the month )

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

Search for instructions

find Instructions

find The instruction will recursively traverse its subdirectories from the specified directory , Display the qualified files or directories on the terminal .

Basic grammar :

find [ Search scope ] [ Options ]

Option description :

  • -name: Search by name , Support for wildcards .
  • -user: Search by user name
  • -size: Find by file size

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

 Practical dry goods !!Linux Common command sharing

 

 Practical dry goods !!Linux Common command sharing

 

locate Instructions

Basic grammar :

locate The file name to search for

explain :locate Instruction can quickly locate the file path in the whole system .locate The command uses all the file names and paths in the pre established system locate Fast location of given files based on Database .locate Instructions do not need to traverse the entire file system , Fast query speed . In order to ensure the accuracy of query results , Administrators must update regularly locate moment .

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

grep Instructions

Basic grammar :

  • grep [ Options ] Find the content of the source file for
  • Common options :

-n: Show matching lines and line numbers

-i: Ignore case

explain :grep Filter lookup , Pipe, ,“|”, Indicates that the processing result output of the previous command is passed to the subsequent command processing .

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

Compression and decompression instructions

gzip Instructions

Basic grammar :

gzip file

Functional specifications : Compressed files , Compress the file to *.gz The file is stored in the directory where the original file is located , After successful compression, the original file will be deleted . Used to compress a single file .

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

gunzip Instructions

Basic grammar :

gunzip file

Functional specifications : Extract file command , After decompression, it will be stored in the directory where the original compressed file is located , And delete the original compressed file .

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

zip Instructions

Basic grammar :

  • zip [ Options ] XXX.zip What will be compressed

Function description : Compress the specified file or directory into XXX.zip file , Used to compress all file structures .

  • Option description :

-r: Recursive compression , Compress directory

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

unzip Instructions

Basic grammar :

unzip [ Options ] XXX.zip

Common options :

-d Catalog : Specify the directory to store the extracted files

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

tar Instructions

Basic grammar :

tar [ Options ] XXX.tar.gz [ Packaged content ]

Function description : Package or unzip files

Option description :

  • -c: produce .tar.gz Package files
  • -v: Show details
  • -f: Specify the compressed filename
  • -z: Pack and compress
  • -x: decompression .tar.gz file
  • -C: Specify which directory to unzip to

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

 Practical dry goods !!Linux Common command sharing

 

Group management instruction

Linux Basic introduction of group :

stay linux Each user in must belong to a group , Can’t be independent of the group , You can change the user’s group .

stay linux Each file in has an owner 、 Group in 、 Other groups , You can also change the file group .

file / Owner of directory

It’s usually the creator of the document , Who created the file , Naturally become the owner of the file , By default, the owner’s group is the same as the file’s group .

View the file owner and group instructions

Basic grammar :

ls –ahl file name

(a-all,h-human,l-list)

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

Modify file owner instructions

Basic grammar :

chown New owners file name

chown newowner:newgroup file Modify the user’s owner and all groups at the same time

-R If it is a directory, it makes all the sub files or directories under it recursively effective

Functional specifications : Change the file owner to the specified user .

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

Modify the group instruction of the file

Basic grammar :

chgrp New group name file name

-R If it is a directory, it makes all the sub files or directories under it recursively effective

Function description : Change the file group to the specified group

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

Rights management instructions

Basic introduction of authority

The permissions mentioned here are file and directory permissions . stay Linux in , Every file and directory has its own access rights , Through the file list, you can see .

 Practical dry goods !!Linux Common command sharing

 

RWX Detailed explanation of authority

rwx Apply to documents

1) [ r ] Representative readable (read): Can read , see

2) [ w ] Representative may write (write): You can modify , But it doesn’t mean that you can delete the file , The prerequisite for deleting a file is to have write permission to the directory where the file is located , To delete the file .

3) [ x ] Representative executable (execute): Can be executed

rwx To the directory

1) [ r ] Representative readable (read): Can read ,ls View directory contents

2) [ w ] Representative may write (write): You can modify , Create… In directory + Delete + Rename Directory

3) [ x ] Representative executable (execute): You can go to the directory

rwx Show by number

r=4( namely 2²),w=2( namely 2¹),x=1( namely 2º)

Rights management instructions

Modify file / Directory permission instructions chmod

The first way : adopt r、w、x Change authority

1) chmod u=rwx,g=rx,o=x File directory name

2) chmod o+w File directory name

3) chmod a-x File directory name

explain :u、g、o、a Each represents the owner of the file 、 Users in the file group 、 Other groups of users 、 All users =、+、- They represent setting permissions 、 Increase the permissions 、 Remove authority

The second way : Change authority by number

chmod A set of three numbers File directory name

explain :r=4 w=2 x=1 rwx=4+2+1=7

Practical operation cases :

 Practical dry goods !!Linux Common command sharing

 

 Practical dry goods !!Linux Common command sharing

 

 Practical dry goods !!Linux Common command sharing

 

 Practical dry goods !!Linux Common command sharing

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注