文章目录
Linux命令基本格式
命令基本格式为:
命令 [选项] [参数]
其中[]代表可选项,即有些命令无选项和参数也可执行。不同的命令格式不完全一致。
shell内部命令可使用help查看帮助信息,如“echo”,可以查看命令的格式和实现的功能。
[root@centos7 ~]#help echo
echo: echo [-neE] [arg ...]
Write arguments to the standard output.
Display the ARGs on the standard output followed by a newline.
Options:
-n do not append a newline
-e enable interpretation of the following backslash escapes
-E explicitly suppress interpretation of backslash escapes
非shell内部一般可通过“–help”查看帮助信息,如“date”。具体不同命令之间格式上会有一些差异。
[root@centos7 ~]#date --help
Usage: date [OPTION]... [+FORMAT]
or: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.
选项作用
选项可以调整命令,实现更丰富的功能,不加选项只能实现最基本的功能。选项有短格式(-a)和长格式(–all)之分,实现功能形同。
[root@centos7 ~]#ls
anaconda-ks.cfg initial-setup-ks.cfg
[root@centos7 ~]#ls -a
. anaconda-ks.cfg .bash_logout .bashrc .config .dbus .tcshrc
.. .bash_history .bash_profile .cache .cshrc initial-setup-ks.cfg .viminfo
[root@centos7 ~]#ls --all
. anaconda-ks.cfg .bash_logout .bashrc .config .dbus .tcshrc
.. .bash_history .bash_profile .cache .cshrc initial-setup-ks.cfg .viminfo
参数作用
参数一般用于指定命令操作的对象。实现更加具体的操作。
[root@centos7 ~]#ls
anaconda-ks.cfg initial-setup-ks.cfg
[root@centos7 ~]#ls -l initial-setup-ks.cfg
-rw-r--r--. 1 root root 1878 Apr 18 19:01 initial-setup-ks.cfg