Yezee user ssh to the server, then su to the root user, ready to restart the iptables service
Run the service command to restart the iptables service:
[Root @ www sysconfig] # service iptables restart
The bash: service: command not found error is returned.
Why are there no service commands? Then I searched the internet for an explanation from a foreign forum:
Http://www.linuxquestions.org/questions/linux-newbie-8/service-__-restart-bash-command-isnt-working-102136/
The su root format cannot be used to convert to root.
Need to use
[Yezee @ www sysconfig] $ su-root
Or
[Yezee @ www root] $ su-
Or
Directly su root and then write the absolute service path/sbin/service servicename start
To the root user, you can use the service.
In this way, the bash: service: command not found error will no longer occur.
As for why do we use the-symbol? Read the help of the su command.
[Root @ www ~] # Su-help
Usage: su [OPTION]… [-] [USER [ARG]…]
Change the valid tive user id and group id to that of USER.
-,-L,-login make the shell a login shell
-G-group = group specify the primary group
-G-supp-group = group specify a supplemental group
-C,-commmand = COMMAND pass a single COMMAND to the shell with-c
-Session-command = COMMAND pass a single COMMAND to the shell with-c
And do not create a new session
-F,-fast pass-f to the shell (for csh or tcsh)
-M,-preserve-environment do not reset environment variables
-P same as-m
-S,-shell = SHELL run SHELL if/etc/shells allows it
-Help display this help and exit
-Version output version information and exit
A mere-implies-l. If USER not given, assume root.
Report bugs to <bug-coreutils@gnu.org>.
This is actually the same effect as-or-l or-login.
-,-L,-login make the shell a login shell