Register shell script file as global command

A shell script file (.sh file) that has been written and tested can be registered as a globally available command for ease of use, so that the script can be used even without entering the directory where the script file is located, making the use of the script more convenient and faster.

Note: Please perform this operation under root to ensure sufficient permissions.

Steps

1. Copy the script file to  the /usr/local/bin  directory.

2. Remove the .sh suffix from the shell script name so that the shell script looks more like a command and is easy to operate. There are probably two methods I know of at present:

(1) Directly remove the suffix from mv.

(2) The same effect can also be achieved by creating a soft connection. It is recommended to use this method because it can be globally effective if modified in place.

The command is as follows:

root@master:/usr/local/bin# ln -s /shell/tomcatrestart.sh tomcatrestart

Guess you like

Origin blog.csdn.net/wangshiqi666/article/details/131362779