Common Linux commands under Ubuntu
1. View/open/close firewall status
Check firewall status: sudo ufw status is
on: sudo ufw enable is
off: sudo ufw disable
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:
1./Root Directory: 2. A quick reference table of linux main directories
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
Five, auto-completion commands
Six, common options of ls command
There 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
Seven, the use of ls wildcard
Eight, the characteristics of the linux file directory
touch .File name--------Create a hidden file
Nine, cd
Comparison of cat and more commands
cat 123.txt
more 123.txt
tree command, cp command, mv command
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
the 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
that contains D (ignore case) in 123.txt:
echo command
- Echo will display the content specified by the parameter in the terminal, usually used in conjunction with redirection
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):
at the end of text a, append hello world:
redirect (output) the file list on the desktop to text a:
change the desktop The directory structure is redirected to (appended to) text a: