“This is the 21st day of my participation in the August Text Challenge.

The vast sea of millions, thank you for this second you see here. Hope my article is helpful to you!

May you keep your love and go to the mountains and seas in the coming days!

Linux basic commands

Yesterday we Linux some basic commands such as shutdown and restart, operating directory command learning, today we are ready to file some commands in detail learning!

Basic command – Operation file

Create a file

Command: touch file name

There can be one or more files.

Specific demonstration:

Note: How do you determine what type a file is?

Linux has different colors for different files and directories

File color Detailed instructions
white Common file
Dark blue Directory (folder)
green Executable file
red Compressed package
cyan Link, equivalent to Windows shortcut
orange Device file

Check the file

Command:

Cat [option] File to view: View all the contents of the file, which is opened in read-only mode.

More File to view: Displays all contents of a file in separate screens. The more instruction is a text filter based on ⅵ editor, which displays the content of a text file page by page in a full-screen manner

Less Files to view: The less command is used to view files in separate screens. Similar to the more command, but more powerful than the MORE command, the less command supports various display terminals. The less command does not load the entire file at one time, but loads the content according to the display requirements, which is efficient for displaying large files.

Head [option] File to view: Head is used to display the beginning of the file. By default, the head command displays the first 10 lines of the file.

Tail [option] File to view: tail is used to print the contents of the tail of the file. By default, the tail directive displays the last 10 lines of the file.

Parameter details:

parameter describe
The cat filename View all contents of a file
More filename You can view all contents of a file in separate screens

Enter key: line by line display

Space bar: page by page display

Q: Exits the view mode
The head file name Look at the first 10 lines of the file
Head -n Number of lines file name View the number of lines specified in the file
Tail filename Look at the last 10 lines of the file
Tail-n Specifies the file name View the number of lines specified in the file
Less filename View all contents of a file

-n: Displays the line number

Q: Exits the view mode

Specific demonstration:

Edit file contents

Command:

Vim file: Vi is similar to VIm here. Vim has the power of program editing and can be regarded as an enhanced version. In general system administration maintenance vi is sufficient, if you want to use code highlighting can use vim.

Vim edits files according to three modes:

model describe
Command mode You can move the cursor and delete characters

Open the file to enter the mode
Edit mode Characters can be entered for editing operations
The bottom line You can enter commands to search, save, and exit files

Parameter details:

The command describe
i Inserts a character before the current cursor
a Inserts characters after the current cursor
o Inserts a character on the line below the current cursor
yy In command line or bottom line mode: Copy the current line
p In cli or bottom line mode: Paste
dd In cli or bottom line mode: Delete the current line
u Command line or bottom line mode: Undo
wq Save and exit
q! Forced exit without saving
wq! Forced save exit

G The cursor is positioned at the first character at the end of the file

Specific demonstration:

Compress and decompress files

Learn about the extension of compressed files in the VIRTUAL machine

extension classification
. Zip or rar Compressed package under Windows
.tar Package files under Linux
.gz Compressed files under Linux
.tar.gz Packaged zip file under Linux

Command:

  • Tar [option] Compressed package name one or more files: tar command is a package command. The final package file is a tar.gz file.
  • Tar [option] -c directory of the file to be decompressedThe tar command can also be an unzip command, decompressing the file to a specified directory.

Parameter details:

Tar compression options:

-c: create Creates a package file

-v: indicates the verbose information, which is used to display information

-z: gzip, compressed file format

-f: file, used to set the name of the compressed file

It is usually written like this:

tar -czf fish.tar.gz fish.java eee
Copy the code

Tar decompress options:

-x: extract, used to decompress files from compressed packages

-c: change To switch to a specified directory and decompress the package

-v: displays the detailed decompression process

-f: specifies the file to be decompressed

It is usually written like this:

tar -xvf fish.tar.gz  -C aaa
Copy the code

Specific demonstration:

Compression:

Extract:

conclusion

I believe that you have a certain understanding of the basic command of the Linux system, looking forward to waiting for the next chapter in Linux advanced command learning bar!

Of course, there are more commands to watch next time! Welcome to the next chapter!

Let’s refuel together, too! I am not just, if there is any missing, wrong place, also welcome you to criticize in the comments of talent leaders! Of course, if this article is sure to help you a little, please kindly and lovely talent leaders to give a thumb-up, favorites, one key three even, thank you very much!

Here, the world is closed for today, good night! Although this article is over, I am still here, never finished. I will try to keep writing articles. The coming days are long, why fear the car yao ma slow!

Thank you all for seeing this! May you live up to your youth and have no regrets!