I run a gaming server called PocketMine. So basically I have a folder in my home directory that has a bash script to run the server: ~/PocketMine/start.sh

Everytime I want to run the server I either cd into the folder and ./start.sh or PocketMine/./start.sh

I want to know how do I add a symlink called pocketmine in /usr/local/sbin (a lot of progs with symlinks goes here) that will run start.sh and use the contents of its dir.

/usr/local/sbin/pocketmine = ~/PocketMine/./start.sh

Call me lazy but im tired of cd-ing into the folder and running the script instead of just typing one command.

  • As the below answers have illustrated without comment, you never need to say anything quite like PocketMine/./start.sh.  You sometimes need ./ in front of a plain filename that is in the current directory (i.e., after you have done cd PocketMine); in this example, to make explicit your desire to run a program from a directory that's not in your search path.  But specifying any directory (i.e., anything with a / in it) will do that, so you can say PocketMine/start.sh if you are in your home directory, or ~/PocketMine/start.sh wherever you are, without using the /./. Commented Jun 15, 2015 at 7:24

2 Answers 2


You actually don't need any symlinks, just edit your ~/.bashrc and add the following statement:


This avoids polluting your filesystem with unnecessary clutter like symlinks. If you are a csh/tcsh user rather than a bash user, then edit ~/.cshrc and add

set path = ( $path ~/PocketMine )

Personally I'd go one step further in organization. I'd create a ~/bin directory, and put your start script in there, perhaps with a more distinctive name like pmstart (it's not significant that it's a shell script, is it? Maybe someday you want to re-implement it in Python or something. .sh suffices on executables are usually a bad idea because you're exposing and hard-coding an implementation detail (the implementation language) that end-users don't care about, and in the process committing yourself to that implementation detail unnecessarily).

It's likely your $PATH already includes $HOME/bin, but if not you can add it similarly.

Finally, there's are historical conventions/best practices as to what things go into sbin directories and what things go into bin directories. sbin is usually reserved for tools for administrators, while bin is for general end-user utilities.


If you just want to have a shorter way to run ~/PocketMine/start.sh, you can make an alias for it. Add the following line in ~/.bashrc and call pm to run that script:

alias pm=~/PocketMine/start.sh

If you need to change to the script's directory first, make it a function:

function pm (
  cd ~/PocketMine && exec ./start.sh "$@"

If you want to be able to call this shortcut from another script and not just from an interactive shell, make the shortcut a script that you put in any of the directories in $PATH. The script needs to be an executable file (e.g. chmod a+rx ~/bin/pm) and contains

cd ~/PocketMine && exec ./start.sh "$@"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .