Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

Is there any shortcut for cd ..?

share|improve this question
Does it take so long to type? – rightfold Mar 19 '11 at 15:08
YES, it does take too long for something needed that often. – maaartinus Mar 19 '11 at 16:08
Try push and pop – Dr. Zim Mar 19 '11 at 19:44
I'm terribly amused that someone finds cd .. too cumbersome to type – Erik Mar 20 '11 at 8:16
I suspect the people who need ‘cd ..’ so often have the “I must cd into a directory before talking about the files there” anti-pattern, rather than specifying filesystem paths. – bignose Apr 20 '11 at 7:08
up vote 66 down vote accepted

Not by default (There might be some exceptions to this), there isn't. But if you use the alias command you can create a shortcut like this:

alias ..="cd .."

This will allow you to use the command .. to do cd ...

share|improve this answer
Damn, I was just typing the exact same thing. – Majenko Mar 19 '11 at 15:10
I'm using also alias ...="cd ../.." and two more. Additionally, I can recommend alias ,=cd "$OLDPWD". – maaartinus Mar 19 '11 at 16:09
@maaartinus: cd -. – Benjamin Bannier Mar 19 '11 at 16:11
@honk I didn't know it. However, it's too long (and I don't need the output). – maaartinus Mar 19 '11 at 16:25
Could someone please explain the downvote? – Wuffers Mar 19 '11 at 22:24

Activate the autocd option. It will let you type .. for cd .. and will actually let you use any directory as a command name and will cd to it:

shopt -s autocd

For the curious, the same exists for zsh:

setopt auto_cd
share|improve this answer
That is fantastic. Time to edit .bashrc on all my linux boxes. Unfortunately it doesn't seem to work with cygwin bash. – cantfork Mar 19 '11 at 19:42
Woah, that's awesome. – Reid Mar 19 '11 at 20:38
@gordoco: yeah, it's bash 4.x only. It's the reason why I've been using zsh for 14 years. – sam hocevar Mar 20 '11 at 1:55
zsh (+ auto_cd) FTW! – Johnsyweb Mar 20 '11 at 3:17
@LaC: Technical superiority isn't always a determinant of dominance. Bash is far older and has far more written using it, and practically all shell programmers know it, more than anything else. Change can be hard. -- from someone who doesn't know what all the zsh noise is all about, and has only really ever used bash :) – Tshepang Apr 9 '11 at 8:41

I find this useful:

up() { local p= i=${1:-1}; while (( i-- )); do p+=../; done; cd "$p$2" && pwd; }

For example, up 4 = cd ../../../..

As a bonus, `up 4`/path/to/file works in a similar way to ../../../../path/to/file.

share|improve this answer
That's interesting! In 2007 I wrote a similar [function] ( for my .bashrc - file. Your solution allows to jump back the whole way with cd - too. Well done! :) – user unknown Mar 20 '11 at 8:57
Nice. I had something like this for VMS DCL when I worked on that, but didn't really think about it when I moved to Unix and its variants. – GreenMatt Oct 11 '12 at 13:33

After doing a

bind '"\eu":"cd ..\C-m"'

you can cd .. by pressing Alt-u. I used to use this on chdir championships ;-)

If you want the whole swift-chdir suite

ALT+u cd ..
ALT+n enter next dir for selection
ALT+p enter previous dir for selection
ALT+SPC choose selected dir
ALT+l list subdirectories and highlight selection

just include this in your .bashrc

swiftcd-status() {
    echo -n -e "\r\0033[1A\0033[J"

swiftcd-contents() {
    find "$swiftcdpath" -maxdepth 1 -executable -type d

swiftcd-setdir () 
    swiftcddircount=`swiftcd-contents|wc -l`;

swiftcd-pd () 
    (( --swiftcddirnum <= 0 )) && swiftcddirnum=$swiftcddircount;
    swiftcd-switch $swiftcddirnum

swiftcd-updir () 
    cd ..;

swiftcd-list () 
    local redOn="$(echo -e '\0033[31m\0033[1m')"
    local redOff="$(echo -e '\0033[m')"

    ((  swiftcddircount > 1 )) && { 
        echo $(swiftcd-contents|sed 's!^'"$swiftcdpath"'!!'|sed $swiftcddirnum' s/\(.*\)/'"$redOn"'\1'"$redOff"'/')

swiftcd-nd () 
    (( ++swiftcddirnum > swiftcddircount )) && swiftcddirnum=1;
    swiftcd-switch $swiftcddirnum

swiftcd-switch() {
    (( $1 <= swiftcddircount && $1 > 0 )) && cd $(swiftcd-contents|sed -n $1' p')

bind '"\e ":"swiftcd-setdir\C-m"'
bind '"\ep":"swiftcd-pd\C-m"'
bind '"\eu":"swiftcd-updir\C-m"'
bind '"\en":"swiftcd-nd\C-m"'
bind '"\el":"swiftcd-list\C-m"'
share|improve this answer
What's a chdir championship? ignorant – Peter Jaric Mar 19 '11 at 21:57
Directory navigation sports event. – artistoex Mar 19 '11 at 22:11
Thanks! a little less ignorant – Peter Jaric Mar 21 '11 at 9:35
@Peter You're welcome ;-) – artistoex Mar 21 '11 at 12:22

I use this one since I type too fast and often miss the space bar:

alias cd..="cd .."
share|improve this answer
Most inconvenient for a non-unix person occasionally on a *nix box +1 – mplungjan Mar 19 '11 at 17:52
s/non-unix/Windows/ – grawity Mar 19 '11 at 19:02
If you are typing so fast you are missing characters, it's hard to believe adding alias for cd.. really helps. – Olli Mar 20 '11 at 12:25
I can see how it could help if you come from dear old DOS, where cd.. was valid :) – cambraca Mar 20 '11 at 19:02
For some reason I have been typing cd.. a lot for the past week. I thought I was going to have to quit coffee but I like this solution way better. – Syntax Error Mar 20 '11 at 20:35

Try autojump: autojump on github

This will not only shorten the cd command into 'j' but also shorten the characters needed for typing the folder you want to jump into.

If you always cd into the folder /home/foo/Projects/thenextfacebook you can just do 'j face' and there you are. It learns automatically which folders are the most important ones for you and after using it for a month now I can say that it is very accurate.

share|improve this answer

I use alias …='cd ..' in my .bashrc file. Unicode rules ;)

share|improve this answer

My bashrc file contains

alias ..="cd .. && ls -lG"

as well as

alias ,,="pushd .. && ls -lG"
share|improve this answer

Try Cd Deluxe for a greatly improved cd command. It supports things like "cd ..." and "cd ...." and so on in order to quickly navigate upwards.

share|improve this answer

You must log in to answer this question.

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