特定命令后面的选项是什么意思?

特定命令后面的选项是什么意思?

我如何理解各种选项/标志的含义?

例如:

1) -这里表示uname -a什么?-a

2) -这里表示pyang -f什么?-f

我只是想了解是否有一些参考/文档告诉这些的用法?请澄清。

答案1

对于几乎所有 Linux 命令,我认为最快、最简单的第一步就是在命令后附加“--help”。这为您提供了一个很好的总结,这通常就足够了。

如果您需要更多详细信息,man 命令是不错的第二选择。

例如:

$uname --help

Usage: uname [OPTION]...  
Print certain system information.  With no OPTION, same as -s.

  -a, --all                print all information, in the following order,  
                             except omit -p and -i if unknown:  
  -s, --kernel-name        print the kernel name  
  -n, --nodename           print the network node hostname  
  -r, --kernel-release     print the kernel release  
  -v, --kernel-version     print the kernel version  
  -m, --machine            print the machine hardware name  
  -p, --processor          print the processor type (non-portable)  
  -i, --hardware-platform  print the hardware platform (non-portable)  
  -o, --operating-system   print the operating system  
      --help     display this help and exit  
      --version  output version information and exit  

答案2

在 UNIX/Linux Shell 中,有四种不同类型的命令:

1. executables: compiled binaries or scripts
2. shell builtin commands
3. shell functions
4. aliases

如果遇到未知命令,首先要检查其类型。让我们看一下每种类型的几个示例:

type <command>  # indicates the commands type
--------------
type find       # find is /usr/bin/find   --> executables
type cd         # cd is a shell builtin
type dequote    # dequote is a function
type ls         # ls is aliased to 'ls --color=auto'

有了命令类型的信息,你可以得到命令的帮助、描述和用法,它的选项

<command> --help   # help for executables     -->  find --help
help <command>     # help for shell builtins  -->  help cd

man <command>      # manual page for the specific command

以下命令对于信息收集也很有用。

whatis <command>   # display a very brief description of the command
which <command>    # display an executables location

在上面的例子中,ls是别名,但ls真正的是什么?

whatis ls
help ls      # doesn't work --> ls is not a shell builtin command
ls --help    # works        --> ls is an executable / compiled binary
which ls     # /bin/ls      --> ls is an executable / compiled binary

有数千个命令可供探索:

ls /bin       # list a few executables
ls /usr/bin   # list more executables
enable -p     # list all available shell builtin commands
declare -f    # list all defined functions
alias         # list all defined aliases

现在让我们检查一下uname命令:

type uname    # uname is /bin/uname   --> executable
whatis uname
which uname
uname --help  # see the meanings of the options, e.g. -a
man uname     # read the manual page for uname

对命令执行相同的操作pyang...

相关内容