The basic format of shell commands

The basic syntax of Shell commands: command [选项] [对象]
[] means optional, that is not necessarily required; we will also see {option1|option2} in some command syntax, they mean choose one of two, that is, you cannot choose at the same time .
Usually add-or-before the option, when the option uses the full name, add-(ls --help) in front; when using abbreviations, add-(ls -l) in front; when there are multiple abbreviated options, they can be superimposed and omitted The following -(ls -a -l is equivalent to ls -al)
commands all have operation objects, such as files, directories, users and processes, etc. can all be used as command operation objects. But some commands do not need to specify the object, such as the rebootcommand only has options, that is because rebootthe object of the command is unique, that is, the system itself, so there is no need to specify; and some commands have default objects, if they happen to only need to operate For the default object, you can omit the object name. For example, the default object of the lscommand is the current directory , so omitting the object will also output the file name under this directory.
Some command options can or must be accompanied by parameters to achieve precise execution of the command. For example head -n 5 /etc/passwd, you can /etc/passwdoutput the first 5 lines of a file (the file stores all user data) to the console. Here /etc/passwdis the operation object, -nan option, indicating how many lines are output, and 5 is -nthe parameter of this option.

[root@hollowman ~]# head -n 5 /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

Guess you like

Origin blog.csdn.net/ymz641/article/details/111601289