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, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 1 comments/add one below):

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.

    Have a question? Post it on our forum!