How to make a file executable in linux?

> echo '#!/bin/bash' > hello
> echo 'echo hi' >> hello
> cat hello
#!/bin/bash
echo hi
> chmod +x hello
> ./hello
hi
> mkdir subdir
> mv hello subdir
> ./subdir/hello
hi
> cat hello
#!/usr/bin/python
print "hello from python!"
> ./hello
hello from python!

--

--

--

Casual developer, nothing fancy

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Peeyush Kushwaha

Peeyush Kushwaha

Casual developer, nothing fancy

More from Medium

Shell Scripting

Command Shortcuts — Simple Productivity booster for Linux

Stupid Bash Tricks: Pretty Path

Shell vs BASH vs PowerShell vs CMD