2

Lets say I have a script which creates a file and writes something into it (but could be anything). It could be a script that runs a set of xrandr commands to set a resolution, for example.

Is there a way in which I can create a command (working only on my system) that executes the file, even if the file is not in my working directory?

TellMeWhy
  • 17,484

1 Answers1

4

In Ubuntu, the default .profile adds your $HOME/bin directory to $PATH, assuming the former exists. This means that you can create a bin directory in your home, and any executables in there can be run without specifying the full path, which is what you want.

In the case of a Python script, also make sure that it's executable (chmod u+x blahblah) and it has the proper shebang on the first line, usually:

#!/usr/bin/python
roadmr
  • 34,222
  • 9
  • 81
  • 93
  • Additionally, after creating the ~/bin directory, you need to either close and reopen your terminal window or run source ~/.profile again. Otherwise the PATH will not be updated yet. – Byte Commander Nov 20 '15 at 17:13