1.1.1
ls command
L LS (list) Feature: List Directory contents
L format: ls [parameter] [file or directory]
All files and directories under-A or--all. Note Hidden files, special directories,. And..
-l Use a detailed format list.
-T is sorted with file and directory change times.
-R Reverse Sort
--help online Help.
L Common
Ls-l--This command is very common and provides a simplified version of the command ll
Ls-al
ll/home/--Displays the contents of the specified directory
1.1.2
CD Command
L CD (change directory) feature: Switch directory
L Syntax: CD [catalogue]
L Common
CD ~, Current user Directory
CD/, root directory
CD-The directory that was last accessed
Cd.. , Top level Directory
CD, default current User directory
1.1.3
pwd Command
L PWD (print working directory) features: Show working directory
1.1.4
mkdir Command
L mkdir (Make Directoriy) feature: Create directory
-P Parent Directory is not present in the case of Mr. Cheng-parent directory (parents)
-V displays detailed information during command execution
MKDIR-PV./abc/123
1.1
File Management
-
File Browsing1.1.1
Cat Command
L Cat (catenate) Feature: Display text file contents
L Syntax:
Cat file that displays all the contents of the specified file
1.1.2
More Commands
L More Features: page displays the contents of the file, but also support the direct jump switch and other functions.
L Syntax: more file
L operation
Enter down n rows, which need to be defined. Default is 1 rows
SPACEBAR scroll down one screen or ctrl+f
B return to previous screen or ctrl+b
Q Exit more
More/root/install.log
1.1.3
Less command
L Less Function: page displays the contents of the file, the operation is more detailed.
L Syntax: less [parameter] file
-m shows a percentage similar to the more command
-N Displays the line number of each line
L operation
SPACEBAR: Forward one page or PAGE down
b: Back one page or page up
D: Forward Half page
U: Back Half page
Enter: Forward line or arrow key down
Y: Back row or arrow key up
/string: Search Down
? string: Search Up
V: Enter the VIM editor
Left and RIGHT ARROW keys: equivalent to horizontal scroll bar
Q: Exit
Less-mn/root/install.log
1.1.4
Tail Command
L function: Used to display the end of the specified file, do not specify the file, as input information for processing. Common view log files.
L Format: tail[necessary parameters [selection parameters] [file]
-n< lines > Display rows
-F Loop Read
Ping 127.0.0.1 > Ip.log &
Tail-f Ip.log
L & To run in the background, otherwise occupy the terminal
L CTRL + C exit
1.2
File Management
-
file Operations1.2.1
CP Command
L CP (copy) function: Copy files or directories.
L Syntax: CP [parameters] [source file or directory] [destination file or directory]
-R or--recursive recursive processing, the files under the specified directory and subdirectories are processed together.
CP./abc./xxx #无法复制目录
Cp-r./abc./xxx #复制目录必须使用-R parameter
CP Ip.log Ip2.log
CP Ip.log Ip2.log
Cp-b Ip.log Ip2.log
1.2.2
MV Command
L MV (move) function: Moves or renames an existing file or directory.
L Syntax: MV [source file or directory] [destination file or directory]
-F or--force if the destination file or directory is duplicated with an existing file or directory, overwrite the existing file or directory directly.
mv./abc/123/./xxx/111 #移动一个空目录 or a file
CP Ip.log./abc/ip.log
MV Ip.log./abc/ip.log
Mv-f Ip.log./abc/ip.log
1.2.3
RM Command
L RM (Remove) RM function: Delete files or directories.
L Syntax: RM [-dfirv][--help][--version][file or directory ...]
-F or--force forces the deletion of files or directories.
-R or-R or--recursive recursively handles all files and subdirectories under the specified directory.
Rm./ip2.log
Rm-f./ip2.log #强制删除文件
Rm-f./xxx
Rm-rf./xxx #强制删除目录
1.2.4
Find Command
L Find function: Find files or directories.
L Syntax: Find [directory ...] Parameters
-NAME specifies a string as a template style for finding a file or directory.
find/root/-name ' test* '
1.3
Document editing1.3.1
vi or VIM command1.3.1.1
Basic Operations
L Enter "Vim file name" into "General mode"
L Press "I" to enter "Insert mode" from General mode
L Press "ESC" to exit from "Insert mode" to "normal mode"
In "General mode", enter ": Wq" to exit the edit.
1.3.1.2
VI Basic Concepts
L Basically VI can be divided into three states, which are command mode, insert mode and bottom line mode, the functions of each mode are distinguished as follows:
1) command-line mode
Controls the movement of the screen cursor, the deletion of characters, words, or lines, moving and copying a section and entering insert mode, or to last line mode.
2) Insert mode
Only in the Insert mode, you can do text input, press "esc" to return to the command line mode.
3) Bottom Line mode
Save or Exit VI, or you can set the editing environment, such as looking for a string, listing line numbers ... such as
1.3.1.3
Common Commands
Group |
Command |
Describe |
Insert (enter into insert mode from normal mode) |
I |
Insert before the cursor |
SHIFT + I |
Start insertion at the current line of the cursor |
A |
Insert after cursor |
Shift + A |
Inserts at the end of the current line of the cursor |
O |
Inserts a new row on the next line of the current line of the cursor |
SHIFT + O |
Inserts a new row on the previous line of the cursor's current row |
|
Copy or paste (in insert mode) |
Yy |
Single-line replication Move the cursor to the line that will be copied |
Nyy |
MultiRow replication Move the cursor to the first line that will be copied |
P |
Paste Move the cursor to the line where you want to paste |
|
Positioning |
Gg |
To the first line of text |
SHIFT + G |
To the last line of text |
|
Delete |
Dd |
Delete the cursor in the row |
Ndd |
Delete N rows |
|
Exit |
: Q |
Exit VI (when no modifications are made) |
: q! |
Force quit does not save |
: W |
Save does not exit |
: Wq |
Exit after saving |
1.3.2
Pipeline |
L Linux provides pipe symbol "|". The function is the output of "command 1" and will be the input of "command 2". Typically used with the grep command.
L Format: Command 1 | Command 2
1.3.3
grep Command
grep full name is the global Regular expression Print, which represents the globally regular expressions version
L Function: Used to filter/search for specific characters. The use of regular expressions can be used in conjunction with a variety of commands, the use of very flexible.
L Format: grep [option] pattern [file]
-I or--ignore-case #忽略字符大小写的差别.
#格式: grep parameter filter criteria file
#查看install the contents of the. log file that contain the "control" character
Grep-i Control/root/install.log
#格式: Other Commands | grep parameter Filter conditions
Cat/root/install.log | Grep-i Control #在cat命令输出结果基础上, filter
1.4
system Commands1.4.1
PS Command
L Function: PS command is the abbreviation of process status. Provides a one-time view of the process. and execute the PS command at the moment of process information.
L Format: ps[parameter]
-E The effect of this parameter is the same as specifying the "A" parameter, showing all programs
-F Display uid,ppip,c and Stime fields
Ping 127.0.0.1 > Ip.log &
Ps-ef | Grep-i Ping
1.4.2
Kill command
L Kill function: Remove the program or work in execution.
L Syntax: kill [Parameter] [program]
-L < Information number > If the < information number > option is not added, the-l parameter lists all information names.
Kill-9 indicates forced termination
Format: kill-9 PID
Kill-9 4199
1.4.3
ifconfig Command
L Function: Display network device
L Command: Ifconfig
1.4.4
ping command
L Function: Test the connectivity with the target host
L Command: Ping host name or IP address
1.5
Backup compression: Tar command
L TAR function: file backup compression
L Syntax: Tar command
-C Create a parameter directive (create) for a compressed file--Compression
-X unlocks a compressed file's parameter directive (extract)--unzip
-Z is required to compress with gzip
-V compression in the process of displaying files (verbose)
-F Use file name, immediately after F to receive the file name (file)
Common decompression parameter combination: ZXVF
Common compression parameter combination: ZCVF
L Compression
TAR-ZCVF Itheima.tar./itheima/
L Decompression
Rm-rf./itheima #将 "Itheima" Remove and unzip
ll | Grep-i Itheima
TAR-ZXVF./itheima.tar
1.6
Power off Restart
L Linux CentOS restart command: reboot
L Linux CentOS shutdown command: Halt immediately shut down the machine
1.7
file permissions: chmod command
L chmod (change mode) function: Changes the permissions of a file or directory.
L Syntax: chmod [parameters] [< permission range >< symbol >< permission code;]
-R or--recursive recursively handles all files and subdirectories under the specified directory.
n the representation of the permission range is as follows:
U:user, which is the owner of a file or directory.
G:group, which is the group to which the file or directory belongs.
O:other, except for files or directory owners or groups, other users belong to this range.
A:all, which is the entire user, contains the owner, the owning group, and other users.
N Symbol:
+ Add Permissions
-Cancel Permissions
n the section on the permission designator, listed below:
R: Read permission, the number code is "4".
W: Write permission, the number code is "2".
X: Execute or toggle permissions, the number code is "1".
-: No permission, number code is "0".
mkdir xxx
ll | grep xxx
chmod u-rwx xxx #取消xxx目录, user "read and write execute" permission
chmod g-rwx xxx #取消xxx目录, group "read and write execute" permission
chmod 777 XXX #给xxx目录添加所有权限
L Linux Permissions format:< types >< users >< groups >< other users >
1.8
Network configuration:1.8.1
VIM Command Configuration
L View NIC Configuration Cat/etc/sysconfig/network-scripts/ifcfg-eth0
The summary information is as follows:
Device=eth0 #网卡名称 Type=ethernet #网卡类型 Onboot=yes #是否开机启动网卡 Bootproto=static #静态获取IP, other values: DHCP (if you set DHCP under red not required) ipaddr=192.168.44.100 #ip地址 gateway=192.168.44.2 #网关 netmask=255.255.255.0 #子网掩码 |
1.8.2
Setup Settings
Setup
L 1) Select "Network Configuration"
L 2) Select "Device Configuration"
L 3) Select "First Nic"
L 4) Set IP address and other details
1.9
Command Summary and help
L Internal command: Part of the shell parser (system boot is loaded directly into memory)
CD switch directory (change directory)
PWD Displays the current working directory (print working directory)
Help
L External command: File program independent of Shell parser (standalone executable file)
LS display file and directory list
mkdir Creating a directory (make Directoriy)
CP Copy file or directory (copy)
L View Help documentation
Internal command: Help + command (Help CD)
External command: Man + command (man ls)
L do not have to deliberately remember the command classification, development, if you need to view the command parameters, first use man, if there is no result, then use Help.
Simple commands for Linux