shell命令总结(主要用于自己练习和复习)

shell命令总结

一、文件、目录操作命令

  • ls命令
//功能:显示文件和目录的信息
ls		//以默认方式显示当前文件列表
ls -a	//显示文件包括隐藏文件
ls -ls	//显示文件属性,包括大小、日期、连接符,是否可读、是否可以执行
ls -lh	//显示文件大小
ls -lt	//按照修改时间显示文件
  • cd命令
//功能:切换当前工作目录
cd dir		//切换到当前工作目录下的dir目录
cd /		//切换到根目录
cd ..		//切换到上一级目录
cd ../.. 	//切换到上两级目录
cd ~			//切换到用户目录

关于目录结构的介绍,可以看我的另外一篇文章,在这里就不赘述了。

  • cp命令
//功能:复制文件——Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

用法:
	 cp [选项]... [-T] 源文件 目标文件
 或:cp [选项]... 源文件... 目录
 或:cp [选项]... -t 目录 源文件...
 源文件:被复制的文件 
 目标文件:被复制的文件最后存放的文件

必选参数对长短选项同时适用。
  -a, --archive			等于-dR --preserve=all
      --attributes-only	仅复制属性而不复制数据      --backup[=CONTROL		为每个已存在的目标文件创建备份
  -b				类似--backup 但不接受参数
      --copy-contents		在递归处理是复制特殊文件内容
  -d				等于--no-dereference --preserve=links
  -f, --force                  if an existing destination file cannot be
                                 opened, remove it and try again (this option
                                 is ignored when the -n option is also used)
  -i, --interactive            prompt before overwrite (overrides a previous -n
                                  option)
  -H                           follow command-line symbolic links in SOURCE
  -l, --link                   hard link files instead of copying
  -L, --dereference            always follow symbolic links in SOURCE
  -n, --no-clobber		不要覆盖已存在的文件(使前面的 -i 选项失效)
  -P, --no-dereference		不跟随源文件中的符号链接
  -p				等于--preserve=模式,所有权,时间戳
      --preserve[=属性列表	保持指定的属性(默认:模式,所有权,时间戳),如果
					可能保持附加属性:环境、链接、xattr 等
  -c                           deprecated, same as --preserve=context
      --sno-preserve=属性列表	不保留指定的文件属性
      --parents			复制前在目标目录创建来源文件路径中的所有目录
  -R, -r, --recursive		递归复制目录及其子目录内的所有内容
      --reflink[=WHEN]		控制克隆/CoW 副本。请查看下面的内如。
      --remove-destination	尝试打开目标文件前先删除已存在的目的地
					文件 (相对于 --force 选项)
      --sparse=WHEN		控制创建稀疏文件的方式
      --strip-trailing-slashes	删除参数中所有源文件/目录末端的斜杠
  -s, --symbolic-link		只创建符号链接而不复制文件
  -S, --suffix=后缀		自行指定备份文件的后缀
  -t,  --target-directory=目录	将所有参数指定的源文件/目录
                                           复制至目标目录
  -T, --no-target-directory	将目标目录视作普通文件
  -u, --update			只在源文件比目标文件新,或目标文件
					不存在时才进行复制
  -v, --verbose		显示详细的进行步骤
  -x, --one-file-system	不跨越文件系统进行操作
  -Z                           set SELinux security context of destination
                                 file to default type
      --context[=CTX]          like -Z, or if CTX is specified then set the
                                 SELinux or SMACK security context to CTX
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出




 假设当前目录下结构为 
 				a
 					-a1.txt
 					-a2.txt
 				b
 					-b1.txt
 					-b2.txt
 					
 则在当前目录下执行下列语句的含义即结果如下:
 
 cp b a    //把b文件夹 复制到 a文件夹下面
		
		查看a文件夹下的目录为
		a
			-a1.txt
			-a2.txt
			-b
				-t1.txt
				-t2.txt
		
		
		
  • rm命令

文档:

用法:rm [选项]... [文件]...
Remove (unlink) the FILE(s).

  -f, --force           ignore nonexistent files and arguments, never prompt
  -i                    prompt before every removal
  -I                    prompt once before removing more than three files, or
                          when removing recursively; less intrusive than -i,
                          while still giving protection against most mistakes
      --interactive[=WHEN]  prompt according to WHEN: never, once (-I), or
                          always (-i); without WHEN, prompt always
      --one-file-system		递归删除一个层级时,跳过所有不符合命令行参
				数的文件系统上的文件
      --no-preserve-root  do not treat '/' specially
      --preserve-root[=all]  do not remove '/' (default);
                              with 'all', reject any command line argument
                              on a separate device from its parent
  -r, -R, --recursive   remove directories and their contents recursively
  -d, --dir             remove empty directories
  -v, --verbose         explain what is being done
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

默认时,rm 不会删除目录。使用--recursive(-r 或-R)选项可删除每个给定
的目录,以及其下所有的内容。

To remove a file whose name starts with a '-', for example '-foo',
use one of these commands:
  rm -- -foo

  rm ./-foo

请注意,如果使用rm 来删除文件,通常仍可以将该文件恢复原状。如果想保证
该文件的内容无法还原,请考虑使用shred。

 语句举例:
	rm file			//删除名为file的文件(执行后会进行询问),只可以删除文件,不能删除文件夹。
	rm -f file		//删除名为file的文件(直接删除,不询问)
	rm -rf file		//删除名为file的整个目录(直接删除,不询问)
					//
					//
  • mv命令

用法:mv [选项]... [-T] 源文件 目标文件
 或:mv [选项]... 源文件... 目录
 或:mv [选项]... -t 目录 源文件...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

必选参数对长短选项同时适用。
      --backup[=CONTROL]       为每个已存在的目标文件创建备份
  -b                           类似--backup 但不接受参数
  -f, --force                  覆盖前不询问
  -i, --interactive            覆盖前询问
  -n, --no-clobber             不覆盖已存在文件
如果您指定了-i、-f、-n 中的多个,仅最后一个生效。
      --strip-trailing-slashes	去掉每个源文件参数尾部的斜线
  -S, --suffix=SUFFIX		替换常用的备份文件后缀
  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY
  -T, --no-target-directory    treat DEST as a normal file
  -u, --update                 move only when the SOURCE file is newer
                                 than the destination file or when the
                                 destination file is missing
  -v, --verbose                explain what is being done
  -Z, --context                set SELinux security context of destination
                                 file to default type
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:

  none, off       不进行备份(即使使用了--backup 选项)
  numbered, t     备份文件加上数字进行排序
  existing, nil   若有数字的备份文件已经存在则使用数字,否则使用普通方式备份
  simple, never   永远使用普通方式备份


 举例:
	mv a2.txt a3.txt 	 		//将a2.txt 文件的名字改为 a3.txt
								//
								//
								//
								//
  • diff命令

用法:diff [选项]... 文件们
逐行比较<文件们>。

长选项的必需参数也是相应短选项的必需参数。
      --normal                  以正常的 diff 方式输出 (默认)
  -q, --brief                   只有在文件不同时报告
  -s, --report-identical-files  当两个一样时仍然显示结果
  -c, -C NUM, --context[=NUM]   output NUM (default 3) lines of copied context
  -u, -U 数量, --unified[=数量] 输出 <数量>(默认为 3)行一致化上下文
  -e, --ed                      以 ed script 方式输出
  -n, --rcs                     以 RCS diff 格式输出
  -y, --side-by-side            output in two columns
  -W, --width=数量              每行显示最多 <数量>(默认 130)个字符
      --left-column             当有两行相同时只显示左边栏的一行
      --suppress-common-lines   当有两行相同时不显示

  -p, --show-c-function         show which C function each change is in
  -F, --show-function-line=RE   show the most recent line matching RE
      --label LABEL             use LABEL instead of file name and timestamp
                                  (can be repeated)

  -t, --expand-tabs             将输出中的 tab 转换成空格
  -T, --initial-tab             每行先加上 tab 字符,使 tab 字符可以对齐
      --tabsize=数字           TAB 格的宽度,默认为 8 个打印列宽
      --suppress-blank-empty    suppress space or tab before empty output lines
  -l, --paginate                将输出送至 “pr” 指令来分页

  -r, --recursive                 连同所有子目录一起比较
      --no-dereference            don't follow symbolic links
  -N, --new-file                  不存在的文件以空文件方式处理
      --unidirectional-new-file   若第一文件不存在,以空文件处理
      --ignore-file-name-case     忽略文件名大小写的区别
      --no-ignore-file-name-case  不忽略文件名大小写的区别
  -x, --exclude=模式              排除匹配 <模式> 的文件
  -X, --exclude-from=文件         排除所有匹配在<文件>中列出的模式的文件
  -S, --starting-file=文件        当比较目录時,由<文件>开始比较
      --from-file=文件1<文件1>和操作数中的所有文件/目录作比较;
                                    <文件1>可以是目录
      --to-file=文件2             将操作数中的所有文件/目录和<文件2>作比较;
                                    <文件2>可以是目录

  -i, --ignore-case               忽略文件内容大小写的区别
  -E, --ignore-tab-expansion      忽略由制表符宽度造成的差异
  -Z, --ignore-trailing-space     忽略每行末端的空格
  -b, --ignore-space-change       忽略由空格数不同造成的差异
  -w, --ignore-all-space          忽略所有空格
  -B, --ignore-blank-lines        忽略任何因空行而造成的差异
  -I, --ignore-matching-lines=正则 若某行完全匹配 <正则>,则忽略由该行造成的差异

  -a, --text                      所有文件都以文本方式处理
      --strip-trailing-cr         去除输入内容每行末端的回车(CR)字符

  -D, --ifdef=名称                输出的内容以 ‘#ifdef <名称>’ 方式标明差异
      --GTYPE-group-format=GFMT   以 GFMT 格式处理 GTYPE 输入行组
      --line-format=LFMT          以 LFMT 格式处理每一行资料
      --LTYPE-line-format=LFMT    以 LFMT 格式处理 LTYPE 输入的行
    These format options provide fine-grained control over the output
      of diff, generalizing -D/--ifdef.
    LTYPE 可以是 “old”、“new” 或 “unchanged”。GTYPE 可以是 LTYPE 的选择
    或是 “changed”。
  (仅)GFMT 可包括:
      %<  该组中每行属于<文件1>的差异
      %>  该组中每行属于<文件2>的差异
      %=  该组中同时在<文件1><文件2>出现的每一行
      %[-][宽度][.[精确度]]{doxX}字符  以 printf 格式表示该<字符>代表的内容
        大写<字符>表示属于新的文件,小写表示属于旧的文件。<字符>的意义如下:
          F  行组中第一行的行号
          L  行组中最后一行的行号
          N  行数 ( =L-F+1 )
          E  F-1
          M  L+1
      %(A=B?T:E)  如果 A 等于 B 那么 T 否则 E
  (仅)LFMT 可包括:
      %L  该行的内容
      %l  该行的内容,但不包括结束的换行符
      %[-][宽度][.[精确度]]{doxX}n  以 printf 格式表示的输入行号
    GFMT 或 LFMT 都可包括:
      %%        %
      %c'C'     单个字符 C
      %c'\OOO'  八进制码 OOO 所代表的字符
      C         字符 C(处上述转义外的其他字符代表它们自身)

  -d, --minimal            尽可能找出最小的差异。
      --horizon-lines=数量 保持<数量>行的一致前后缀
      --speed-large-files  假设文件十分大而且文件中含有许多微小的差异
      --color[=WHEN]       colorize the output; WHEN can be 'never', 'always',
                             or 'auto' (the default)
      --palette=PALETTE    the colors to use when --color is active; PALETTE is
                             a colon-separated list of terminfo capabilities

      --help               显示此帮助信息并退出
  -v, --version            输出版本信息并退出

FILES are 'FILE1 FILE2' or 'DIR1 DIR2' or 'DIR FILE' or 'FILE DIR'.
如果使用 --from-file 或 --to-file 选项,<文件名> 的格式则不受限制。
如果 FILE 是 “-”,则由标准输入读取内容。
如果输入相同,则退出状态为 01 表示输入不同;2 表示有错误产生。

//举例:
	diff file1 file2	//比较文件file1 & file2 的文件内容是否相同
	diff dir1 dir2		//比较文件dir1 & dir2 的文件是否相同
						//
						//
						//
  • ln命令

功能:为某一个文件在另外一个位置建立一个同不的链接

Usage: ln [OPTION]... [-T] TARGET LINK_NAME
  or:  ln [OPTION]... TARGET
  or:  ln [OPTION]... TARGET... DIRECTORY
  or:  ln [OPTION]... -t DIRECTORY TARGET...
In the 1st form, create a link to TARGET with the name LINK_NAME.
In the 2nd form, create a link to TARGET in the current directory.
In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.
Create hard links by default, symbolic links with --symbolic.
By default, each destination (name of new link) should not already exist.
When creating hard links, each TARGET must exist.  Symbolic links
can hold arbitrary text; if later resolved, a relative link is
interpreted in relation to its parent directory.

必选参数对长短选项同时适用。
      --backup[=CONTROL]	为每个已存在的目标文件创建备份文件
  -b				类似--backup,但不接受任何参数
  -d, -F, --directory		创建指向目录的硬链接(只适用于超级用户)
  -f, --force			强行删除任何已存在的目标文件
  -i, --interactive           prompt whether to remove destinations
  -L, --logical               dereference TARGETs that are symbolic links
  -n, --no-dereference        treat LINK_NAME as a normal file if
                                it is a symbolic link to a directory
  -P, --physical              make hard links directly to symbolic links
  -r, --relative              create symbolic links relative to link location
  -s, --symbolic              make symbolic links instead of hard links
  -S, --suffix=SUFFIX         override the usual backup suffix
  -t, --target-directory=DIRECTORY  specify the DIRECTORY in which to create
                                the links
  -T, --no-target-directory   treat LINK_NAME as a normal file always
  -v, --verbose               print name of each linked file
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:

  none, off       不进行备份(即使使用了--backup 选项)
  numbered, t     备份文件加上数字进行排序
  existing, nil   若有数字的备份文件已经存在则使用数字,否则使用普通方式备份
  simple, never   永远使用普通方式备份

Using -s ignores -L and -P.  Otherwise, the last option specified controls
behavior when a TARGET is a symbolic link, defaulting to -P.


//举例:
	ln source_path target_path			//建立硬链接
	ln source_path target_path			//建立软连接
							//
							//
							//

二、查看文件内容命令

  • cat命令

用法:cat [选项]... [文件]...
连接所有指定文件并将结果写到标准输出。

如果没有指定文件,或者文件为"-",则从标准输入读取。

  -A, --show-all           equivalent to -vET
  -b, --number-nonblank    number nonempty output lines, overrides -n
  -e                       equivalent to -vE
  -E, --show-ends          display $ at end of each line
  -n, --number             number all output lines
  -s, --squeeze-blank      suppress repeated empty output lines
  -t                       与-vT 等价
  -T, --show-tabs          将跳格字符显示为^I
  -u                       (被忽略)
  -v, --show-nonprinting   使用^ 和M- 引用,除了LFD和 TAB 之外
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

示例:
  cat f - g  先输出f 的内容,然后输出标准输入的内容,最后输出g 的内容。
  cat        将标准输入的内容复制到标准输出。



//举例:
				//
				//
				//
				//
				//
  • more命令

用法:
 more [选项] <文件>...

适合屏幕查看的文件阅读输出工具。

选项:
 -d          显示帮助而非响铃
 -f          计算逻辑行数,而非屏幕行数
 -l          屏蔽换页(form feed)后的暂停
 -c          不滚动,显示文本并清理行末
 -p          不滚动,清除屏幕并显示文本
 -s          将多行空行压缩为一行
 -u          屏蔽下划线
 -<数字>     每屏的行数
 +<数字>     从指定行开始显示文件
 +/<字符串>  从匹配搜索字符串的位置开始显示文件

     --help     display this help
 -V, --version  display version


//举例:
		//
		//
		//
		//
		//
  • tail命令

用法:tail [选项]... [文件]...
Print the last 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.

如果没有指定文件,或者文件为"-",则从标准输入读取。

必选参数对长短选项同时适用。
  -c, --bytes=[+]NUM       output the last NUM bytes; or use -c +NUM to
                             output starting with byte NUM of each file
  -f, --follow[={name|descriptor}]
                           output appended data as the file grows;
                             an absent option argument means 'descriptor'
  -F                       same as --follow=name --retry
  -n, --lines=[+]NUM       output the last NUM lines, instead of the last 10;
                             or use -n +NUM to output starting with line NUM
      --max-unchanged-stats=N
                           with --follow=name, reopen a FILE which has not
                             changed size after N (default 5) iterations
                             to see if it has been unlinked or renamed
                             (this is the usual case of rotated log files);
                             with inotify, this option is rarely useful
      --pid=PID            with -f, terminate after process ID, PID dies
  -q, --quiet, --silent    never output headers giving file names
      --retry              keep trying to open a file if it is inaccessible
  -s, --sleep-interval=N   with -f, sleep for approximately N seconds
                             (default 1.0) between iterations;
                             with inotify and --pid=P, check process P at
                             least once every N seconds
  -v, --verbose            always output headers giving file names
  -z, --zero-terminated    以 NUL 字符而非换行符作为行尾分隔符
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

NUM may have a multiplier suffix:
b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.

如果您希望即时追查一个文件的有效名称而非描述内容(例如循环日志),默认
的程序动作并不如您所愿。在这种场合可以使用--follow=name 选项,它会使
tail 定期追踪打开给定名称的文件,以确认它是否被删除或被其它某些程序重新创建过。



//举例:
	tail -n 100 a1.txt		//显示文件a1.txt的最后100行
		//
		//
		//
		//
  • vi命令

用法: vim [参数] [文件 ..]       编辑指定的文件
  或: vim [参数] -               从标准输入(stdin)读取文本
  或: vim [参数] -t tag          编辑 tag 定义处的文件
  或: vim [参数] -q [errorfile]  编辑第一个出错处的文件

参数:
   --			在这以后只有文件名
   -v			Vi 模式 ("vi")
   -e			Ex 模式 ("ex")
   -E			Improved Ex mode
   -s			安静(批处理)模式 (只能与 "ex" 一起使用)
   -d			Diff 模式 ("vimdiff")
   -y			容易模式 ("evim",无模式)
   -R			只读模式 ("view")
   -Z			限制模式 ("rvim")
   -m			不可修改(写入文件)
   -M			文本不可修改
   -b			二进制模式
   -l			Lisp 模式
   -C			兼容传统的 Vi: 'compatible'
   -N			不完全兼容传统的 Vi: 'nocompatible'
   -V[N][fname]		Be verbose [level N] [log messages to fname]
   -D			调试模式
   -n			不使用交换文件,只使用内存
   -r			列出交换文件并退出
   -r (跟文件名)		恢复崩溃的会话
   -L			同 -r
   -A			以 Arabic 模式启动
   -H			以 Hebrew 模式启动
   -F			以 Farsi 模式启动
   -T <terminal>	设定终端类型为 <terminal>
   --not-a-term		Skip warning for input/output not being a terminal
   --ttyfail		Exit if input or output is not a terminal
   -u <vimrc>		使用 <vimrc> 替代任何 .vimrc
   --noplugin		不加载 plugin 脚本
   -P[N]		打开 N 个标签页 (默认值: 每个文件一个)
   -o[N]		打开 N 个窗口 (默认值: 每个文件一个)
   -O[N]-o 但垂直分割
   +			启动后跳到文件末尾
   +<lnum>		启动后跳到第 <lnum>--cmd <command>	加载任何 vimrc 文件前执行 <command>
   -c <command>		加载第一个文件后执行 <command>
   -S <session>		加载第一个文件后执行文件 <session>
   -s <scriptin>	从文件 <scriptin> 读入正常模式的命令
   -w <scriptout>	将所有输入的命令追加到文件 <scriptout>
   -W <scriptout>	将所有输入的命令写入到文件 <scriptout>
   -x			编辑加密的文件
   --startuptime <file>	Write startup timing messages to <file>
   -i <viminfo>		使用 <viminfo> 取代 .viminfo
   --clean		'nocompatible', Vim defaults, no plugins, no viminfo
   -h  或  --help	打印帮助(本信息)并退出
   --version		打印版本信息并退出


//功能
		//
		//
		//
		//
		//
  • touch命令

用法:touch [选项]... 文件...
Update the access and modification times of each FILE to the current time.

A FILE argument that does not exist is created empty, unless -c or -h
is supplied.

A FILE argument string of - is handled specially and causes touch to
change the times of the file associated with standard output.

必选参数对长短选项同时适用。
  -a			只更改访问时间
  -c, --no-create	不创建任何文件
  -d, --date=字符串	使用指定字符串表示时间而非当前时间
  -f			(忽略)
  -h, --no-dereference		会影响符号链接本身,而非符号链接所指示的目的地
				(当系统支持更改符号链接的所有者时,此选项才有用)
  -m			只更改修改时间
  -r, --reference=FILE   use this file's times instead of current time
  -t STAMP               use [[CC]YY]MMDDhhmm[.ss] instead of current time
      --time=WORD        change the specified time:
                           WORD is access, atime, or use: equivalent to -a
                           WORD is modify or mtime: equivalent to -m
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

请注意,-d 和-t 选项可接受不同的时间/日期格式。


//举例:
	touch a4.txt		//创建a4文本文件
		//
		//
		//
		//

三、基本系统命令

  • man命令

用法: man[选项...] [章节] 手册页...

  -C, --config-file=文件   使用该用户设置文件
  -d, --debug                输出调试信息
  -D, --default              将所有选项都重置为默认值
      --warnings[=警告]    开启 groff 的警告

 主要运行模式:
  -f, --whatis               等同于 whatis
  -k, --apropos              等同于 apropos
  -K, --global-apropos       search for text in all pages
  -l, --local-file
                             把“手册页”参数当成本地文件名来解读
  -w, --where, --path, --location
                             输出手册页的物理位置
  -W, --where-cat, --location-cat
                             输出 cat 文件的物理位置

  -c, --catman               由 catman 使用,用来对过时的 cat
                             页重新排版
  -R, --recode=编码        output source page encoded in ENCODING

 寻找手册页:
  -L, --locale=区域
                             定义本次手册页搜索所采用的区域设置
  -m, --systems=系统       use manual pages from other systems
  -M, --manpath=路径       设置搜索手册页的路径为“路径”

  -S, -s, --sections=列表  使用以半角冒号分隔的章节列表

  -e, --extension=扩展
                             将搜索限制在扩展类型为“扩展”的手册页之内

  -i, --ignore-case          查找手册页时不区分大小写字母
                             (默认)
  -I, --match-case           查找手册页时区分大小写字母。

      --regex                show all pages matching regex
      --wildcard             show all pages matching wildcard

      --names-only           make --regex and --wildcard match page names only,
                             not descriptions

  -a, --all                  寻找所有匹配的手册页
  -u, --update               强制进行缓存一致性的检查

      --no-subpages          don't try subpages, e.g. 'man foo bar' => 'man
                             foo-bar'

 控制格式化的输出:
  -P, --pager=PAGER          使用 PAGER 程序显示输出文本
  -r, --prompt=字符串     给 less pager 提供一个提示行

  -7, --ascii                显示某些 latin1 字符的 ASCII 翻译形式
  -E, --encoding=编码      use selected output encoding
      --no-hyphenation, --nh turn off hyphenation
      --no-justification,                              --nj   turn off justification
  -p, --preprocessor=字符串   字符串表示要运行哪些预处理器:
                             e - [n]eqn, p - pic, t - tbl,
g - grap, r - refer, v - vgrind

  -t, --troff                使用 groff 对手册页排版
  -T, --troff-device[=设备]   使用 groff 的指定设备

  -H, --html[=浏览器]     使用 elinks 或指定浏览器显示 HTML
                             输出
  -X, --gxditview[=分辨率]   使用 groff 并通过 gxditview (X11)
                             来显示:
                             -X = -TX75, -X100 = -TX100, -X100-12 = -TX100-12
  -Z, --ditroff              使用 groff 并强制它生成 ditroff

  -?, --help                 显示此帮助列表
      --usage                显示一份简洁的用法信息
  -V, --version              打印程序版本

选项完整形式所必须用的或是可选的参数,在使用选项缩写形式时也是必须的或是可选的。


//举例:
	man su				//查看su命令的含义与使用
		//
		//
		//
		//
  • w命令

Usage:
 w [options]

Options:
 -h, --no-header     do not print header
 -u, --no-current    ignore current process username
 -s, --short         short format
 -f, --from          show remote hostname field
 -o, --old-style     old style output
 -i, --ip-addr       display IP address instead of hostname (if possible)

     --help     display this help and exit
 -V, --version  output version information and exit


//举例:
	w				//显示用户的登录信息
		//
		//
		//
		//
  • who命令

用法:who [选项]... [ 文件 | 参数1 参数2 ]
显示当前已登录的用户信息。

  -a, --all		等于-b -d --login -p -r -t -T -u 选项的组合
  -b, --boot		上次系统启动时间
  -d, --dead		显示已死的进程
  -H, --heading	输出头部的标题列
  -l,--login		显示系统登录进程
      --lookup		尝试通过 DNS 查验主机名
  -m			只面对和标准输入有直接交互的主机和用户
  -p, --process	显示由 init 进程衍生的活动进程
  -q, --count		列出所有已登录用户的登录名与用户数量
  -r, --runlevel	显示当前的运行级别
  -s, --short		只显示名称、线路和时间(默认)
  -T, -w, --mesg	用+-? 标注用户消息状态
  -u, --users		列出已登录的用户
      --message	等于-T
      --writable	等于-T
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

If FILE is not specified, use /var/run/utmp.  /var/log/wtmp as FILE is common.
If ARG1 ARG2 given, -m presumed: 'am i' or 'mom likes' are usual.


//举例:
	who				//显示用户的登录信息
		//
		//
		//
		//
  • last命令

用法:
 last [选项] [<用户名>...] [<tty>...]

显示上次登录用户的列表。

选项:
 -<数字>              显示行数
 -a, --hostlast       最后一列显示主机名
 -d, --dns            将 IP 号转换回主机名
 -F, --file <文件>    用指定文件代替 /var/log/wtmp
 -F, --fulltimes      打印完整的登录和注销时间和日期
 -i, --ip             以数字和点的形式显示 IP 号
 -n, --limit <数字>   要显示的行数
 -R, --nohostname     不显示主机名字段
 -s, --since <时间>   显示从指定时间起的行
 -t, --until <时间>   显示到指定时间为止的行
 -p, --present <时间> 显示在指定时间谁在场(present)
 -w, --fullnames      显示完整的用户名和域名
 -x, --system         显示系统关机项和运行级别更改
     --time-format <格式>    以指定<格式>显示时间戳:
                               notime|short|full|iso

 -h, --help           display this help
 -V, --version        display version


//举例:
		//
		//
		//
		//
		//
  • date命令
用法:date [选项]... [+格式]
 或:date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.

必选参数对长短选项同时适用。
  -d, --date=STRING          display time described by STRING, not 'now'
      --debug                annotate the parsed date,
                              and warn about questionable usage to stderr
  -f, --file=DATEFILE        like --date; once for each line of DATEFILE
  -I[FMT], --iso-8601[=FMT]  output date/time in ISO 8601 format.
                               FMT='date' for date only (the default),
                               'hours', 'minutes', 'seconds', or 'ns'
                               for date and time to the indicated precision.
                               Example: 2006-08-14T02:34:56-06:00
  -R, --rfc-email            output date and time in RFC 5322 format.
                               Example: Mon, 14 Aug 2006 02:34:56 -0600
      --rfc-3339=FMT         output date/time in RFC 3339 format.
                               FMT='date', 'seconds', or 'ns'
                               for date and time to the indicated precision.
                               Example: 2006-08-14 02:34:56-06:00
  -r, --reference=FILE       display the last modification time of FILE
  -s, --set=STRING           set time described by STRING
  -u, --utc, --universal     print or set Coordinated Universal Time (UTC)
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

给定的格式FORMAT 控制着输出,解释序列如下:

  %%	一个文字的 %
  %a	当前locale 的星期名缩写(例如: 日,代表星期日)
  %A	当前locale 的星期名全称 (如:星期日)
  %b	当前locale 的月名缩写 (如:一,代表一月)
  %B	当前locale 的月名全称 (如:一月)
  %c	当前locale 的日期和时间 (如:200533日 星期四 23:05:25)
  %C	世纪;比如 %Y,通常为省略当前年份的后两位数字(例如:20)
  %d	按月计的日期(例如:01)
  %D	按月计的日期;等于%m/%d/%y
  %e	按月计的日期,添加空格,等于%_d
  %F	完整日期格式,等价于 %Y-%m-%d
  %g	ISO-8601 格式年份的最后两位 (参见%G)
  %G	ISO-8601 格式年份 (参见%V),一般只和 %V 结合使用
  %h	等于%b
  %H	小时(00-23)
  %I	小时(00-12)
  %j	按年计的日期(001-366)
  %k   hour, space padded ( 0..23); same as %_H
  %l   hour, space padded ( 1..12); same as %_I
  %m   month (01..12)
  %M   minute (00..59)
  %n   a newline
  %N   nanoseconds (000000000..999999999)
  %p   locale's equivalent of either AM or PM; blank if not known
  %P   like %p, but lower case
  %q   quarter of year (1..4)
  %r   locale's 12-hour clock time (e.g., 11:11:04 PM)
  %R   24-hour hour and minute; same as %H:%M
  %s   seconds since 1970-01-01 00:00:00 UTC
  %S	秒(00-60)
  %t	输出制表符 Tab
  %T	时间,等于%H:%M:%S
  %u	星期,1 代表星期一
  %U	一年中的第几周,以周日为每星期第一天(00-53)
  %V	ISO-8601 格式规范下的一年中第几周,以周一为每星期第一天(01-53)
  %w	一星期中的第几日(0-6)0 代表周一
  %W	一年中的第几周,以周一为每星期第一天(00-53)
  %x	当前locale 下的日期描述 (如:12/31/99)
  %X	当前locale 下的时间描述 (如:23:13:48)
  %y	年份最后两位数位 (00-99)
  %Y	年份
  %z +hhmm		数字时区(例如,-0400)
  %:z +hh:mm		数字时区(例如,-04:00)
  %::z +hh:mm:ss	数字时区(例如,-04:00:00)
  %:::z			数字时区带有必要的精度 (例如,-04+05:30)
  %Z			按字母表排序的时区缩写 (例如,EDT)

默认情况下,日期的数字区域以0 填充。
The following optional flags may follow '%':

  -  (hyphen) do not pad the field
  _  (underscore) pad with spaces
  0  (zero) pad with zeros
  ^  use upper case if possible
  #  use opposite case if possible

在任何标记之后还允许一个可选的域宽度指定,它是一个十进制数字。
作为一个可选的修饰声明,它可以是E,在可能的情况下使用本地环境关联的
表示方式;或者是O,在可能的情况下使用本地环境关联的数字符号。

Examples:
Convert seconds since the epoch (1970-01-01 UTC) to a date
  $ date --date='@2147483647'

Show the time on the west coast of the US (use tzselect(1) to find TZ)
  $ TZ='America/Los_Angeles' date

Show the local time for 9AM next Friday on the west coast of the US
  $ date --date='TZ="America/Los_Angeles" 09:00 next Fri'


//举例:
		//
		//
		//
		//
		//
  • clock命令

用法:
 clock [function] [option...]

Time clocks utility.

功能:
 -r, --show           display the RTC time
     --get            display drift corrected RTC time
     --set            set the RTC according to --date
 -s, --hctosys        set the system time from the RTC
 -w, --systohc        set the RTC from the system time
     --systz          send timescale configurations to the kernel
 -a, --adjust         adjust the RTC to account for systematic drift
     --predict        predict the drifted RTC time according to --date

选项:
 -u, --utc            the RTC timescale is UTC
 -l, --localtime      the RTC timescale is Local
 -f, --rtc <file>     use an alternate file to /dev/rtc0
     --directisa      use the ISA bus instead of /dev/rtc0 access
     --date <time>    date/time input for --set and --predict
     --update-drift   update the RTC drift factor
     --noadjfile      do not use /etc/adjtime
     --adjfile <file> use an alternate file to /etc/adjtime
     --test           dry run; implies --verbose
 -v, --verbose        display more details

 -h, --help           display this help
 -V, --version        display version


//举例:
		//
		//
		//
		//
		//
  • uname命令

用法:uname [选项]...
输出一组系统信息。如果不跟随选项,则视为只附加 -s 选项。

  -a, --all                以如下次序输出所有信息。其中若 -p 和
                             -i 的探测结果不可知则被省略:
  -s, --kernel-name        输出内核名称
  -n, --nodename           输出网络节点上的主机名
  -r, --kernel-release     输出内核发行号
  -v, --kernel-version     输出内核版本
  -m, --machine            输出主机的硬件架构名称
  -p, --processor          输出处理器类型(不可移植)
  -i, --hardware-platform  输出硬件平台或(不可移植)
  -o, --operating-system   输出操作系统名称
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出


//举例:
	uanme -m				//输出主机的硬件架构名称
		//
		//
		//
		//
  • 关闭&重启命令
	reboot:
	
		用法:
			reboot [OPTIONS...] [ARG]
			
			Reboot the system.
			
			    --help      Show this help
			    --halt      Halt the machine
			 -p --poweroff  Switch off the machine
			    --reboot    Reboot the machine
			 -f --force     Force immediate halt/power-off/reboot
			 -w --wtmp-only Don't halt/power-off/reboot, just write wtmp record
			 -d --no-wtmp   Don't write wtmp record
			    --no-wall   Don't send wall message before halt/power-off/reboot

			//举例:
				//
				//
				//
				//

	shutdown:
		用法:
			shutdown [OPTIONS...] [TIME] [WALL...]

			Shut down the system.
		
			--help      Show this help
			-H --halt      Halt the machine
			-P --poweroff  Power-off the machine
			-r --reboot    Reboot the machine
			-h             Equivalent to --poweroff, overridden by --halt
			-k             Don't halt/power-off/reboot, just send warnings
			   --no-wall   Don't send wall message before halt/power-off/reboot
			-c             Cancel a pending shutdown

		

		//举例:
				shutdown -h 15 			//15分钟后关机
				//
				//
				//
				//
  • su命令

用法:
 su [选项] [-] [<用户> [<参数>...]]

Change the effective user ID and group ID to that of <user>.
A mere - implies -l.  If <user> is not given, root is assumed.

选项:
 -m, -p, --preserve-environment  不重置环境变量
 -g, --group <>                指定主组
 -G, --supp-group <group>        specify a supplemental group

 -, -l, --login                  使 shell 成为登录 shell
 -c, --command <命令>            使用 -c 向 shell 传递一条命令
 --session-command <命令>        使用 -c 向 shell 传递一条命令
                                   而不创建新会话
 -f, --fast                      向shell 传递 -f 选项(csh 或 tcsh)
 -s, --shell <shell>/etc/shells 允许,运行<shell>
 -P, --pty                       create a new pseudo-terminal

 -h, --help                      display this help
 -V, --version                   display version


//举例:
	su 					//从当前用户切换到root用户
		//
		//
		//
		//

四、监视系统状态命令

  • top命令
//功能 查看cpu的使用情况
	top			//
		//
		//
		//
		//
  • free命令

Usage:
 free [options]

Options:
 -b, --bytes         show output in bytes
     --kilo          show output in kilobytes
     --mega          show output in megabytes
     --giga          show output in gigabytes
     --tera          show output in terabytes
     --peta          show output in petabytes
 -k, --kibi          show output in kibibytes
 -m, --mebi          show output in mebibytes
 -g, --gibi          show output in gibibytes
     --tebi          show output in tebibytes
     --pebi          show output in pebibytes
 -h, --human         show human-readable output
     --si            use powers of 1000 not 1024
 -l, --lohi          show detailed low and high memory statistics
 -t, --total         show total for RAM + swap
 -s N, --seconds N   repeat printing every N seconds
 -c N, --count N     repeat printing N times, then exit
 -w, --wide          wide output

     --help     display this help and exit
 -V, --version  output version information and exit


//举例:
	free			//查看内存和swap分区使用情况
		//
		//
		//
		//
  • uptime命令
Usage:
 uptime [options]

Options:
 -p, --pretty   show uptime in pretty format
 -h, --help     display this help and exit
 -s, --since    system up since
 -V, --version  output version information and exit


//举例:
		//
		//
		//
		//
		//
  • vmstat命令
Usage:
 vmstat [options] [delay [count]]

Options:
 -a, --active           active/inactive memory
 -f, --forks            number of forks since boot
 -m, --slabs            slabinfo
 -n, --one-header       do not redisplay header
 -s, --stats            event counter statistics
 -d, --disk             disk statistics
 -D, --disk-sum         summarize disk statistics
 -p, --partition <dev>  partition specific statistics
 -S, --unit <char>      define display unit
 -w, --wide             wide output
 -t, --timestamp        show timestamp

 -h, --help     display this help and exit
 -V, --version  output version information and exit


//举例:
		//
		//
		//
		//
		//
  • ps命令
//功能
		//
		//
		//
		//
		//
  • kill命令

kill: kill [-s 信号声明 | -n 信号编号 | -信号声明] 进程号 | 任务声明 ... 或 kill -l [信号声明]
    Send a signal to a job.
    
    Send the processes identified by PID or JOBSPEC the signal named by
    SIGSPEC or SIGNUM.  If neither SIGSPEC nor SIGNUM is present, then
    SIGTERM is assumed.
    
    Options:
      -s sig	SIG is a signal name
      -n sig	SIG is a signal number
      -l	list the signal names; if arguments follow `-l' they are
    		assumed to be signal numbers for which names should be listed
      -L	synonym for -l
    
    Kill is a shell builtin for two reasons: it allows job IDs to be used
    instead of process IDs, and allows processes to be killed if the limit
    on processes that you can create is reached.
    
    Exit Status:
    Returns success unless an invalid option is given or an error occurs.

//举例:
		//
		//
		//
		//
		//

五、磁盘操作命令

  • df命令
用法:df [选项]... [文件]...
Show information about the file system on which each FILE resides,
or all file systems by default.

必选参数对长短选项同时适用。
  -a, --all             include pseudo, duplicate, inaccessible file systems
  -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes;
                           see SIZE format below
      --direct          show statistics for a file instead of mount point
  -h, --human-readable  print sizes in powers of 1024 (e.g., 1023M)
  -H, --si              print sizes in powers of 1000 (e.g., 1.1G)
  -i, --inodes		显示inode 信息而非块使用量
  -k			即--block-size=1K
  -l, --local		只显示本机的文件系统
      --no-sync		取得使用量数据前不进行同步动作(默认)
      --output[=FIELD_LIST]  use the output format defined by FIELD_LIST,
                               or print all fields if FIELD_LIST is omitted.
  -P, --portability     use the POSIX output format
      --sync            invoke sync before getting usage info
      --total           elide all entries insignificant to available space,
                          and produce a grand total
  -t, --type=TYPE       limit listing to file systems of type TYPE
  -T, --print-type      print file system type
  -x, --exclude-type=TYPE   limit listing to file systems not of type TYPE
  -v                    (ignored)
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

所显示的数值是来自 --block-size、DF_BLOCK_SIZE、BLOCK_SIZE 
及 BLOCKSIZE 环境变量中第一个可用的 SIZE 单位。
否则,默认单位是 1024 字节(或是 512,若设定 POSIXLY_CORRECT 的话)。

The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).

FIELD_LIST is a comma-separated list of columns to be included.  Valid
field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',
'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page).


//举例:
		//
		//
		//
		//
		//
  • du命令

用法:du [选项]... [文件]...
 或:du [选项]... --files0-from=F
Summarize disk usage of the set of FILEs, recursively for directories.

必选参数对长短选项同时适用。
  -0, --null            end each output line with NUL, not newline
  -a, --all             write counts for all files, not just directories
      --apparent-size   print apparent sizes, rather than disk usage; although
                          the apparent size is usually smaller, it may be
                          larger due to holes in ('sparse') files, internal
                          fragmentation, indirect blocks, and the like
  -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes;
                           see SIZE format below
  -b, --bytes           equivalent to '--apparent-size --block-size=1'
  -c, --total           produce a grand total
  -D, --dereference-args  dereference only symlinks that are listed on the
                          command line
  -d, --max-depth=N     print the total for a directory (or file, with --all)
                          only if it is N or fewer levels below the command
                          line argument;  --max-depth=0 is the same as
                          --summarize
      --files0-from=F   summarize disk usage of the
                          NUL-terminated file names specified in file F;
                          if F is -, then read names from standard input
  -H                    equivalent to --dereference-args (-D)
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
      --inodes          list inode usage information instead of block usage
  -k                    like --block-size=1K
  -L, --dereference     dereference all symbolic links
  -l, --count-links     count sizes many times if hard linked
  -m                    like --block-size=1M
  -P, --no-dereference  don't follow any symbolic links (this is the default)
  -S, --separate-dirs   for directories do not include size of subdirectories
      --si              like -h, but use powers of 1000 not 1024
  -s, --summarize       display only a total for each argument
  -t, --threshold=SIZE  exclude entries smaller than SIZE if positive,
                          or entries greater than SIZE if negative
      --time            show time of the last modification of any file in the
                          directory, or any of its subdirectories
      --time=WORD       show time as WORD instead of modification time:
                          atime, access, use, ctime or status
      --time-style=STYLE  show times using STYLE, which can be:
                            full-iso, long-iso, iso, or +FORMAT;
                            FORMAT is interpreted like in 'date'
  -X, --exclude-from=FILE  exclude files that match any pattern in FILE
      --exclude=PATTERN    exclude files that match PATTERN
  -x, --one-file-system    skip directories on different file systems
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

所显示的数值是来自 --block-size、DU_BLOCK_SIZE、BLOCK_SIZE 
及 BLOCKSIZE 环境变量中第一个可用的 SIZE 单位。
否则,默认单位是 1024 字节(或是 512,若设定 POSIXLY_CORRECT 的话)。

The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).


//举例:
	du -s			//显示当前目录占用空间
	du -sk			//显示当前目录占用空间,以k为单位
	du -sb			//显示当前目录占用空间,以b为单位
	du -sm			//显示当前目录占用空间,以m为单位
	du -sh			//只统计目录大小
	
  • mount命令

用法:
 mount [-lhV]
 mount -a [选项]
 mount [选项] [--source] <> | [--target] <目录>
 mount [选项] <> <目录>
 mount <操作> <挂载点> [<目标>]

挂载文件系统。

选项:
 -a, --all               挂载 fstab 中的所有文件系统
 -c, --no-canonicalize   不对路径规范化
 -f, --fake              空运行;跳过 mount(2) 系统调用
 -F, --fork              对每个设备禁用 fork(-a 选项一起使用)
 -T, --fstab <路径>      /etc/fstab 的替代文件
 -i, --internal-only     不调用 mount.<type> 辅助程序
 -l, --show-labels       也显示文件系统标签
 -n, --no-mtab           不写 /etc/mtab
 -o, --options <列表>    挂载选项列表,以英文逗号分隔
 -O, --test-opts <列表>  限制文件系统集合(-a 选项一起使用)
 -r, --read-only         以只读方式挂载文件系统(-o ro)
 -t, --types <列表>      限制文件系统类型集合
     --source <>       指明源(路径、标签、uuid)
     --target <目标>     指明挂载点
 -v, --verbose           打印当前进行的操作
 -w, --rw, --read-write  以读写方式挂载文件系统(默认)

 -h, --help              display this help
 -V, --version           display version

源:
 -L, --label <标签>      同 LABEL=<label>
 -U, --uuid <uuid>       同 UUID=<uuid>
 LABEL=<标签>            按文件系统标签指定设备
 UUID=<uuid>             按文件系统 UUID 指定设备
 PARTLABEL=<标签>        按分区标签指定设备
 PARTUUID=<uuid>         按分区 UUID 指定设备
 <设备>                  按路径指定设备
 <目录>                  绑定式挂载的挂载点(参阅 --bind/rbind)
 <文件>                  用于设置回环设备的常规文件

操作:
 -B, --bind              挂载其他位置的子树(-o bind)
 -M, --move              将子树移动到其他位置
 -R, --rbind             挂载其他位置的子树及其包含的所有子挂载(submount)
 --make-shared           将子树标记为 共享
 --make-slave            将子树标记为 从属
 --make-private          将子树标记为 私有
 --make-unbindable       将子树标记为 不可绑定
 --make-rshared          递归地将整个子树标记为 共享
 --make-rslave           递归地将整个子树标记为 从属
 --make-rprivate         递归地将整个子树标记为 私有
 --make-runbindable      递归地将整个子树标记为 不可绑定


//举例:
		//
		//
		//
		//
		//
  • mkswap命令
 创建交换空间

用法
 mkswap [选项] 设备 [大小]

设置 Linux 交换区。

Options:
 -c, --check               check bad blocks before creating the swap area
 -f, --force               allow swap size area be larger than device
 -p, --pagesize SIZE       specify page size in bytes
 -L, --label LABEL         specify label
 -v, --swapversion NUM     specify swap-space version number
 -U, --uuid UUID           specify the uuid to use
 -h, --help                display this help
 -V, --version             display version


//举例:
		//
		//
		//
		//
		//
  • fdisk命令
用法:
 fdisk [选项] <磁盘>         更改分区表
 fdisk [选项] -l [<磁盘>]     列出分区表

显示或操作磁盘分区表。

选项:
 -b, --sectors-size <大小>     显示扇区计数和大小
 -B, --protect-boot            创建新标签时不要擦除 bootbits 
 -c, --compatibility[=<模式>]  模式,为“dos”或“nondos”(默认)
 -L, --color[=<时机>]          彩色输出(auto, always 或 never)
                                 默认启用颜色
 -l, --list                    显示分区并退出
 -o, --output <列表>           输出列
 -t, --type <类型>             只识别指定的分区表类型
 -u, --units[=<单位>]          显示单位,“cylinders”柱面或“sectors”扇区(默认)
 -s, --getsz                   以 512-字节扇区显示设备大小[已废弃]
     -b, --bytes                   以字节为单位而非易读的格式来打印 SIZE
 -w, --wipe <模式>             擦除签名(auto, always 或 never)
 -W, --wipe-partitions <模式>  擦除新分区的签名(auto, always 或 never)

 -C, --cylinders <数字>        指定柱面数
 -H, --heads <数字>            指定磁头数
 -S, --sectors <数字>          指定每条磁道的扇区数

 -h, --help                    display this help
 -V, --version                 display version

Available output columns:
 gpt: Device Start End Sectors Size Type Type-UUID Attrs Name UUID
 dos: Device Start End Sectors Cylinders Size Type Id Attrs Boot End-C/H/S Start-C/H/S
 bsd: Slice Start End Sectors Cylinders Size Type Bsize Cpg Fsize
 sgi: Device Start End Sectors Cylinders Size Type Id Attrs
 sun: Device Start End Sectors Cylinders Size Type Id Flags


//举例:
		//
		//
		//
		//
		//
  • mkfs命令
用法:
 mkfs [选项] [-t <类型>] [文件系统选项] <设备> [<大小>]

创建一个Linux 文件系统。

选项:
 -t, --type=<类型>  文件系统类型;若不指定,将使用 ext2
     fs-options     实际文件系统构建程序的参数
     <设备>         要使用设备的路径
     <大小>         要使用设备上的块数
 -V, --verbose      解释正在进行的操作;
                      多次指定 -V 将导致空运行(dry-run)
 -h, --help         display this help
 -V, --version      display version


//举例:
		//
		//
		//
		//
		//
  • e2fsck命令

用法:e2fsck [-panyrcdfktvDFV] [-b 超级块] [-B 块大小]
		[-l|-L 坏块文件] [-C fd] [-j 外部日志]
		[-E 扩展选项]  [-z 撤销文件] 设备

重要提示:
 -p                   自动修复(不询问)
 -n                   不对文件系统做任何更改
 -y                   对所有询问都回答“是”
 -c                   检查可能的坏块,并将它们加入坏块列表
 -f                   强制进行检查,即使文件系统被标记为“没有问题”
 -v                   显示更多信息
 -b superblock        使用备选超级块
 -B blocksize         使用指定块大小来查找超级块
 -j external_journal  指定外部日志的位置
 -l bad_blocks_file   添加到指定的坏块列表(文件)
 -L bad_blocks_file   指定坏块列表(文件)
 -z undo_file         创建一个撤销文件


//功能
		//
		//
		//
		//
		//
  • tune2fs命令
//功能
		//
		//
		//
		//
		//

l

  • dd命令

用法:dd [操作数] ...
 或:dd 选项
Copy a file, converting and formatting according to the operands.

  bs=BYTES        read and write up to BYTES bytes at a time (default: 512);
                  overrides ibs and obs
  cbs=BYTES       convert BYTES bytes at a time
  conv=CONVS      convert the file as per the comma separated symbol list
  count=N         copy only N input blocks
  ibs=BYTES       read up to BYTES bytes at a time (default: 512)
  if=FILE         read from FILE instead of stdin
  iflag=FLAGS     read as per the comma separated symbol list
  obs=BYTES       write BYTES bytes at a time (default: 512)
  of=FILE         write to FILE instead of stdout
  oflag=FLAGS     write as per the comma separated symbol list
  seek=N          skip N obs-sized blocks at start of output
  skip=N          skip N ibs-sized blocks at start of input
  status=LEVEL    The LEVEL of information to print to stderr;
                  'none' suppresses everything but error messages,
                  'noxfer' suppresses the final transfer statistics,
                  'progress' shows periodic transfer statistics

N and BYTES may be followed by the following multiplicative suffixes:
c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M,
GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.

Each CONV symbol may be:

  ascii     from EBCDIC to ASCII
  ebcdic    from ASCII to EBCDIC
  ibm       from ASCII to alternate EBCDIC
  block     pad newline-terminated records with spaces to cbs-size
  unblock   replace trailing spaces in cbs-size records with newline
  lcase     change upper case to lower case
  ucase     change lower case to upper case
  sparse    try to seek rather than write the output for NUL input blocks
  swab      swap every pair of input bytes
  sync      pad every input block with NULs to ibs-size; when used
            with block or unblock, pad with spaces rather than NULs
  excl		fail if the output file already exists
  nocreat	do not create the output file
  notrunc	不截断输出文件
  noerror	读取数据发生错误后仍然继续
  fdatasync	结束前将输出文件数据写入磁盘
  fsync	类似上面,但是元数据也一同写入

FLAG 符号可以是:

  append	追加模式(仅对输出有意义;隐含了conv=notrunc)
  direct	使用直接I/O 存取模式
  directory	除非是目录,否则 directory 失败
  dsync		使用同步I/O 存取模式
  sync		与上者类似,但同时也对元数据生效
  fullblock	为输入积累完整块(仅iflag)
  nonblock	使用无阻塞I/O 存取模式
  noatime	不更新存取时间
  nocache   Request to drop cache.  See also oflag=sync
  noctty	不根据文件指派控制终端
  nofollow	不跟随链接文件
  count_bytes  treat 'count=N' as a byte count (iflag only)
  skip_bytes  treat 'skip=N' as a byte count (iflag only)
  seek_bytes  treat 'seek=N' as a byte count (oflag only)

Sending a USR1 signal to a running 'dd' process makes it
print I/O statistics to standard error and then resume copying.

Options are:

      --help		显示此帮助信息并退出
      --version		显示版本信息并退出


//举例:
		//
		//
		//
		//
		//

六、用户和组相关命令

  • groupadd命令

用法:groupadd [选项] 组

选项:
  -f, --force		如果组已经存在则成功退出
			并且如果 GID 已经存在则取消 -g
  -g, --gid GID                 为新组使用 GID
  -h, --help                    显示此帮助信息并推出
  -K, --key KEY=VALUE           不使用 /etc/login.defs 中的默认值
  -o, --non-unique              允许创建有重复 GID 的组
  -p, --password PASSWORD       为新组使用此加密过的密码
  -r, --system                  创建一个系统账户
  -R, --root CHROOT_DIR         chroot 到的目录
  -P, --prefix PREFIX_DIR       directory prefix


//举例:
		//
		//
		//
		//
		//
  • useradd命令

用法:useradd [选项] 登录
      useradd -D
      useradd -D [选项]

选项:
  -b, --base-dir BASE_DIR	新账户的主目录的基目录
  -c, --comment COMMENT         新账户的 GECOS 字段
  -d, --home-dir HOME_DIR       新账户的主目录
  -D, --defaults		显示或更改默认的 useradd 配置
 -e, --expiredate EXPIRE_DATE  新账户的过期日期
  -f, --inactive INACTIVE       新账户的密码不活动期
  -g, --gid GROUP		新账户主组的名称或 ID
  -G, --groups GROUPS	新账户的附加组列表
  -h, --help                    显示此帮助信息并推出
  -k, --skel SKEL_DIR	使用此目录作为骨架目录
  -K, --key KEY=VALUE           不使用 /etc/login.defs 中的默认值
  -l, --no-log-init	不要将此用户添加到最近登录和登录失败数据库
  -m, --create-home	创建用户的主目录
  -M, --no-create-home		不创建用户的主目录
  -N, --no-user-group	不创建同名的组
  -o, --non-unique		允许使用重复的 UID 创建用户
  -p, --password PASSWORD		加密后的新账户密码
  -r, --system                  创建一个系统账户
  -R, --root CHROOT_DIR         chroot 到的目录
  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files
  -s, --shell SHELL		新账户的登录 shell
  -u, --uid UID			新账户的用户 ID
  -U, --user-group		创建与用户同名的组
  -Z, --selinux-user SEUSER		为 SELinux 用户映射使用指定 SEUSER


//举例:
		//
		//
		//
		//
		//
  • passwd命令

用法: passwd [选项...] <帐号名称>
  -k, --keep-tokens       保持身份验证令牌不过期
  -d, --delete            删除命名帐户的密码(仅限 root
                          用户);也删除密码锁(如果有)
  -l, --lock              锁定指名帐户的密码(仅限 root 用户)
  -u, --unlock            解锁指名帐户的密码(仅限 root 用户)
  -e, --expire            终止指名帐户的密码(仅限 root 用户)
  -f, --force             强制执行操作
  -x, --maximum=DAYS      密码的最长有效时限(只有 root
                          用户才能进行此操作)
  -n, --minimum=DAYS      密码的最短有效时限(只有 root
                          用户才能进行此操作)
  -w, --warning=DAYS      在密码过期前多少天开始提醒用户(只有 root
                          用户才能进行此操作)
  -i, --inactive=DAYS     当密码过期后经过多少天该帐号会被禁用(只有 root 用户才能进行此操作)
  -S, --status            报告已命名帐号的密码状态(只有 root
                          用户才能进行此操作)
      --stdin             从标准输入读取令牌(只有 root
                          用户才能进行此操作)


//举例:
		//
		//
		//
		//
		//
  • userdel命令
用法:userdel [选项] 登录

选项:
  -f, --force                   force some actions that would fail otherwise
                                e.g. removal of user still logged in
                                or files, even if not owned by the user
  -h, --help                    显示此帮助信息并推出
  -r, --remove                  删除主目录和邮件池
  -R, --root CHROOT_DIR         chroot 到的目录
  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files
  -Z, --selinux-user            为用户删除所有的 SELinux 用户映射


//举例:
		//
		//
		//
		//
		//
  • chown命令

用法:chown [选项]... [所有者][:[]] 文件...
 或:chown [选项]... --reference=参考文件 文件...
Change the owner and/or group of each FILE to OWNER and/or GROUP.

//举例:
		//
		//
		//
		//
		//
  • chgrp命令

用法:chgrp [选项]... 用户组 文件...
 或:chgrp [选项]... --reference=参考文件 文件...
Change the group of each FILE to GROUP.


//举例:
		//
		//
		//
		//
		//
  • chmod命令

用法:chmod [选项]... 模式[,模式]... 文件...
 或:chmod [选项]... 八进制模式 文件...
 或:chmod [选项]... --reference=参考文件 文件...

将每个文件的权限模式变更至指定模式。
使用 --reference 选项时,把指定文件的模式设置为与参考文件相同。


//举例:
		//
		//
		//
		//
		//
  • id命令

Usage: id [OPTION]... [USER]
Print user and group information for the specified USER,
or (when USER omitted) for the current user.


//功能
		//
		//
		//
		//
		//

七、压缩命令

  • gzip格式命令

Usage: gzip [OPTION]... [FILE]...
Compress or uncompress FILEs (by default, compress FILES in-place).

Mandatory arguments to long options are mandatory for short options too.

  -c, --stdout      write on standard output, keep original files unchanged
  -d, --decompress  decompress
  -f, --force       force overwrite of output file and compress links
  -h, --help        give this help
  -k, --keep        keep (don't delete) input files
  -l, --list        list compressed file contents
  -L, --license     display software license
  -n, --no-name     do not save or restore the original name and timestamp
  -N, --name        save or restore the original name and timestamp
  -q, --quiet       suppress all warnings
  -r, --recursive   operate recursively on directories
      --rsyncable   make rsync-friendly archive
  -S, --suffix=SUF  use suffix SUF on compressed files
      --synchronous synchronous output (safer if system crashes, but slower)
  -t, --test        test compressed file integrity
  -v, --verbose     verbose mode
  -V, --version     display version number
  -1, --fast        compress faster
  -9, --best        compress better


//功能
		//
		//
		//
		//
		//
  • zip命令

Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  The default action is to add or replace zipfile entries from list, which
  can include the special name - to compress standard input.
  If zipfile and list are omitted, zip compresses stdin to stdout.
  -f   freshen: only changed files  -u   update: only changed or new files
  -d   delete entries in zipfile    -m   move into zipfile (delete OS files)
  -r   recurse into directories     -j   junk (don't record) directory names
  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  -1   compress faster              -9   compress better
  -q   quiet operation              -v   verbose operation/print version info
  -c   add one-line comments        -z   add zipfile comment
  -@   read names from stdin        -o   make zipfile as old as latest entry
  -x   exclude the following names  -i   include only the following names
  -F   fix zipfile (-FF try harder) -D   do not add directory entries
  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  -T   test zipfile integrity       -X   eXclude eXtra file attributes
  -y   store symbolic links as the link instead of the referenced file
  -e   encrypt                      -n   don't compress these suffixes
  -h2  show more help


//功能
		//
		//
		//
		//
		//
  • bzip2根式命令

usage: bzip2 [flags and input files in any order]

   -h --help           print this message
   -d --decompress     force decompression
   -z --compress       force compression
   -k --keep           keep (don't delete) input files
   -f --force          overwrite existing output files
   -t --test           test compressed file integrity
   -c --stdout         output to standard out
   -q --quiet          suppress noncritical error messages
   -v --verbose        be verbose (a 2nd -v gives more)
   -L --license        display software version & license
   -V --version        display software version & license
   -s --small          use less memory (at most 2500k)
   -1 .. -9            set block size to 100k .. 900k
   --fast              alias for -1
   --best              alias for -9

//举例:
		//
		//
		//
		//
		//
  • tar命令

用法: tar [选项...] [FILE]...
GNU 'tar' saves many files together into a single tape or disk archive, and can
restore individual files from the archive.

Examples:
  tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
  tar -tvf archive.tar         # List all files in archive.tar verbosely.
  tar -xf archive.tar          # Extract all files from archive.tar.

//
		//
		//
		//
		//
		//

八、网络相关命令

  • ifconfig命令

Usage:
  ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
  [add <address>[/<prefixlen>]]
  [del <address>[/<prefixlen>]]
  [[-]broadcast [<address>]]  [[-]pointopoint [<address>]]
  [netmask <address>]  [dstaddr <address>]  [tunnel <address>]
  [outfill <NN>] [keepalive <NN>]
  [hw <HW> <address>]  [mtu <NN>]
  [[-]trailers]  [[-]arp]  [[-]allmulti]
  [multicast]  [[-]promisc]
  [mem_start <NN>]  [io_addr <NN>]  [irq <NN>]  [media <type>]
  [txqueuelen <NN>]
  [[-]dynamic]
  [up|down] ...

//
		//
		//
		//
		//
		//
  • route命令

Usage: route [-nNvee] [-FC] [<AF>]           List kernel routing tables
       route [-v] [-FC] {add|del|flush} ...  Modify routing table for AF.

       route {-h|--help} [<AF>]              Detailed usage syntax for specified AF.
       route {-V|--version}                  Display version/author and exit.

        -v, --verbose            be verbose
        -n, --numeric            don't resolve names
        -e, --extend             display other/more information
        -F, --fib                display Forwarding Information Base (default)
        -C, --cache              display routing cache instead of FIB


//功能
		//
		//
		//
		//
		//
  • netstat命令
功能:显示网络状态
		//
		//
		//
		//
		//
  • 启动网络命令
//功能:
		//
		//
		//
		//
		//
  • 手工修改网络配置
debian系统
//功能
		//
		//
		//
		//
		//



redhat系统
//功能
		//
		//
		//
		//
		//
  • 网络排错
ping
//功能:查看两个网络是否是否连接,如果连接则可以ping得通,否则,ping不通。
		//
		//
		//
		//
		//
traceroute
//功能:路由跟踪
		//
		//
		//
		//
		//
nslookup
//功能:域名解析排错
		//
		//
		//
		//
		//
		
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值