Common Linux commands under Ubuntu

Common Linux commands under Ubuntu

1. View/open/close firewall status

Check firewall status: sudo ufw status is
Insert picture description here
on: sudo ufw enable is
Insert picture description here
off: sudo ufw disable
Insert picture description here

Second, the installation command

Installation: sudo apt-get install openssh-server
New file: touch file name
New folder: mkdir folder name

Three, linux directory structure:


Insert picture description here
1./Root Directory: 2. A quick reference table of linux main directories
Insert picture description here

3.Linux commonly used commands:

 1. 创建多级目录:
mkdir -p lib/com/src/java


 2. 删除多级目录:
 rm -r lib
 3. 强制性删除,没有任何提示:
 rm -f lib
 注意:rm命令删除文件后,无法恢复

Fourth, the use of editor vi

* Two modes of vi:
Command mode: When vi is opened, the default is command mode. To switch to input mode, you need to press a or i. In command mode, everything typed on the keyboard at this time is treated as a command by vi.

Input mode: Input mode is used to input content to the file. You can press a or i from the command mode to enter the input mode.
After entering the input mode, you can press the keyboard to input at will.

If you want to save after the input is completed, you must first return to the command mode (because saving is also a command).
In the input mode, press the ESC key to return to the command mode.
Note: pay attention to the lower left corner of the screen, when there is no prompt message or file name and other information
in command mode, when in input mode, prompt – INSERT – how to save in command mode:
:wq save and exit
: w only save but not launch
:q Only exit without saving, come in and check it out without change
: q! Force exit without saving
:wq! Save and force exit

Insert picture description here

Five, auto-completion commands

Insert picture description here

Six, common options of ls command

Insert picture description hereInsert picture description hereThere can be:
ls -lh ------arrange the files vertically and display the size
ls -lah --------arrange the files vertically, and display the size and all hidden files

Insert picture description here

Seven, the use of ls wildcard

Insert picture description hereInsert picture description here

Eight, the characteristics of the linux file directory

Insert picture description here
touch .File name--------Create a hidden file

Nine, cd

Insert picture description here

Comparison of cat and more commands

Insert picture description here

cat 123.txt
more 123.txt

tree command, cp command, mv command

Insert picture description hereInsert picture description here
Insert picture description hereInsert picture description hereInsert picture description here

Insert picture description hereInsert picture description hereInsert picture description hereInsert picture description hereInsert picture description here

grep command

  • The grep command is a powerful terminal search command that allows you to search for patterns in text.
Options meaning
-n Show matching line and line number
-v Show all lines that do not include matching text
-i Ignore case

Find
Insert picture description herethe line and line number that contains D (ignore case) in 123.txt : find the line and line number that does not contain d in 123.txt : find the line
Insert picture description herethat contains D (ignore case) in 123.txt:
Insert picture description here

echo command

  • Echo will display the content specified by the parameter in the terminal, usually used in conjunction with redirection
    Insert picture description here

Redirect >> and >>

  • Linux allows the command execution result to be redirected to a file

among them:

>表示输出,会覆盖文件原有的内容
>>表示追加,会将内容追加到已有文件的末尾

Create a new text a, and enter hello in it (it will overwrite the original content of the file):
Insert picture description here
at the end of text a, append hello world:
Insert picture description here
Insert picture description hereredirect (output) the file list on the desktop to text a:
Insert picture description here
Insert picture description here
change the desktop The directory structure is redirected to (appended to) text a:
Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44421869/article/details/107115576
Recommended