Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Beginner at linux here, is there a way to create a permanent link between a command and the directory it's within. I've got XAMPP installed and to start i'm using:

/opt/lampp/lampp start

Is there a way to change this so instead I can just type

lampp start

Without changing the directory (i.e like how normal commands are executed in linux)

share|improve this question

migrated from Nov 7 '10 at 1:52

This question came from our site for professional and enthusiast programmers.

Assuming you're using Bash.

The way you would do this is by adding the directory /opt/lampp to your PATH variable:

export PATH=${PATH}:/opt/lampp/

To retain this change permanently, you could add the above line to your .bash_profile file. As demonstrated already, there are multiple answers to this kind of problem. I'd recommend dedicating a bit of time to reading about Linux in general, it will save you time in the long run. A decent Bash tutorial is here:

share|improve this answer
Just out of curiosity, I've always set my PATH with PATH=$PATH:/whatever/dir instead of PATH=${PATH}:/whatever/dir. Is there any difference between using the curly brackets and not? – Wuffers Nov 7 '10 at 2:00
There's actually a lot you can do with curly braces in Bash. When referring to variables, I use them to delimit the variable contents from the string it's being attached to. Your example works because of the : and the / in between PATH and the rest of the content. If (for example) you tried to join the string like: PATH=$PATHwhatever/dir, you'd run into problems. For other cool stuff you can do with curly braces, search for "curly brace expansion" or play around with tricks like: ${COLOUR:-blue} – Paul Andrew Nov 8 '10 at 15:54
In this case the curlies are not needed, but it is always safe to add them, and not always safe to remove them. – richard 15 hours ago

You can also create an alias. Edit the file ~/.bashrc and add a new alias, such as :

alias startlamp='/opt/lampp/lampp start'

Then, you can type startlamp instead of /opt/lampp/lampp. Please note that this alias is only valid for your own user, and not everyone that uses your computer.

This does not create a link, though, unlike Travis' command.

share|improve this answer

Sure is. Try this:

ln -s /opt/lampp/lampp /usr/bin/lampp

ln -s creates a symbolic link to /opt/lampp/lampp from /usr/bin/lampp. The reason that we put it in /usr/bin is because that is where all your standard UNIX commands will be found, such as "ls" and "rm".

Now you can type lampp start no matter what directory you are in!

Note: you will probably need to run the above command as superuser, or root.

share|improve this answer
Brilliant works perfectly, thanks to all other answers as well. Thank you. – akd5446 Nov 6 '10 at 18:10
I would not recommend polluting system directories such as /usr/bin, as it could mess thing up. These directories are probably managed my you package manager. The /opt directory was added for you to add your own stuff to. There is also the /usr/local sub-structure, it has its own bin, lib, etc, etc. They are all empty waiting for you to put stuff into (for application that want to be put into this structure). For self contained applications, use /opt, and set the PATH. – richard 15 hours ago

Basically you'd want to either make a symlink (as Travis points out) point to the app from a directory which is within your path, or add /opt/lampp to your path. If you want it for your account only, you can put it into your shell's rc file in your home directory (~/.bashrc, for instance), or in the system shell config (/etc/bash.bashrc) which would make it apply to everyone.

share|improve this answer

I suggest making a bash alias.

Login with a non root account and open a terminal window
After you get the terminal window open, use vi to open ~/.bashrc

vi ~/.bashrc

In vi, either look for the aliases or just go to the end of the file
Press the 'i' key (without quotes) to enter insert mode
Type the following into your .bashrc file

alias lampstart='/opt/lampp/lampp start'

Press ESCAPE to exit insert mode Type the following to save the .bashrc file and quit vi


At the terminal, type the following command to reload your .bashrc file


now type lampstart in your terminal, and lamp should start. You could actually name the alias whatever you want, i just used the alias lampstart because it seemed logical.

share|improve this answer

I like to put all my custom commands in a ~/bin folder which I add to my path.

In ~/bin/lampp, I would have:


/opt/lampp/lampp start

Make sure you chmod a+x ~/bin/lampp. Then you can run lampp anywhere and will have the desired behavior.

The advantage of this method is you have a central location for all your own commands and aliases.


This works better for more complex commands. For more basic commands, a symlink instead of a script is better, as in Travis' answer.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.