1.ls [Options] [Directory name | list all directories and files in the relevant directory
-a 列出包括.a开头的隐藏文件的所有文件-A 通-a,但不列出"."和".."-l 列出文件的详细信息-c 根据ctime排序显示-t 根据文件修改时间排序---color[=WHEN] 用色彩辨别文件类型 WHEN 可以是‘never‘、‘always‘或‘auto‘其中之一 白色:表示普通文件 蓝色:表示目录 绿色:表示可执行文件 红色:表示压缩文件 浅蓝色:链接文件 红色闪烁:表示链接的文件有问题 黄色:表示设备文件 灰色:表示其它文件
2.MV [Options] source file or directory directory or multiple source files | Move or rename a file
-b 覆盖前做备份-f 如存在不询问而强制覆盖-i 如存在则询问是否覆盖-u 较新才覆盖-t 将多个源文件移动到统一目录下,目录参数在前,文件参数在后eg: mv a /tmp/ 将文件a移动到 /tmp目录下 mv a b 将a命名为b mv /home/zenghao test1.txt test2.txt test3.txt
3.CP [Options] source file or directory directory or multiple source files | Copy the source file to the destination file, or copy multiple source files to the destination directory.
-r -R 递归复制该目录及其子目录内容-p 连同档案属性一起复制过去-f 不询问而强制复制-s 生成快捷方式-a 将档案的所有特性都一起复制
4.SCP [parameter] [original path] [Target path] | Copying files and directories between Linux servers
-v 详细显示输出的具体情况-r 递归复制整个目录(1) 复制文件: 命令格式: scp local_file [email protected]_ip:remote_folder 或者 scp local_file [email protected]_ip:remote_file 或者 scp local_file remote_ip:remote_folder 或者 scp local_file remote_ip:remote_file 第1,2个指定了用户名,命令执行后需要输入用户密码,第1个仅指定了远程的目录,文件名字不变,第2个指定了文件名 第3,4个没有指定用户名,命令执行后需要输入用户名和密码,第3个仅指定了远程的目录,文件名字不变,第4个指定了文件名 (2) 复制目录: 命令格式: scp -r local_folder [email protected]_ip:remote_folder 或者 scp -r local_folder remote_ip:remote_folder 第1个指定了用户名,命令执行后需要输入用户密码; 第2个没有指定用户名,命令执行后需要输入用户名和密码;eg: 从 本地 复制到 远程 scp /home/daisy/full.tar.gz [email protected]:/home/root 从 远程 复制到 本地 scp [email protected]/172.19.2.75:/home/root/full.tar.gz /home/daisy/full.tar.gz
5.rm [Options] file | deleting files
-r 删除文件夹-f 删除不提示-i 删除提示-v 详细显示进行步骤
6.touch [Options] file | Create an empty file or update the file time
-a 只修改存取时间-m 值修改变动时间-r eg:touch -r a b ,使b的时间和a相同-t 指定特定的时间 eg:touch -t 201211142234.50 log.log -t time [[CC]YY]MMDDhhmm[.SS],C:年前两位
7.PWD View current Path
8.CD changing the current directory
- :返回上层目录.. :返回上层目录回车 :返回主目录/ :根目录
9.mkdir [options] directory ... | Create a new directory
-p 递归创建目录,若父目录不存在则依次创建-m 自定义创建目录的权限 eg:mkdir -m 777 hehe-v 显示创建目录的详细信息
10.rmdir Delete Empty Directory
-v 显示执行过程-p 若自父母删除后父目录为空则一并删除
11.rm [options] File ... | One or more files or directories
-f 忽略不存在的文件,不给出提示-i 交互式删除-r 将列出的目录及其子目录递归删除-v 列出详细信息
12.echo: Display Content
-n 输出后不换行-e 遇到转义字符特殊处理 eg: echo "he\nhe" 显示he\nhe ehco -e "he\nhe" 显示he(换行了)he
13.cat [Options] [File]..| Display the entire file at once or create a file from the keyboard or merge several files into one file
-n 编号文件内容再输出-E 在结束行提示$
14.tac | Reverse Display
15.more | View article content by page, read the file backwards from the front, so load the entire file at startup
+n 从第n行开始显示-n 每次查看n行数据+/String 搜寻String字符串位置,从其前两行开始查看-c 清屏再显示-p 换页时清屏
16.less | You can view the content of the article by screen, and not load the entire file before viewing it.
-m 显示类似于more命令的百分比-N 显示行号/ 字符串:向下搜索“字符串”的功能? 字符串:向上搜索“字符串”的功能n 重复前一个搜索(与 / 或 ? 有关)N 反向重复前一个搜索(与 / 或 ? 有关)b 向后翻一页d 向后翻半页
17.nl [Options] ... [File] ... | Automatically add line numbers to output content
-B
-B A line number (similar to cat-n) is listed regardless of whether there is a blank line
-B t empty line is not column lines (default)
-N has ln rn RZ three parameters, respectively, the most left display, the right side of the display does not add 0, the right side of the display plus 0
18.head [Parameter] ... [File] ... | Displays the beginning of the file, starting with 10 lines by default
-v 显示文件名-c number 显示前number个字符,若number为负数,则显示除最后number个字符的所有内容-number/n (+)number 显示前number行内容,-n number 若number为负数,则显示除最后number行数据的所有内容
19.tail [Required parameters] [select parameters] [file] | Show end of File
-v 显示详细的处理信息-q 不显示处理信息-num/-n (-)num 显示最后num行内容-n +num 从第num行开始显示后面的数据-c 显示最后c个字符-f 循环读取
20.VI Editing files
: W filename Saves the article with the specified file name: Wq Save and exit: q! Do not save and Force Exit command line mode function key 1) insert mode Press "i" switch into insert mode "insert mode", press "I" to enter the insertion mode is the beginning of the cursor from the current position of the input file, press "a" into the insertion mode, the current cursor from the location of the next position to start typing; When "o" enters insert mode, it inserts a new line and enters text from the beginning of the beginning. 2) switch from insert mode to command line mode by pressing the "esc" key. 3) Move the cursor VI can be directly with the cursor on the keyboard to move up and down, but the normal VI is a lowercase English letter "h", "j", "k", "l", respectively, control the cursor left, bottom, upper and right one grid. Press "ctrl"+"b": The screen moves one page to the back. Press "ctrl"+"f": The screen moves one page to the front. Press "ctrl"+"u": The screen moves the half page toward the back. Press "ctrl"+"d": The screen moves the half page toward the front. "0" by number: Moves to the beginning of the article. Press "g": Move to the end of the article. Press "$": Moves to the end of the line where the cursor is located. Press "^": Move to the beginning of the line where the cursor is located press "w": The cursor jumps to the beginning of the next word by pressing "e": The cursor jumps to the end of the next word by "b": The cursor goes back to the beginning of the previous word by pressing "#l": the cursor moves to the first # position of the line, such as: 5l,56l. 4) Delete text "x": Each time you press, delete the "back" character at the cursor location. #x: For example, "6x" represents the "after" 6 characters of the location where the cursor was deleted. "x": Uppercase X, each time it is pressed, deletes the "front" character at the location of the cursor. "#X": for example, "20x" represents the "front" 20 characters of the location where the cursor was deleted. "dd": Delete the line where the cursor is located. "#dd": Delete # line 5 from the line where the cursor is located) copy "yw": Copies the character at the end of the cursor to the buffer. "#yw": Copy the # Word to buffer "yy": Copy the row of the cursor to the buffer. "#yy": for example, "6yy" represents a copy of 6 lines of text from the line where the cursor is located. "p": Paste the characters in the buffer to the cursor location. Note: All copy commands related to "Y" must be mated with "P" to complete the copy and paste function. 6) Replace "r": replaces the character at which the cursor is located. "r": Replaces the character where the cursor is located until the "esc" key is pressed. 7) Reply to the last action "u": If you mistakenly execute a command, you can press "u" immediately to go back to the previous action. Multiple replies can be performed by pressing "U" multiple times. 8Change "cw": Change the word at the end of the cursor to "c#w": For example, "c3w" means change 3 characters 9) jumps to the specified row "ctrl"+"g" lists the line number of the line where the cursor is located. "#G": for example, "15g", which means moving the cursor to the beginning of the 15th line of the article.
21.which Executable file name | View the location of the executable file, and see if the system command exists and its location in the path specified by the PATH variable
22.whereis [-BMSU] [BMS directory name-f] File name | Locating executables, source code files, Help files in file system locations
-b 定位可执行文件。-m 定位帮助文件。-s 定位源代码文件。-u 搜索默认路径下除可执行文件、源代码文件、帮助文件以外的其它文件。-B 指定搜索可执行文件的路径。-M 指定搜索帮助文件的路径。-S 指定搜索源代码文件的路径。
23.locate | Quickly search for files by searching the database
-r 使用正规运算式做寻找的条件
24.find Find [PATH] [option] [action] | Find files in the file tree and make corresponding processing
Options and Parameters: 1. Time-related options: A total of-atime,-ctime and-mtime, and-amin,-cmin and-mmin, with-mtime stating-mtime N: = number, meaning "within one day" prior to n days the contents of the file were altered;-mtim E +n: Lists the file name of the content that was changed before n days (excluding n days itself);-mtime-n: Lists the file names that have been changed within n days (including the N-day itself). -newer File:file as an existing file, listing a new file name of 2 than file. Parameters related to the user or group name:-uid n = = number, this number is the customer's account ID, that is, uid-gid N: = number, this number is the ID of the group name, that is, Gid-user name:name user account name! For example, Dmtsai-group Name:name is a group name, such as users;-nouser: The owner of the file does not exist/etc/passwd person! -nogroup: The owning group looking for the file does not exist in the/etc/group file! 3. Parameters related to file permissions and names:-name filename: Search for files named filename (wildcard)-size [+-]size: Search for files larger than size (+) or small (-). This size has the following specifications: C: Represents the byte K: 1024bytes. So, to find a larger file than 50KB, that is "-size +50k"-type type: Search for the types of files, types mainly include: General regular archives (f) Device archives (b, c) catalogue (d ) Nexus (L) socket (s) FIFO (p)-perm mode: Search file Permissions "just equals" mode's file, this mode is a property value similar to chmod, for example,-rwsr-xr-x The property is 4755! -perm-mode: Search for file Permissions "must all include Mode's permission" file, for example, we want to search-rwxr--r--that is 0744 of the files, using-perm-0744, when the permissions of a file-rwsr-xr-x, that is, 4755, will also be listed, because-rwsr-xr-x attributes have been included in the-rwxr--r--properties. -perm +mode: Search file permission "contains any mode permission" of the file, for example, we search for-rwxr-xr-x, that is-perm +755, but a file property is-RW-------will be listed, because he has-rw .... The attribute exists! 4. Additional action:-exec Command:command For other instructions, the-exec can be followed by additional instructions to process the search results. -print: Print the results to the screen, this action is a preset action! Eg:find/-perm +7000-exec ls-l {} \; , the extra instruction starts with-exec, with \; end {} instead of what was found earlier | Xargs-i the default front output with {} instead of Eg:find. -name "*.log" | Xargs-i MV {} test4
25.grep ' Regular expression ' file name | Search for text with regular expressions and print matching lines
-c 只输出匹配行的计数。-I 不区分大小写(只适用于单字符)。-l 只显示文件名-v 显示不包含匹配文本的所有行。-n 显示匹配行数据及其行号
25.file | Determine file type
26.gzip [-cdtv#] File name | Compressed, uncompressed, source files no longer exist
-d 进行解压缩-c 将压缩的数据输出到屏幕上-v :显示原档案/压缩文件案的压缩比等信息-# :压缩等级,-1最快,但压缩比最差,=9最慢,但压缩比最好
27.gunzip | Unzip
28.BZIP2 | Compression, decompression
-d :解压-z :压缩-k :保留源文件-c :将压缩的过程产生的数据输出到屏幕上!-v :可以显示出原档案/压缩文件案的压缩比等信息;-# :与 gzip 同样的,都是在计算压缩比的参数, -9 最佳, -1 最快!
29.BZCAT read data without decompression
30.tar [main options + Secondary options] File or directory | Multiple catalogs or archives packed and compressed into one big file
主选项: -c 建立打包档案,可搭配 -v 来察看过程中被打包的档名(filename) -t 察看打包档案的内容含有哪些档名,重点在察看『档名』就是了; -x 解打包或解压缩的功能,可以搭配 -C (大写) 在特定目录解开辅选项: -j 透过 bzip2 的支持进行压缩/解压缩:此时档名最好为 *.tar.bz2 -z 透过 gzip 的支持进行压缩/解压缩:此时档名最好为 *.tar.gz -v 在压缩/解压缩的过程中,将正在处理的文件名显示出来! -f filename -f 后面要立刻接要被处理的档名! -C 目录 这个选项用在解压缩,若要在特定目录解压缩,可以使用这个选项。 --exclude FILE:在压缩打包过程中忽略某文件 eg: tar --exclude /home/zenghao -zcvf myfile.tar.gz /home/* /etc -p 保留备份数据的原本权限与属性,常用于备份(-c)重要的配置文件 -P(大写) 保留绝对路径,亦即允许备份数据中含有根目录存在之意;eg: 压 缩:tar -jcvf filename.tar.bz2 要被压缩的档案或目录名称 查 询:tar -jtvf filename.tar.bz2 解压缩:tar -jxvf filename.tar.bz2 -C 欲解压缩的目录
31.exit exiting the current shell
32.logout Exit Login Shell
33.shutdown-h now
34.users Displays the user currently logged on to the system
35.who login in native user with source
-H或--heading 显示各栏位的标题信息列。
36.W users who log on to the computer and the programs they run
-s 使用简洁格式列表,不显示用户登入时间,终端机阶段作业和程序所耗费的CPU时间。-h 不显示各栏位的标题信息列。
37.write sending messages to users who are currently online
38.wall send messages to all users who log on to the machine
39.last View User Login log
40.lastlog View last login time for each user
41.finger [Options] [users] [user @ host] | View user Information
-s 显示用户的注册名、实际姓名、终端名称、写状态、停滞时间、登录时间等信息-l 除了用-s选项显示的信息外,还显示用户主目录、登录shell、邮件状态等信息,以及用户主目录下的.plan、.project和.forward文件的内容。-p 除了不显示.plan文件和.project文件以外,与-l选项相同
42.hostname Viewing host names
43.alias II = "Ls-l" | Add Alias
44.unalias II | Clear aliases
45.useradd [-U UID] [-G initial Group] [-G secondary Group] [-C description Bar] [-D Home directory Absolute Path] [-s shell] User account name | New user
-M 不建立用户家目录!(系统账号默认值)-m 建立用户家目录!(一般账号默认值)-r 建立一个系统的账号,这个账号的 UID 会有限制 -e 账号失效日期,格式为『YYYY-MM-DD』-D 查看useradd的各项默认值
46.passwd | Change Password
-l 使密码失效-u 与-l相对,用户解锁-S 列出登陆用户passwd文件内的相关参数-n 后面接天数,shadow 的第 4 字段,多久不可修改密码天数-x 后面接天数,shadow 的第 5 字段,多久内必须要更动密码-w 后面接天数,shadow 的第 6 字段,密码过期前的警告天数-i 后面接『日期』,shadow 的第 7 字段,密码失效日期使用管道刘设置密码:echo "zeng" | passwd --stdin zenghao
47.userdel Delete User
-r 用户文件一并删除
48.chage [-LDEIMMW] Account name | Modify the related properties of a user's password
-l 列出该账号的详细密码参数;-d 后面接日期,修改 shadow 第三字段(最近一次更改密码的日期),格式YYYY-MM-DD-E 后面接日期,修改 shadow 第八字段(账号失效日),格式 YYYY-MM-DD-I 后面接天数,修改 shadow 第七字段(密码失效日期)-m 后面接天数,修改 shadow 第四字段(密码最短保留天数)-M 后面接天数,修改 shadow 第五字段(密码多久需要进行变更)-W 后面接天数,修改 shadow 第六字段(密码过期前警告日期)
49.usermod [-cdegglsulu] username | Modify a user's related properties
-c 后面接账号的说明,即 /etc/passwd 第五栏的说明栏,可以加入一些账号的说明。-d 后面接账号的家目录,即修改 /etc/passwd 的第六栏;-e 后面接日期,格式是 YYYY-MM-DD 也就是在 /etc/shadow 内的第八个字段数据啦!-f 后面接天数为 shadow 的第七字段。-g 后面接初始群组,修改 /etc/passwd 的第四个字段,亦即是GID的字段!-G 后面接次要群组,修改这个使用者能够支持的群组-l 后面接账号名称。亦即是修改账号名称, /etc/passwd 的第一栏!-s 后面接 Shell 的实际档案,例如 /bin/bash 或 /bin/csh 等等。-u 后面接 UID 数字啦!即 /etc/passwd 第三栏的资料;-L 冻结密码-U 解冻密码
50.id [Username] | View user-related ID information and can also be used to determine whether a user exists
51.groups View Login user-supported groups, the first output group is a valid group
52.NEWGRP Toggle Active Group
53.groupadd [-G GID] Group name | Add Group
-g 设定添加组的特定组id
54.groupmod [-G GID] [-n group_name] Group name | Modify group Information
-g 修改既有的 GID 数字-n 修改既有的组名
55.groupdel [GroupName] | Delete a group
56.gpasswd | Group Administrator Features
root管理员动作: -gpasswd groupname 设定密码 -gpasswd [-A user1,...] [-M user3,...] groupname -A 将 groupname 的主控权交由后面的使用者管理(该群组的管理员) -M 将某些账号加入这个群组当中 -gpasswd [-r] groupname -r 将 groupname 的密码移除群组管理员动作: - gpasswd [-ad] user groupname -a 将某位使用者加入到 groupname 这个群组当中 -d 将某位使用者移除出 groupname 这个群组当中
57.CHFN Modify Personal Information
58.mount [-t vfstype] [-O options] Device dir
-ro 采用只读方式挂接设备-rw 采用读写方式挂接设备eg:mount /home/mydisk.iso /tmp/mnt 通过mnt访问mydisk内的内容
59.umount un-mount
60.cut
-b :以字节为单位进行分割。这些字节位置将忽略多字节字符边界,除非也指定了 -n 标志。-c :以字符为单位进行分割。-d :自定义分隔符,默认为制表符。-f :与-d一起使用,指定显示哪个区域。
61.sort
-n 依照数值的大小排序。-o<输出文件> 将排序后的结果存入指定的文件。-r 以相反的顺序来排序。-t<分隔字符> 指定排序时所用的栏位分隔字符。-k 选择以哪个区间进行排序。
62.WC statistics Specify the number of bytes, words, and lines in the file, and display the results of the statistics output
-l filename 报告行数-c filename 报告字节数-m filename 报告字符数-w filename 报告单词数
63.uniq Remove adjacent duplicate rows in a file
Empty/new file, redirect content into
&> correct and Error redirect past
Append later
64.set Display environment variables and normal variables
65.ENV Display Environment variables
66.export changing the normal variable into an environment variable
67.unset Delete an environment variable
AAA () {} define function
68.read
-p 接提示字符-t 接等待的秒数
69.declare, typeset
-i 声明为整数-a 声明为数组-f 声明为函数-r 声明为只读
70.ulimit restricting some system resources for users
-f 此 shell 可以建立的最大档案容量 (一般可能设定为 2GB)单位为 Kbytes eg: ulimit -f 1024 限制使用者仅能建立 1MBytes 以下的容量的档案
71.DF [Options] [file] | Displays the free space for the specified disk file, and if no file name is specified, the free space for all currently mounted file systems will be displayed
-a 显示全部文件系统-h 文件大小友好显示-l 只显示本地文件系统-i 显示inode信息-T 显示文件系统类型
72.DU [Options] [file] | Displays disk usage space for each file and directory
-h 方便阅读的方式-s 只显示总和的大小
73.LN [parameters] [source file or directory] [destination file or directory] | One file to create a synchronized link in another location
-s 建立软连接 -v 显示详细的处理过程
74.diff [Parameter] [file 1 or directory 1] [file 2 or directory 2] | Compare individual files or directory contents
-b 不检查空格字符的不同。-B 不检查空白行。-i 不检查大小写-q 仅显示差异而不显示详细信息eg: diff a b > parch.log 比较两个文件的不同并产生补丁
75.date [Parameter] ... [+ format] | Displays or sets the date and time of the system
%H 小时(以00-23来表示)。 %M 分钟(以00-59来表示)。 %P AM或PM。%D 日期(含年月日)%U 该年中的周数。date -s “2015-10-17 01:01:01″ //时间设定date +%Y%m%d //显示前天年月日date +%Y%m%d --date="+1 day/month/year" //显示前一天/月/年的日期date +%Y%m%d --date="-1 day/month/year" //显示后一天/月/年的日期date -d ‘2 weeks‘ 2周后的日期
76.cal [parameter] month] [year] | View Calendar
-1 显示当月的月历-3 显示前、当、后一个月的日历-m 显示星期一为一个星期的第一天-s (默认)星期天为第一天-j 显示当月是一年中的第几天的日历-y 显示当前年份的日历
77.ps | List snapshots of the current process
a 显示所有的进程-a 显示同一终端下的所有程序e 显示环境变量f 显示进程间的关系-H 显示树状结构r 显示当前终端的程序T 显示当前终端的所有程序-au 显示更详细的信息-aux 显示所有包含其他使用者的行程 -u 指定用户的所有进程
78.top [parametric] | Displays information about the processes currently being executed by the system, including process IDs, memory usage, CPU utilization, etc.
79.kill [parameter] [process number] | Kill process
80.free [parametric] | Displays the free, used physical memory and swap memory in the Linux system, and the buffer used by the kernel
81.vmstat | Monitor virtual memory, process, and CPU activity of the operating system
82.iostat [parameter] [time t] [number of times N] (refresh once every t time, up to n times) | Monitor the disk operation activity of the system, report disk activity statistics, and report CPU usage
-p[磁盘] 显示磁盘和分区的情况
83.watch [parameters] [command] | Repeat a command to see the change
-n 时隔多少秒刷新-d 高亮显示动态变化
84.at [parameter] [TIME] | Executes a specified task at a specified time, only once
HH:MM[am|pm] + number [minutes|hours|days|weeks] 强制在某年某月某日的某时刻进行该项任务atq 查看系统未执行的任务atrm n 删除编号为n的任务at -c n 显示编号为n的任务的内容
85.crontab | Timed Task Scheduling
file 载入crontab-e 编辑某个用户的crontab文件内容-l 显示某个用户的crontab文件内容-r 删除某个用户的crontab文件
86.ifconfig [network device] [parameter] | View and configure network devices
87.route | Displaying and manipulating IP routing tables
88.ping [parameters] [host name or IP address] | Testing connectivity to the target host
-q 只显示最后的结果
89.netstat | Displays statistics related to IP, TCP, UDP, and ICMP protocols
90.telnet [parameters] [host] | For remote login, using plaintext to transmit messages, security is not good
91.RCP [parameters] [source file] [target file] | Remote file copy
-r 递归复制-p 保留源文件的属性usage: rcp –r remote_hostname:remote_dir local_dir
92.wget [parameters] [url address] | Download files directly from the network
-o FILE 把记录写到FILE文件中 eg : wget -O a.txt URLwget --limit-rate=300k URL 限速下载
93.awk
-F 分隔符 以分隔符分隔内容{} 要执行的脚本内容 eg:cat /etc/passwd |awk -F ‘:‘ ‘{print $1"\t"$7}‘
94.sed Replace, delete, add, select, and so on data rows
a 新增,在新的下一行出现c 取代,取代 n1,n2 之间的行 eg: sed ‘1,2c Hi‘ abd 删除i 插入,在新的上一行出现
95.paste merging files to ensure the same number of rows in the merged two file
-d 指定不同于空格或tab键的域分隔符-s 按行合并,单独一个文件为一行
96.su [parameter] user | Switch Login
-l 切换时连同环境变量、工作目录一起改变-c command 执行command变回原来的使用者
97.sudo | To execute a specific command with the privileges of a specific user
-l 列出当前用户可执行的命令-u username#uid 以指定用户执行命令
Linux Command Summary (RPM)