How to run a file with .sh extension in Linux

I assume you are typing the file name as it is, as if it were a console command. This can’t be done like this, because your sh script isn’t really a system command.

The solution is quite simple. You can run it with “./” followed by the file name. For example:

./script.sh

Another important detail, you have to make sure that the file has execute permissions, because otherwise you could not execute the .sh script. To give executable permissions to files in Linux, use chmod and the “+x” option. The command would be something like this:

chmod +x script.sh

With this you should be able to run the sh script.

See also  Restart the FTP service on Linux
Loading Facebook Comments ...
Loading Disqus Comments ...