linux命令使用规则及如何获取帮助
linux命令介绍
命令的语法格式
COMMAND OPTIONS ARGUMENTS
命令 选项 参数
命令(COMMAND):
命令
应用程序
脚本程序
命令的类型:
内建命令:由shell程序自带的命令
外部命令:本身是一个独立的可执行程序文件,命令名即为程序文件名
查找命令的方式
重要通过shell的内置的环境变量PATH中指定的路径进行查找
#echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
查看命令的类型:
type:
type COMMAND
type cd
cd is a shell builtin cd是shell命令,是一个内建命令
选项(OPTIONS):调整命令的作用方式
短选项:-char例如: -l,-d,-h
多个选项间要使用空白分隔:-l -d -h
合并使用:-ldh
长选项:--word,例如:--long, --directory, --human, --readable
长选项一般不能合并使用
注意:有些选项需要带参数,称为选项参数
例:mkfs -t ext4
参数(ARGUMENTS):
命令的作用对象,有的命令可以带多个参数
列子:
ls /etc/sysconfig
ls:是命令,此命令的作用是查看
/etc/sysconfig:是参数,是ls命令查看的对象
整个命令的意思就是:查看 /etc/sysconfig 这个文件
ls -l /etc/sysconfig
这里相比上一个命令加了一个 -l 是选项,这里 -l 就是将 ls 作用方式改变为 详细显示,比原不加 -l 显更加更 加详细
#################################华丽的分割线##############################################
如何获取命令帮助
内置命令:help COMMAND
列如:help history
外部命令:
1、COMMAND --help
2、手册,manual (/usr/share/man/)
手册章节:1-9
man手册对不同的对象给出了不一样的章节来归类
1:用户命令
2:系统调用
3:库调用
4:设备文件
5:配置文件
6:游戏
7:杂项
8:管理命令
man [#] COMMAND --------------------------->#:章节 []:可省
如何查看指定命令在那些章节下有帮助
whatis COMMAND
手册的段落
NAME:命令名称
DESCRIPTION:命令功能的详细描述
OPTIONS:所有现象
EXAMPLES:使用事例
FILES:与当前命令相关的配置文件
SEE ALSO:可参考的其他手册
帮助中的格式字串
[]:可省略
<>:不可省略
|:二选一或多选已
...:同类内容可以出现多个
man的使用机制
翻屏:
空格键:向文件尾部翻一屏
b:向文件首部翻一屏
回车键:向文件尾部翻一行
k:向文件首部翻一行
ctrl+d:向文件尾部翻半屏
ctrl+u:向文件首部翻半屏
字符串搜索
/keyword :从文件首部向尾部进行搜索
?keyword:从文件尾部向首部进行搜索
n:显示找到的下一个
N:显示找到的上一个
退出
q
注意:man能够为除命令之外的配置文件、系统调用、库调用等
info命令:获取在线文档
仅在man手册无法获取到足够信息,或想了解程序的开发历史时才使用info
很多应用程序都自带有帮助文档:/usr/share/doc
目标程序目录下,下面两个文件:
ChangeLog:安装方法说明
README:程序说明信息
主流发行版官方文档
redhat,suse,debian
##########################################################################################
man 命令参考解析
#man ifconfig
IFCONFIG(8)----->man手册第8章 Linux Programmer’s Manual IFCONFIG(8)
NAME ------------------------------------------------------------------------>(命令名称)
ifconfig - configure a network interface -------------------------->(命令简称)
SYNOPSIS ------------------------------------------------------------------>(命令的使用格式)
ifconfig [interface] -------------------------------------------------->(具体使用格式 [] 为非必须选项)
ifconfig interface [aftype] options | address ... ------------------>(另一种使用格式 | 选一选项)
NOTE ------------------------------------------------------------------>(简介)
This program is obsolete! For replacement check ip addr and ip link. For statistics use ip -s link.
DESCRIPTION ------------------------------------------------------------------>(命令功能的详细描述)
Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as
necessary. After that, it is usually only needed when debugging or when system tuning is needed.
If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argu-
ment is given, it displays the status of the given interface only; if a single -a argument is given, it displays the
status of all interfaces, even those that are down. Otherwise, it configures an interface.
Address Families
If the first argument after the interface name is recognized as the name of a supported address family, that address
family is used for decoding and displaying all protocol addresses. Currently supported address families include inet
(TCP/IP, default), inet6 (IPv6), ax25 (AMPR Packet Radio), ddp (Appletalk Phase 2), ipx (Novell IPX) and netrom (AMPR
Packet radio). All numbers supplied as parts in IPv4 dotted decimal notation may be decimal, octal, or hexadecimal, as
specified in the ISO C standard (that is, a leading 0x or 0X implies hexadecimal; otherwise, a leading ’0’ implies
octal; otherwise, the number is interpreted as decimal). Use of hexamedial and octal numbers is not RFC-compliant and
therefore its use is discouraged and may go away.
OPTIONS ----------------------------------------------------------------------->(选项)
interface ----------------------------------------------------------->(具体选项,下面是功能说明)
The name of the interface. This is usually a driver name followed by a unit number, for example eth0 for the
first Ethernet interface.
up This flag causes the interface to be activated. It is implicitly specified if an address is assigned to the
interface.
down This flag causes the driver for this interface to be shut down.
[-]arp Enable or disable the use of the ARP protocol on this interface.
[-]promisc
Enable or disable the promiscuous mode of the interface. If selected, all packets on the network will be
received by the interface.
[-]allmulti
Enable or disable all-multicast mode. If selected, all multicast packets on the network will be received by the
interface.
。
。
以下省略
。
。
NOTES --------------------------------------------------------------------->(记录)
Since kernel release 2.2 there are no explicit interface statistics for alias interfaces anymore. The statistics printed
for the original address are shared with all alias addresses on the same device. If you want per-address statistics you
should add explicit accounting rules for the address using the ipchains(8) command.
Interrupt problems with Ethernet device drivers fail with EAGAIN. See http://www.scyld.com/expert/irq-conflict.html for
more information.
FILES ----------------------------------------------------------------------->(与命令相关的配置文件)
/proc/net/socket
/proc/net/dev
/proc/net/if_inet6
BUGS ------------------------------------------------------------------------>命令bugs
Ifconfig uses obsolete kernel interface. It uses the ioctl access method to get the full address information, which
limits hardware addresses to 8 bytes. Since an Infiniband address is 20 bytes, only the first 8 bytes of Infiniband
address are displayed.
While appletalk DDP and IPX addresses will be displayed they cannot be altered by this command.
SEE ALSO ------------------------------------------------------------------->相关参考手册
ip(8)
AUTHORS ------------------------------------------------------------------>作者联系方式
Fred N. van Kempen, <[email protected]>
Alan Cox, <[email protected]>
Phil Blundell, <[email protected]>
Andi Kleen
net-tools 14 August 2000 IFCONFIG(8)
#####################################华丽的分割线#########################################
命令使用的小技巧
终止当前命令的执行:Ctrl+c
本文出自 “键心通明” 博客,请务必保留此出处http://loveyp.blog.51cto.com/4450676/1623513
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。