Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

When I move files with a GUI file manager, I navigate to the source and destination directory in 2 different windows, and then drag and drop. Is there a way to do this in BASH (move a file to a directory, but be able to navigate to the new directory rather than needing to know the full path right away to put in the argument)

I know how to use commands like mv, and cp, but both of these take one full path as the argument, and I want to be able to navigate to the new destination separate from navigating to the source file... if that makes sense

share|improve this question
I'm not sure if I understood correctly what you want to achieve. You can use two different terminal windows(or tabs) , or VTs if you are in console mode. Then you can move and/or copy files with mv and cp as you said, and connect to a directory with cd and list the files with ls. –  NikTh Sep 18 '13 at 22:42
You have a current directory and you navigate using .. as previous directory and tab to complete. Eg mv test* ../../otherdir/private/ will move all files whose names start with test to the private directory of the otherdir directory of the second parent of the source. –  Sylwester Sep 18 '13 at 23:31
You can use the Tab key to complete paths and "navigate" directories while building the arguments to cp and mv. For example: type cp /ho and press the Tab key. –  Andrea Corbellini Sep 19 '13 at 17:47

6 Answers 6

You could use the tab feature that comes with ubuntu's terminal (ctrl + shift + t). This way you could search for your destination directory in the second tab using the cd and ls commands. then once in the desired directory you could use the pwd command (print working directory) to get the full path to said directory. Once you have that, copy and paste the path over to your first terminal tab where you are executing your cp or mv command.

enter image description here

If you are not familiar with cd and ls, here is a great little tutorial for some of the basic bash commands.

The Command Line Crash Course

I hope this is of some use to you.

share|improve this answer

I'm not sure if I understood, but you want a console file manager so you could navigate your folders in two panels. You could try with Midnight commander.

Install it with:

sudo apt-get install mc
share|improve this answer
Great answer. this is what i do now, but i really want to try to move into just using the terminal. I feel like knowledge like this will be especially handy when im ssh'd onto machines –  chasemc67 Oct 2 '13 at 15:38

Another option, that's more akin to the GUI 'cut and paste' idea.

cd /long/path/to/wherever/the/file/is/now
mv file_to_move /tmp/
cd /destination/directory/somewhere/else/
mv /tmp/file_to_move ./

But really, it involves much more typing than a simple single cp <source> <destination>

share|improve this answer

This is not exactly navigation, but I am guessing what you're looking for is TAB AUTO COMPLETION.

This will allow you to get the full part of any directory without having to know it.

Here's a great tutorial for this.

share|improve this answer

There are two commands to allow you to easily move back and forth between directories:


For an example, navigate to the first directory with cd:

cd /home/aperson/more/path/to/a/very/long/and/annoying/to/type/

Then use pushd to move to the other directory:

pushd /home/aperson/more/path/to/a/different/very/long/and/annoying/to/type/

Now when you call popd again you will be back in the first directory.

This just helps with the navigation though, you will still need to do your mv or cp separately.

Depending on how much you need to do it may be worth assigning your paths to variables so you don't have to type the full path out:


Now you can use $DIR1 and $DIR2 to refer to the directories i.e.

cp somestuff.stuff $DIR1
cd $DIR1
mv somestuff.stuff $DIR2
cd $DIR2
share|improve this answer
For most cases, I think the last part should have the variables set to /home/aperson/a/very/long/and/annoying/to/type/ & /home/aperson/a/different/very/long/and/annoying/to/type/, otherwise the files will be copied to location.txt. mv can also be used to move files. –  Wilf Jul 9 at 13:51
Thanks @Wilf, you are totally right, editing my answer. I will upvote when I get the rep! –  Michael Shaw Jul 9 at 14:02
Your welcome - also forgot to say welcome to AskUbuntu :) –  Wilf Jul 9 at 14:04
Thanks! A toast to the sharing of knowledge –  Michael Shaw Jul 9 at 14:06

I don't understand why nobody mentioned two easy ways to achieve what op asks.

First way:

cd -  #goes back to previous directory
cd -- #goes back to previous of previous directory 

Second way:


For more info check out following link

EDIT: I found really a nice .bashrc function in following link by Adam Katz which is a must for easy navigation in bash shell:

I tried it, it works well.

share|improve this answer

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.