linux命令帮助
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux命令帮助相关的知识,希望对你有一定的参考价值。
linux命令帮助
shell程序搜寻可执行程序文件的路径定义在PATH环境变量中
[[email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/java/jdk1.7.0_75/bin:/usr/local/zookeeper-3.4.6/bin:/usr/local/hadoop-2.6.0/bin:/root/bin
注意:自左至右
通过 help COMMAND 查看命令的使用方法
[[email protected] ~]# help cd
cd: cd [-L|-P] [dir]
Change the shell working directory.
Change the current directory to DIR. The default DIR is the value of the
HOME shell variable.
The variable CDPATH defines the search path for the directory containing
DIR. Alternative directory names in CDPATH are separated by a colon (:).
A null directory name is the same as the current directory. If DIR begins
with a slash (/), then CDPATH is not used.
If the directory is not found, and the shell option `cdable_vars‘ is set,
the word is assumed to be a variable name. If that variable has a value,
its value is used for DIR.
Options:
-L force symbolic links to be followed
-P use the physical directory structure without following symbolic
links
The default is to follow symbolic links, as if `-L‘ were specified.
Exit Status:
Returns 0 if the directory is changed; non-zero otherwise.
使用手册(manual) man COMMAND
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 ..
--author
with -l, print the author of each file
-b, --escape
print octal escapes for nongraphic characters
--block-size=SIZE
use SIZE-byte blocks. See SIZE format below
信息页 # info COMMAND
程序自身的帮助文档
README
INSTALL
ChangeLog
内部命令帮助:# help COMMAND
hash命令:shell搜寻到的外部命令的路径结果会缓存至kv(key-value)存储中;
[[email protected] ~]# hash
hits command
1 /bin/grep
3 /bin/cat
1 /bin/ls
history命令
[[email protected] ~]# history
18 scp slaves [email protected]:/opt/conf/
19 scp slaves [email protected]:/opt/conf/
20 scp slaves [email protected]:/opt/conf/
21 cd ..
22 ls
23 cd hadoop
24 jps
25 stop-all.sh
26 jps
27 sbin/hadoop-daemons.sh start journalnode
28 hadoop namenode -format
29 jps
30 hdfs zkfc ?formatZK
31 hdfs zkfc -formatZK
32 start-dfs.sh
33 jps
34 start-yarn.sh
35 jps
36 ssh cloud2
37 ssh cloud3
38 ssh cloud4
39 ssh cloud5
40 cd /etc/ssh
管理命令历史,登录shell时,会读取命令历史文件中记录下的命令:~/.bash_history
history:
-a: 追加本次会话新执行的命令历史列表至历史文件中
-d: 删除历史中指定的命令
-c: 清空命令历史
[[email protected] ~]# cat .bash_history
chmod u-w /etc/sudoers
sudo ifconfig
shutdown -h now
ifconfig
ping www.baidu.com
shutdown -h now
ifconfig
service network restart
ping www.baidu.com
shutdown -h now
linux快捷操作
!#: 调用历史中第#条命令
比如通过history查看有如下:
1022 pwd
1023 cat .bash_history
1024 clear
1025 history
[[email protected] ~]# !1022
pwd
/root
!string:调用历史中最近一个以string开头的命令(后面再补)
!!: 上一条命令(后面再补)
外部命令帮助获取
man COMMAND
手册页:/usr/share/man
[[email protected] ~]# ls /usr/share/man/
bg de es hr it man0p man1x man3 man4 man5x man7 man8x mann pl ro sl zh_CN cs el fi hu ja man1 man2 man3p man4x man6 man7x man9 nl pt ru sv zh_TW
da en fr id ko man1p man2x man3x man5 man6x man8 man9x overrides pt_BR sk tr
注意:man1 ... man8主要作用如下:
man1: 用户命令
man2: 系统调用
man3: C库调用
man4: 设备文件及特殊文件
man5: 配置文件格式
man6: 游戏
man7: 杂项
man8: 管理类的命令
[[email protected] ~]# ls /usr/share/man/man8
abrtd.8.gz iptunnel.8.gz qmqpd.8.gz
abrt-dbus.8.gz isosize.8.gz quotacheck.8.gz
accept.8.gz iw.8.gz quota_nld.8.gz
accton.8.gz iwconfig.8.gz quotaoff.8.gz
acpid.8.gz iwevent.8.gz quotaon.8.gz
acpi_listen.8.gz iwgetid.8.gz quotastats.8.gz
addgnupghome.8.gz iwlist.8.gz raw.8.gz
addpart.8.gz iwpriv.8.gz rawdevices.8.gz
adduser.8.gz iwspy.8.gz rdisc.8.gz
agetty.8.gz kbdrate.8.gz reboot.8.gz
alternatives.8.gz kexec.8.gz regdbdump.8.gz
anacron.8.gz killall5.8.gz reject.8.gz
anvil.8.gz killpgrp.8.gz reload.8.gz
查看ls命令在哪一个文档(压缩包) ls命令在man1这个路径
[[email protected] ~]# ls /usr/share/man/man1 | grep ls.*
alsactl.1.gz
alsaloop.1.gz
alsamixer.1.gz
false.1.gz
ls.1.gz
lsattr.1.gz
lscpu.1.gz
lshal.1.gz
lsinitrd.1.gz
lslogins.1.gz
mtools.1.gz
mtoolstest.1.gz
perlsec.1.gz
perlsolaris.1.gz
perlstyle.1.gz
perlsub.1.gz
perlsymbian.1.gz
perlsyn.1.gz
pulseaudio.1.gz
xlsatoms.1.gz
xlsclients.1.gz
xlsfonts.1.gz
yum-utils.1.gz
文本搜索
/KEYWORD:
以KEYWORD指定的字符串为关键字,从当前位置向文件尾部搜索;不区分字符大小写;
搜索slave关键字
[[email protected] ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.107 master
192.168.1.108 slave
~
~
~
~
:/slave
n: 下一个
N:上一个
?KEYWORD:
以KEYWORD指定的字符串为关键字,从当前位置向文件首部搜索;不区分字符大小写;
n: 跟搜索命令同方向,下一个
N:跟搜索命令反方向,上一个
man命令的配置文件路径 /etc/man.config
[[email protected] ~]# more /etc/man.config
# MANBIN /usr/local/bin/man
#
# Every automatically generated MANPATH includes these fields
#
MANPATH /usr/man
MANPATH /usr/share/man
MANPATH /usr/local/man
MANPATH /usr/local/share/man
MANPATH /usr/X11R6/man
#
# Uncomment if you want to include one of these by default
#
# MANPATH /opt/*/man
# MANPATH /usr/lib/*/man
# MANPATH /usr/share/*/man
# MANPATH /usr/kerberos/man
#
# Set up PATH to MANPATH mapping
MANPATH /PATH/TO/SOMEWHERE: 指明新的手册文件搜索位置
# man -M /PATH/TO/SOMEWHERE COMMAND: 到指定位置下搜索COMMAND命令的手册页并显示之;
帮助手册中的段落说明:
NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXAMPLES
AUTHOR
REPORTING BUGS
SEE ALSO
SYNOPSIS:
[]:可选内容
<>: 必选内容
a|b:二选一
...: 同一内容可出现多次
man命令的操作方法:
Space, ^V, ^f, ^F: 向文件尾翻屏;
b, ^B: 向文件首部翻屏;
d, ^D: 向文件尾部翻半屏;
u, ^U: 向文件首部翻半屏;
RETURN, ^N, e, ^E or j or ^J: 向文件尾部翻一行;
y or ^Y or ^P or k or ^K:向文件首部翻一行;
q: 退出;
#:跳转至第#行;
1G: 回到文件首部
G:翻至文件尾部
这章内容非常有用!一定要深刻理解哦!!!
本文出自 “梁小明的博客” 博客,请务必保留此出处http://7038006.blog.51cto.com/7028006/1793777
以上是关于linux命令帮助的主要内容,如果未能解决你的问题,请参考以下文章