Commandline shortcut for current directory similar to ~ for home directory?

Your current directory is . . So, cp /foo/fam/foo . copies the file to your current directory.

The analogous construction for "one directory up," or the parent directory of your current working directory, is two dots, i.e., .. . (Thanks @djeikyb .)

So, from /usr/house/firstfloor/basement , cd .. takes you one level up to /usr/house/firstfloor.

In the same example (starting from /usr/house/firstfloor/basement, the command cd ../.. would take you to /usr/house .

You can also use $PWD with echo to get your current directory:

echo $PWD

Incidentally, $OLDPWD will give you your previous directory. (Which in bash you can also reach by typing cd - .)


You can use $(pwd), it will resolve to the output from the pwd command.

Example:

echo $(pwd)

./ represents the current directory. So you can use command cp ~/anotherdir/dir2/file ./ This will copy the file "file" into currect working directory.