Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-03-2004, 08:07 AM   #1
Registered: Jan 2004
Posts: 66

Rep: Reputation: 15
Moving A Directory.

I know how to move a file but how do I move a directory and all of the files in it?
I want to move it to a different part of the drive, a part that is locked. I can log in as root but drag and drop don't work. :'(

thanks for the help.

Also.. I want to run a website off my machine in the future and was wondering if slackware is good for that?

Last edited by reesee; 02-03-2004 at 08:12 AM.
Old 02-03-2004, 09:31 AM   #2
Registered: Nov 2003
Location: Northcliffe, WA
Distribution: Slackware 12.0
Posts: 481

Rep: Reputation: 30
mv <source> <destination>
Old 02-03-2004, 09:44 AM   #3
Registered: Aug 2003
Location: Chapel Hill, NC
Distribution: Gentoo, Windows 95 2000 & XP
Posts: 160

Rep: Reputation: 30
I could never figure out how to move an entire directory with mv. So I use:
cp -r <directory> <destination>
then I remove the directory after making sure it copied alright with:
rm -r <directory>
Old 02-03-2004, 09:57 AM   #4
Registered: Nov 2003
Location: Northcliffe, WA
Distribution: Slackware 12.0
Posts: 481

Rep: Reputation: 30
you can just use mv as it is to move directories
mv docs/ docs2/
will move docs inside docs2 folder if it does not exist it will rename docs folder to docs2
Old 02-03-2004, 10:27 AM   #5
LQ Newbie
Registered: Feb 2003
Location: State, you ask? Denial.
Distribution: Mandrake 9.2
Posts: 23

Rep: Reputation: 15
The only thing wrong with statmobile's way of doing it (other than its break from the *nix philosophy of laziness) is that the files are copied from one location on the hard drive to another, taking up double the amount of space and causing the operation to take longer. In contrast, the move does not actually change the physical location of the file, it simply changes the place that the files can be found inside your operating system. (I'm sure there are exceptions to this, such as in the case of mounted devices and whatnot)

At least that's my understanding of what cp does. I might be wrong and that it creates a hard link where it's being copied, rather than creating a whole new copy, although that would be inconsistent with the typical behavior of copy.
Old 02-04-2004, 01:40 AM   #6
Registered: Nov 2003
Location: Northcliffe, WA
Distribution: Slackware 12.0
Posts: 481

Rep: Reputation: 30
I dont think it would create a link if it did that then modifying a file that was copyied would then modify the original file
Old 02-04-2004, 02:16 AM   #7
LQ Newbie
Registered: Feb 2004
Distribution: Red Hat
Posts: 20

Rep: Reputation: 0

If you want to move a directory and all the files and directories inside that with all the files and direcotires inside those directories and so forth you can use the -r option of mv command and -f to force the moving any how:

mv -rf source dest

Hope it would be useful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Elegantly moving a large directory. aje Linux - General 2 07-07-2005 09:17 AM
Moving /home Directory? NovaBurst DamnSmallLinux 1 04-18-2005 10:59 PM
Moving my /home directory to another hd bumpert Linux - Newbie 6 07-26-2004 03:27 AM
problem moving directory sanjith11 Linux - Software 4 06-02-2004 07:06 AM
moving a symlink in a directory e1000 Linux - General 2 02-23-2004 05:09 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:57 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration