有人感受Linux命令行操做是件很是神秘和高难度的事,其实并否则,只要咱们静下心来了解一下Linux命令行下操做的相关基础知识,就会发现命令行操做并无想象的那么难。命令行操做的特色能够用四个字归纳“简单高效”。在图形界面下须要点几十次鼠标的工做只须要一两条命令便可完成。咱们在学习具体命令以前,先要掌握命令的基础知识,掌握了这些,学习命令就是件很是简单的事了。shell
Linux命令使用格式:bash
命令 [选项] [参数]ide
命令、选项、参数之间使用空格分隔。学习
选项:用于调节命令的具体功能。ui
短格式选项:以"-"引导,后面跟单个字符。如“-a"、”-l“;多个短格式选项可缩写到一块儿,如”-a -l“能够缩写成”-al“。spa
长格式选项:以”--“引导,后面跟多个字符,一般为一个单词或单词缩写。如”--color“。
命令行
参数:命令操做的对象。orm
Linux命令分类:对象
内部(内建)命令:命令解释器(shell)自身附带的命令
排序
外部命令:存放于PATH路径下的可执行文件
如何判断某个命令是内部命令仍是外部命令?
type command
[root@test ~]# type pwd pwd is a shell builtin ###”pwd“是一个shell内建命令;若输出相似内容,表示该命令为内部命令 [root@test ~]# type ls ls is aliased to `ls --color=auto' ###"ls"是"ls --collor=auto"命令的别名;若输出相似内容,表示该命令为外部命令(关于命令别名,在后续部分探讨)
得到Linux命令帮助的方法:
内部命令:
help command
[root@test ~]# help pwd pwd: pwd [-LP] Print the name of the current working directory. Options: -L print the value of $PWD if it names the current working directory -P print the physical directory, without any symbolic links .......
外部命令:
command --help
[root@test ~]# ls --help 用法:ls [选项]... [文件]... 列出 FILE 的信息(默认为当前目录)。 若是不指定-cftuvSUX 或--sort 选项,则根据字母大小排序。 长选项必须使用的参数对于短选项时也是必需使用的。 -a, --all 不隐藏任何以. 开始的项目 -A, --almost-all 列出除. 及.. 之外的任何项目 .......
命令使用手册。以上方法能够得到某个命令的使用方法,但不够详细,若是须要得到命令更加详细的信息,可以使用”man”命令阅读命令的使用手册
man [n] command
n:手册章节,不一样章节对应不一样类型信息,省略该选项时从1-8按顺序自动匹配,若是须要查看某个章节,能够用对应数字指定查看某一章节
1:用户命令(/bin,/usr/bin,/usr/local/bin)
2:系统调用
3:库调用
4:特殊文件(设备文件)
5:文件格式(解释配置文件的使用方法)
6:游戏
7:杂项(不便归类的内容)(Miscellaneous)
8:管理命令(管理员使用的命令)(/sbin,/usr/sbin,/usr/local/sbin)
[root@test ~]# man ls ###执行命令后会进入交互式阅读模式 LS(1) User Commands LS(1) NAME ###命令简要说明 ls - list directory contents SYNOPSIS ###使用方法(“[]”部分能够省略;“...”表示能够出现多个;“<>”表示必须填写;“|”表示多选“{}”表示分组,无特殊意义 ls [OPTION]... [FILE]... DESCRIPTION ###命令功能详细描述(包含命令选项的详细功能描述) List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. ....... REPORTING BUGS ###如何提交BUGS Report ls bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> ....... COPYRIGHT ###版权信息 Copyright 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL ....... SEE ALSO ###另外参照 The full documentation for ls is maintained as a Texinfo manual. If the info and ls programs are properly installed at your site, the command .......
man命令交互式阅读模式使用方法:
翻屏:“空格”向后翻屏;“b”向前翻屏
翻行:“回车”向后翻行;“k“向前翻行
查找:”/keyword"从前向后查找关键字“keyword"(”n“键查找下一个;”N“查找上一个)
”?keyword"从后向前查找关键在“keyword”(”n“键查找下一个;”N“查找上一个)
退出:“q”
若是想要了解某个命令的更加详细的功能介绍、命令发展历史等关于命令的其余信息,可使用“info”命令查看相关信息
info command
[root@test ~]# info ls File: coreutils.info, Node: ls invocation, Next: dir invocation, Up: Directory listing 10.1 `ls': List directory contents ================================== The `ls' program lists information about files (of any type, including directories). Options and file arguments can be intermixed arbitrarily, as usual. .......
info命令交互式阅读模式使用方法:
翻屏:"Page Down“向后翻屏;”Page Up“向前翻屏
翻行:上下光标键
退出:”q“