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

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

ADVERTISEMENTS

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:

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • Jonathan Apr 19, 2014 @ 22:22

    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.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.