Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-09-2010, 11:25 AM
|
#1
|
Member
Registered: Jan 2009
Location: Isle of Lewis
Distribution: Gentoo, Crunchbang (XFCE)
Posts: 133
Rep:
|
Used mv to move folder, but where are the files?
I have recently taken to using the command line more in order to gain more experience and increase my knowledge of the Linux systems.
I have a (pretty major maritally) problem. I moved the folders containing our pictures using the mv command:
Quote:
mv /{original_position} /{new_position}
|
This appeared to work until I noticed that the folders only have been moved and there is no sign of the files in either the original source or destination.
Where have they gone and can I get them back?
Next time I'm copying them and deleting the source when I make sure they are safe!!!!
Well you learn from mistakes  but I really would like these back, if only to avoid deafness and a 20 year headache.
|
|
|
01-09-2010, 11:31 AM
|
#2
|
Senior Member
Registered: Jul 2006
Location: Kolkata, India
Distribution: Debian 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,766
Rep: 
|
#man mv
your command should move source files to destination directory?
|
|
|
01-09-2010, 11:35 AM
|
#3
|
Member
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Ubuntu, SliTaz
Posts: 403
Rep:
|
If you know a filename of some of the files you lost, you could use find utility:
Code:
find /directory/to/start/search/from -name "your_file_name.ext"
or, for case-insensible search, change -name to -iname. For more info,
.
Last edited by 10110111; 01-09-2010 at 11:36 AM.
|
|
|
01-09-2010, 11:47 AM
|
#4
|
Senior Member
Registered: Jul 2006
Location: Kolkata, India
Distribution: Debian 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,766
Rep: 
|
or try
#locate part-of-filename
|
|
|
01-09-2010, 12:31 PM
|
#5
|
Member
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Ubuntu, SliTaz
Posts: 403
Rep:
|
Should have done updatedb for this to work... so find might be more efficient for one-time search.
|
|
|
01-09-2010, 02:05 PM
|
#6
|
Member
Registered: Mar 2008
Location: Ohio, USA
Distribution: Mint, Fedora
Posts: 64
Rep:
|
Wow that is odd, maybe try testdisk/photorec to recover the images. I have used it to recover images that were deleted, it worked well. http://www.cgsecurity.org/wiki/PhotoRec to install in fedora
Code:
yum install testdisk
Goodluck
|
|
|
01-09-2010, 03:23 PM
|
#7
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
This aspect of a Linux (or any) filesystem should be pretty much deterministic.
Within one physical drive, a mv command will not actually relocate anything---it only changes the info used to get to the folder/files. As others have pointed out, the files will be recoverable. (Just don't write to the disk.)
I am curious about your description of the move: "mv /source /destination". You would not normally be moving files or folders at the root level like that. Can you post exactly where the folder was and exactly what command you used?
|
|
|
01-09-2010, 09:51 PM
|
#8
|
Member
Registered: Mar 2004
Distribution: debian testing/unstable, devuan, raspberrypi OS
Posts: 68
Rep:
|
A safer option would have been to run
Quote:
cp -a /source /destination
|
and then compare them to make sure they are the same before deleting the /source directory. Even better:
Quote:
tar -jvcf backup.tar.bz2 /source && cp -a backup.tar.bz2 /destination/ && cd /destination && bzip2 -dc backup.tar.bz2 |tar xvf -
|
That's just an example of what can be done.
|
|
|
01-09-2010, 11:09 PM
|
#9
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852
|
I suggest also using the -v option to provide verbose output, both for mv and cp. Set it up as an alias for it so that it becomes the default behavior. It would've probably told you instantly what happened.
You might also consider the -i option, which makes it ask you interactively before actually performing the move, although that can become tedious when you're operating on a large number of files at once. One compromise is to use -i for the first few files, then crtl+c terminate the command and re-run it for the rest of them without the interaction.
|
|
|
01-10-2010, 06:21 PM
|
#10
|
Member
Registered: Jan 2009
Location: Isle of Lewis
Distribution: Gentoo, Crunchbang (XFCE)
Posts: 133
Original Poster
Rep:
|
Well folks, thanks to everybody for the help and advice. I searched using parts of the file names, extensions but got nothing. However I did try photorec after a suggestion from highfructose327 and that has recovered my files. I will definitely copy my files from now on rather than moving them. Again thanks to everybody for their advice.
|
|
|
01-10-2010, 06:28 PM
|
#11
|
Member
Registered: Jan 2009
Location: Isle of Lewis
Distribution: Gentoo, Crunchbang (XFCE)
Posts: 133
Original Poster
Rep:
|
Quote:
Originally Posted by pixellany
I am curious about your description of the move: "mv /source /destination". You would not normally be moving files or folders at the root level like that. Can you post exactly where the folder was and exactly what command you used?
|
I used the command as follows:
mv /home/kevie/pics /temp/
I was keeping the stuff I was wanting before cleaning out my home folder, I had previously made a folder called temp with the mkdir command. Like I said I am trying to use the command line more and have been consulting the Command Line and Shell Scripting Bible.
|
|
|
01-11-2010, 02:09 AM
|
#12
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852
|
There's no need to be afraid to use mv or to be overly-cautious with it. But you do have to watch what you're doing. I think the problem you had is mostly because the default action for many *nix tools is to work silently, without feedback. You just need to set things up to provide you with some interaction, gain some experience, and you'll be fine.
There's a package I recommend called removeutils. Two of the programs it contains are imv and icp, which work just like the standard mv and cp, but if you give them only a single file or directory argument it will place it in an edit buffer and let you simply rename it directly. I've found it very convenient and safer than the originals when renaming files and moving directory trees. You can set up aliases so that they can perform as substitutes for the core versions.
I still suggest using the interactive options, of course. 
|
|
|
01-11-2010, 02:15 AM
|
#13
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
Quote:
Originally Posted by kmacphail
I used the command as follows:
mv /home/kevie/pics /temp/
|
Just to check, whas it really "/temp/" or was it "/tmp/". If the latter did you reboot your machine? On many systems all files in /tmp/ will be deleted on a reboot.
Evo2.
|
|
|
01-11-2010, 06:06 AM
|
#14
|
Member
Registered: Jan 2009
Location: Isle of Lewis
Distribution: Gentoo, Crunchbang (XFCE)
Posts: 133
Original Poster
Rep:
|
Evo2
I did make sure that I made the folder called "temp", I may not be that experienced but I am aware that if I moved files I needed to "tmp" that I would not see them in a hurry, that's why I used the "temp" folder as it was not native and does stick out a bit at root level.
David the H
Thanks I will look into that package.
|
|
|
All times are GMT -5. The time now is 03:57 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|