更新时间:2022-01-22 09:40:58浏览次数:854+次
以下为你详细解释help、head、hash、halt命令的用法。
Linux help命令的用法及解释
Linux help命令用于显示shell内部命令的帮助信息。help命令只能显示shell内部的命令帮助信息。而对于外部命令的帮助信息只能使用man或者info命令查看。
1、语法
help(选项)(参数)
2、选项
-s:输出短格式的帮助信息。仅包括命令格式。
3、参数
内部命令:指定需要显示帮助信息的shell内部命令。
4、实例
使用help命令显示shell内部shopt命令的帮助信息,输入如下命令:
help shopt #获取shopt命令的帮助信息
shopt: shopt [-pqsu] [-o long-option] optname [optname...]
Toggle the values of variables controlling optional behavior.
The -s flag means to enable (set) each OPTNAME; the -u flag
unsets each OPTNAME. The -q flag suppresses output; the exit
status indicates whether each OPTNAME is set or unset. The -o
option restricts the OPTNAMEs to those defined for use with
`set -o'. With no options, or with the -p option, a list of all
settable options is displayed, with an indication of whether or
not each is set.
Linux head命令的用法及解释
Linux head命令用于显示文件的开头的内容。在默认情况下,head命令显示文件的头10行内容。
1、语法
head(选项)(参数)
2、选项
-n<数字>:指定显示头部内容的行数;
-c<字符数>:指定显示头部内容的字符数;
-v:总是显示文件名的头信息;
-q:不显示文件名的头信息。
3、参数
文件列表:指定显示头部内容的文件列表。
Linux hash命令的用法及解释
Linux hash命令用来显示和清除哈希表,执行命令的时候,系统将先查询哈希表。
1、必要参数
-l:显示哈希表
-r:清除哈希表
-d<名称>:清除哈希表
-p<路径>:向哈希表中增加内容
-t<命令>:显示命令的完整路径
2、实例1
[root@linux ~]# hash -l #显示哈希表
builtin hash -p /usr/sbin/fbset fbset
builtin hash -p /bin/df df
builtin hash -p /usr/bin/quota quota
builtin hash -p /usr/bin/du du
builtin hash -p /sbin/e2fsck e2fsck
builtin hash -p /bin/uname uname
builtin hash -p /bin/ls ls
[root@linux ~]# hash -t df #显示df命令的完整路径
/bin/df
[root@linux ~]# hash -p /usr/bin/halt halt #向哈希表中增加 halt
[root@linux ~]# hash -r #清空hash表
3、实例2
[root@localhost tank]# hash
hits command
7 /usr/bin/ldd
2 /usr/bin/last
4 /sbin/chkconfig
1 /bin/sh
1 /bin/uname
4 /bin/ls
Linux halt命令的用法及解释
Linux halt命令用来关闭正在运行的Linux操作系统。halt命令会先检测系统的runlevel,若runlevel为0或6,则关闭系统,否则即调用shutdown来关闭Linux操作系统。
1、语法
halt(选项)
2、选项
-d:不要在wtmp中记录;
-f:不论目前的runlevel为何,不调用shutdown即强制关闭系统;
-i:在halt之前,关闭全部的网络界面;
-n:halt前,不用先执行sync;
-p:halt之后,执行poweroff;
-w:仅在wtmp中记录,而不实际结束系统。
3、实例
halt -p //关闭系统后关闭电源。
halt -d //关闭系统,但不留下纪录。
相关资讯