First, the basic operation
1. Important Shortcut keys
Tab |
Complete commands, directories, parameters, filenames, etc. |
CTRL + C |
Force the current program to terminate |
Ctrl+d |
Keyboard input end or exit terminal |
CTRL + Z |
Put the current program in the background and revert to the foreground using FG |
CTRL + A |
Move the cursor to the beginning of the input, equivalent to the home key |
Ctrl+e |
Moves the cursor to the end of the input line, equivalent to the END key |
Ctrl+k |
Remove from cursor position to end of line |
Alt+backspace |
Delete a word forward |
Shift+pgup |
Scroll the terminal display up |
Shift+pgdn |
Scroll down the terminal display |
Arrow key "Up" key |
Restore the commands you have entered before |
2. Wildcard characters
* |
match 0 or more characters /td> |
|
match any one of the characters |
[list] |
match any single character in the list |
[!list] |
|
[C1-C2] |
match any single character in c1-c2 such as: [0-9][a-z] |
[str1,str2,...] |
match str1 or str2 (or more) one of the strings |
{c1. C2} |
match all the words in c1-c2 such as {1..10}, note that each character is matched once |
3, man
1 Mans <name> Man
Second, user and file Rights management
1. User Management
1 W.H.O.[Options] ... [File |parameter 1 parameter 2] #显示当前已登录的用户信息2 sudoAddUser <name>#添加新用户3 sudo passwd<name> #为用户设置密码, no <name>The current user's password is set4 su<name>#切换登录用户5 groups<name>#查看用户属于哪些用户组6 sudoUsermod-g <g-name> <u-name>#为用户添加用户组7 sudoDeluser <u-name>--remove-home #删除用户并删除该用户的Home目录
2. File permissions
1 ls [Options] ... [File] ... #列出文件的信息 2chown [options] ... [owner] File name #修改文件的所有者 3chgrp [options] ... User group File ... #修改文件所属的用户组 4chmod [options] ... Mode... File ... #修改文件的读写执行权限
Iii. File and directory operations
1. Directory operation
1 Tree <name> #以树形结构显示目录的结构, note that the tree tool needs to be installed on its own 2 cd <name> #切换到指定目录 3 pwd #获取当前目录的绝对路径 4 mkdir <name> #创建新目录
2. File operation
1 Touch<name>#创建空白文件2 CP<name> <p-name>#复制文件到指定目录3 RM[Options] ... <name> #删除文件或空目录, plus-The r parameter can be deleted unless an empty directory4 MV<name> <p-name>#移动文件到指定目录, or modify the file name5 Cat[Options] <name>#正序打印文件内容6 TAC[Options] <name>#倒序打印文件内容7 NL[Options] <name>#添加行号并打印文件内容8 More<name>#分页查看文件内容9 Less<name>#类似于moreTen Head<name>#查看文件开头的内容 One Tail<name>#类似于head但是是从末尾开始 A file<name> #查看文件类型
Iv. environment variables and file search
1. Variables
1 declare var #声明变量 2 var=XXX #给变量赋值 3echo $var # Print variable contents 4 unset var #删除一个环境变量
2. Environment variables
1 set #显示当前shell所有环境变量 2env #显示与当前用户相关的环境变量 3 Export # Displays variables exported from the shell to environment variables
3. Search path and Order of command
1 echo $PATH #输出的内容为系统查找命令的各个路径 to find and invoke the first command found in the ordered order
4. Add a custom path to path
1 path= $PATH:p ath-name #临时修改当前shell的PATH变量
5. File Search
1 whereis <name> #搜索二进制文件, man Help files or source code files 2locate <name> #查找指定目录下不同类型的文件 3 which <name> #用来确定是否安装了某个指定的软件 4find [path] [opt] [Act] # Search for files that meet the specified criteria in the specified directory
Five, file packaging and decompression
Common file Compression Package/Unzip tool:
1 Zip Unzip 2 rar 3 Tar
See man manual for details
Vi. file system operations and Disk Management
1. View disk and directory capacity
1 DF #查看磁盘容量, often plus the-h parameter to print in an easy-to-read manner
2. Disk operation
1 DD #用于转换和复制文件 2Mount [opt] [sour] [dir] #挂在磁盘到指定目录 3 Umount [dir] #卸载已挂载的磁盘 4sudo fdisk [opt] #查看硬盘分区表信息
Command execution sequence control and piping
1. Order of command execution
1 cmd1;cmd2;cmd3, ..... #按顺序执行cmd1, CMD2,... 2 cmd1 && cmd2 #只有cmd1执行成功才执行cmd23 cmd1 | | cmd2 #无论cmd1成功与否, all executed cmd24 cmd1 | cmd2 #将cmd1的输出作为cmd2的输入
2, common to the pipeline command
1 Cut #打印每一行的某一字段 2grep #在文本中或标准输入中查找匹配字符串 3 WC number of #统计并输出一个文件中行, words, and bytes 4 Sort #将输入按照一定方式排序后输出 5uniq #用于过滤或者输出重复行
Eight, simple text processing
1. Text Processing commands
1 TR #删除或替换一段文本信息中的某些文字 2col #将Tab换成对等数量的空格, or reverse this operation 3join #将两个文件中包含相同内容的那一行合并在一起 4 Paste #将多个文件合并在一起, and tab-separated
Ix. Data Flow Redirection
1. Simple redirection
1 cmd > name #将cmd1执行的结果重定向到指定文件或指定设备中, replace the original content 2 cmd >> name #类似于 > , but this is appended to the end of the file instead of replacing 3 cmd < name #方向与 > opposite 4 cmd << name #方向与 > > instead
2. Redirect to multiple files
1 Tee name1 name2 ... #将cmd1的执行结果重定向到标准输出和指定文件中
3. Fully shielded command output
1 cmd >/dev/null #将命令的执行结果导入" black hole " file
Ten, Software Installation
1, online installation
1 apt-get Common Assemblies for #用于安装, updates, uninstalls, and so on
tools |
Description |
I Nstall |
followed by a package name for installing a package |
update |
update local software |
UPGR Ade |
upgrades all locally updatable packages, but there are dependencies that do not upgrade |
Remove |
remove installed packages, including those that are dependent on the removed software, but do not contain a File |
purge |
Remove packages and configuration files |
clean |
Remove downloaded to a local installed package |
Note: This article is only as a study note in the process of the author's study, more detailed content please refer to related books or related documents
Linux Shell Getting Started commands and actions (note)