The bash shell, which is installed in almost all operating systems of the Linux family, has a very advanced command system that allows you to develop scripts with rich functionality. Scripts like this are ubiquitous on Linux systems. You can run a bash script by setting the appropriate attributes for it and having the necessary rights.
Necessary
- - an account on the target machine;
- - possibly root.
Instructions
Step 1
Log in to the console on the machine where the script is to be executed. Start a terminal emulator (konsole, XTerm, etc.) or switch to the text console by pressing one of the Ctrl + Alt + Fx keyboard shortcuts. If there is no physical access to the computer, connect to it over the network using an ssh client (for example, PuTTY under Windows or ssh under Linux). If required, enter your account information
Step 2
Change the current directory to the one where the script file is located. This should be done for the convenience of further work. Use the cd command, the parameter of which must be an absolute or relative path to the target directory. For example: cd / home / tmp / You can also use a file manager like Midnight Commander
Step 3
Change the permissions of the script file if necessary. Make it executable and editable with your account. If you are the owner of the file, run the chmod command, changing the permissions. For example: chmod 0755./test.sh If the file is owned by another user, then either temporarily set permissions to 0777 by running chmod with sudo, or change the owner and group with chown (also from sudo). If you use a file manager, such actions can be much more convenient to perform with its help (in Midnight Commander these are the corresponding items of the File menu)
Step 4
Review and, if necessary, edit the script with the path to the bash interpreter after the #! Characters on the first line. Use your preferred text editor. For example vim or Midnight Commander editor. Save the modified script file
Step 5
Run the bash script. Enter in the console the absolute or relative path to the directory with the script file, its name, and parameters, if necessary. Press ENTER.