How do I make a Linux or FreeBSD file an executable file?

Posted on in Categories last updated March 30, 2006

You need to use chmod command which is use to change file access permissions as well as to setup an executable permission on file.

General syntax:
chmod +x file-name

For example to setup executable permission on a file called foo.sh (shell script):

$ chmod +x foo.sh

To execute file:

$ ./foo.sh

To setup executable permission on a binary file called bar:

$ chmod +x bar

To execute binary file:

$ ./bar

See also:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

1 comment

  1. Thanks for this. I’m trying to work from the CLI as much as poss. these days. Trouble was I had to keep going back to the GUI to make my simple scripts executable.

Comments are closed.