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.

Peeyush Kushwaha

Peeyush Kushwaha

Casual developer, nothing fancy

More from Medium

Alias Bash inside Powershell

Learning Bash Part 6: Common expansions

Command line arguments in Bash Scripting

Dockerfile COPY cannot find the file