[Linux] explanation of basic operation instructions

Fleeting years and mysterious moon 2022-05-14 15:04:04 阅读数:601

linuxexplanationbasicoperationinstructions

brief introduction :

        Linux The directory structure and file organization form of the operating system are organized in the form of multi fork tree . Why? ? It's not just Linux , Many mainstream operating systems are multi tree structures .

The advantage of it is : Easy to find , And all documents have a unique identification method ; Because each child node has only one parent node , So the path from the leaf node to the root node is unique , conversely , The path from the root node to the leaf node is also unique .

Let's introduce the basic instructions :

ls Instructions :

1、 A separate ls : Display the files in the current directory ( file name ).

2、ls -l It can be abbreviated as :ll ; Show more attribute information , It's like windows Property view of .

3、ls -a : Show . The first hidden file and normal file .

4、ls /home/xx/test.c  : View the file through the absolute path .

  Because the path is absolutely unique , So you can enter anywhere , The disadvantage is too much trouble .

5、ls ../xx/ : View files through relative paths .

  The disadvantage is that the path changes , The current path will fail , Absolute path is recommended .

6、ls -d / ls -d xx : Show only information about this directory , By default . .

7、ls -n :  Replace users with numbers .

8、ls -r / ls -R : Display all files under each directory ,-r Show current directory , -R Displays the subdirectories of each directory under the current directory .

 clear 、pwd、whoami、nano、tree Instructions :

1、clear : Clear the screen .

2、pwd :  Displays the directory where the current path is located ,windows Overhead path

Ordinary users :/home/xxx It's called a multi person dormitory xxx The user's home working directory , Default path after login ;

root user :/root It's called a single room dormitory , Is the main working directory of the Administrator .

' / ' be called Linux The path separator for , Keypad 159 ;

 ' \ ' yes windows The delimiter , Keypad 357.

3、whoami : View the current user .

4、nano : Notepad tools .

5、tree : Print each document in a tree structure , You need to configure the environment .

 mkdir、touch Instructions :

1、touch xxx : Create files in the current directory , coca xxx.txt 、xxx.c.

2、mkdir xx : Create directory , Create a directory in the current directory , The path can be added after .

3、mkdir -p xx/xx/xx : Create directory recursively .

 rm Instructions :

1、rmdir xx : Delete directory , Can only be used to delete empty directories .

2、rm -r xx: Recursive delete , file 、 Everything such as non empty directory can be deleted , Delete ordinary files rm xx that will do , When deleting some files that are out of permission or protected, you will be asked to enter Y / N .

3、rm -rf xx : Mandatory deletion , Popular on the Internet " rm -rf / " Delete the library and run away , This is not recommended .

4、rm * or rm ./ *: Delete all files in the current directory ,' * ' Is a wildcard , Suggest using rm ./ * ,rm -r * Delete directory . 

cd Instructions :

1、cd xxx : Entry directory .cd + ls amount to windows Double click the directory in to enter

2、cd .. : Return to parent directory , In the directory ' . ' Represents the current directory ,' .. ' On behalf of the parent directory .

3、cd - : Go back to the previous Directory , Repeat the operation to jump back and forth .

 4、cd ~ : Go to your home directory ( This user ), ' ~ ' Represents the root directory .

man Instructions :

1、man : Command Reference Manual .

2、man 3 xxx : Check the manual of the corresponding command .

Library function -- 3

command  -- 2

system call -- 1 , No default 1 Manual No .

3、cman : Chinese version of the manual , You need to configure the environment .

cp Instructions :

1、cp test.c xx : Copy files test.c To xx Under the path , windows Medium ctrl c + ctrl v.

2、cp -r :  replica catalog ,-r It means recursion .

3、cp -rf * : Copy all files .

4、cp -rf *.txt : Copy all txt file , You can change to other types .

mv Instructions :

mv It has the function of cutting and renaming , You can cut the directory without ' -r ' .

1、mv a.txt b.txt : take a.txt Rename as b.txt.

2、mv test.c xx: Cut the file to xx Under the path .

Other functions and cp The same command .

cat 、tac Instructions :

1、cat xx.txt : Show text content .

