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

So I'm having a problem creating a shortcut to a deep folder. None of the examples I've seen on Superuser have helped :(

This is my path: cd / Applications / MAMP / htdocs / whoat / solr / whoat

I would like to create the shortcut solr to reach that directory

I have to use cd / to get into my computer from the desktop, because I can't navigate into my Applications folder otherwise.


I was able to get into my .bash_profile via VIM

sudo vi ~/.bash_profile

This is what I currently have inside of it, I added the last 3 lines, however none of the shortcuts work:

export PATH="/usr/local/bin:$PATH:/usr/local/share/python"
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib"
alias sublime="/Applications/Sublime\ Text\"
alias edit="/Applications/Sublime\ Text\"
alias solr="/Applications/MAMP/htdocs/website/WhoAt/solr/whoat/"

When I type solr enter, or sublime enter, nothing happens

share|improve this question
Could the downvote explain himself? – Leon Gaban Jun 11 '13 at 13:26
You question shows zero research. A quick google could have told you what the ~/.bash_profile is, let alone the other questions to asked. On that note, you asked multiple unrelated questions in the same Question. – demure Jun 11 '13 at 13:36
up vote 5 down vote accepted

Here is defined an alias solr which will cd to the named directory-:

alias solr='cd /Applications/MAMP/htdocs/whoat/solr/whoat'

Note the use of single quotes - double quotes will cause the cd to go to to the home directory.

I sometimes prefer to add a pwd to the alias as a check and reminder of what the current working directory is-:

alias solr='cd /Applications/MAMP/htdocs/whoat/solr/whoat;pwd'

Ideally you would put this alias in your .bash_profile in your home directory. You can use a text editor such as TextEdit or vim to add the alias command to .bash_profile. Then to load the new alias into your shell type-:

source .bash_profile
share|improve this answer
I put that into my bash_profile, and when I run just solr nothing happens. I don't get an error message however, just nothing happens. When I do LS I see my main Mac directory – Leon Gaban Jun 11 '13 at 13:32
Don't forget to source the revised .bash_profile - see edited answer. Also the spacing in the path - I've removed that now in my answer. – suspectus Jun 11 '13 at 13:35
if you are still having problems try setting the alias direct to the shell. Add the pwd as a check (see above). – suspectus Jun 11 '13 at 13:45
ok. First enter in command line this-: alias solr='cd /Applications/MAMP/htdocs/whoat/solr/whoat;pwd'. Then if no error type solr. That should put you in the correct directory. If that works, then type cd to get to home dir. Then type source .bash_history. Does that help? – suspectus Jun 11 '13 at 13:59
Excellent. Also, I believe the problem with the aliases in .bash_profile are the double quotes. Try changing those to single quotes - the shell gets confused with the spacing after the cd otherwise. – suspectus Jun 11 '13 at 14:11


To create links, you use the ln command. See man ln.
You could do it like ln -s /Applications/MAMP/htdocs/whoat/solr/whoat /where/you/want/link, where:

  • The first path is what you are linking
  • The second path is where the link will be

Directory Navigation

man cd

There are two ways to navigate with cd, absolute and relative.
The easiest way to get from home to applications is cd /Applications/

  • Capitalization matters....

Editing Files

Doing ~/.bash_profile isn't how you edit a file.... you were trying to run the file like it was a script (even though it a config file) Also, here is a decent article on the difference between ~/.bashrc and ~/.bash_profile

If you want to edit it from terminal, you have to use an editor, like vim/emacs/pico etc.

  • vim ~/.bash_profile
  • emacs ~/.bash_profile
  • pico ~/.bash_profile

Editing on Mac

As you are on OS X, you could use open -e ~/.bash_profile to open with TextEditor

  • Don't use sudo!


You shouldn't be using sudo to try to 'force edit' you user's files.

  • It can mess up a file's permissions to be root's
  • It can lead to damaging accidents when you don't know what you are doing (so you should avoid it)
  • Just because you were doing it wrong, doesn't make sudo a magic wand to fix commands.

In Conclusion

Please read a few unix tutorials...

share|improve this answer
Thanks for the really detailed answer, I still could not get the shortcut to work, even after editing my .bash_profile... the command just won't work unless I just directly type in 'alias solr='cd /Applications/MAMP/htdocs/whoat/solr/whoat;pwd' then the shortcut. I can just save that in a note file. I will now proceed to watch some Unix tutorials +1 – Leon Gaban Jun 11 '13 at 14:04

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.