Change Directory (cd) shortcuts

0

This has to have a simple answer, but when I try search for "cd", all the search results relate to compact disc instead of the linux command.

cd ..

takes me to the parent of the current directory I'm in. However, on my work pc, I'm also able to use

..

all on its own to do the same thing. I can do this on one of our clusters at work too, but not the other. What enables me to use this shortcut, so that I can replicate it elsewhere?

Luis Negrete

Posted 2016-09-22T21:26:52.943

Reputation: 3

google for cd linux and you'll find exactly what you're looking for, such as http://www.computerhope.com/unix/ucd.htm

– LPChip – 2016-09-22T21:33:03.980

I tried searching on google and found that site on my own. While it's pretty comprehensive, it does not mention why ".." alone works the same as "cd .." – Luis Negrete – 2016-09-22T22:58:15.620

Answers

5

If your shell is bash and it supports the autocd option, you can enable it by

shopt -s autocd

You can then use not only .., but also bin, ./data, /var/log, or any path. (It only works in an interactive shell, i.e. not in a script.)

Another option is to define an alias:

alias ..='cd ..'

I also like

alias ...='cd ../..'

choroba

Posted 2016-09-22T21:26:52.943

Reputation: 14 741

I use a .cshrc file, where I have other aliases defined, but not the one you mentioned. That's interesting though, thanks! – Luis Negrete – 2016-09-22T23:00:28.707

I was able to do it because it's already aliased in a default .cshrc file. Thanks! – Luis Negrete – 2016-09-22T23:05:04.027