2、cat -n xx.txt : Display text with line number .

3、tac : Flashback display .

more 、less 、head、 tail Instructions :

1、more xxx : Look back before .

2、less xxx : It can be viewed up and down .

3、head xxx : Default view before 10 That's ok .

4、head -n3 xxx or head -3 xxx : Adjustable to see how many lines .

5、tail xxx : After default view 10 That's ok , Usage and head identical .

6、head -1010 xxx | tail -10 : The line number can be controlled by pipeline .

echo Redirection instructions :

1、echo '' xxx '' :  The output content is displayed on the display by default .

2、echo '' xxx ''  > test.txt : Redirect content output to txt In file , What is redirection ? It refers to the file that should be output to the display , The results are printed into the file , This is called redirection . Every redirect will empty , To write .

3、>> : Append redirection , You don't have to empty the contents , Append to the end .

cat And echo The difference between :cat Followed by the filename , echo Follow the string .

ps: Why can they be output directly to the display , Instead of the header file ,c In the program, the header file must be wrapped before printing .

The reason is that the operating system will open three files by default :stdin 、stdout 、stderr , stay printf This interface encapsulates fwrite Such as function , So it can output .

date 、cal Instructions :

date It's a time order ;

1、 A separate date : Original display .

2、date +%Y / %m / %d --- %H:%M:%S : Print mm / DD / yyyy , Minutes and seconds , In the middle of the / - : Can be replaced with any symbol .

3、date +%s : Check the timestamps , from 1970/01/01--08:00 Start , Because of geographical time difference 8;

4、date -d @ Time stamp : Display the original time according to the timestamp .

5、cal : Look at the calendar of the month .

6、cal 2020 : Check the calendar of the current year .

7、cal -3 : See the former 、 in 、 One month later .

find 、which 、 whereis  Instructions :

1、find xxx -name aa : stay xxx Under the path, search by name with aa The file of .

2、find xxx -size 1000 : find xxx The size under the path is 1000 The file of , You can add -size 1010 , Point to 1000 - 1010 Size range .

3、find xxx type d : stay xxx Find... In the path d Properties file .

4、which + command : The command to find the command .

5、whereis + command : Find all with ls Information about .

grep Instructions :

grep It's a line filter tool .

1、grep ' hello ' test.txt : stay test.txt View all files with 'hello' The line of .

2、grep -n ... : The basis above is to display the line number .

3、grep +v : Inversely select the information content .

4、grep -i ' xxx ' : Ignore ' xxx ' Case lookup .

zip 、 tar Instructions :

1、zip xx.zip + Address : By default, only one layer of surface is packaged , The package file name is xx.zip,+r Recursive packaging .

2、unzip xx.zip : decompression xx.zip file .

3、unzip xx.zip -d + Address : Unzip to this address .

-z : Pack it up gzif Format

-f : Use the document name , Followed by the document name

-c : pack

-x : decompression

tar pack / Compress , Do not open view .

4、tar czf xx.tgz : Pack it up tgz Type file .

5、tar xzf xx.tgz -C xx/ : Unzip to xx Under the path .

6、tar tf xx.tgz : Do not decompress to view .

-t : see

alias 、bc 、uname 、history Instructions :

1、alias my='ls-al' : Another name , hold  'ls-al' The name for my.

2、bc : Floating point operation -- Linux Calculator

3、uname -r : View information about your computer and operating system , can -a To view more .

4、history : View history command .

Create delete user adduser 、 userdel 、file 、shutdowm command :

1 、 Create user :1、adduser xx New user name 2、passwd xx Input password ( No echo )

Change the password of the existing account directly passwd that will do .

2 、 Delete user :userdel -r xx Delete xx user .

3、file xxx : View the file properties .

4、shutdowm : To turn it off .

Hot key :

1、Tab : Quick completion .

2、Tab both parties : Prompt command .

3、 Up and down keys : History commands .

4、ctrl + d : Fallback user .

5、ctrl + c : Stop .

6、ctrl + R: Keyword search history command .

版权声明:本文为[Fleeting years and mysterious moon]所创,转载请带上原文链接,感谢。 https://javamana.com/2022/134/202205141458377438.html