LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 10-08-2008, 09:35 AM   #1
fedora_user
Member
 
Registered: Jan 2006
Posts: 112

Rep: Reputation: 15
misuse of mv command


hi
i have accidently mv all files into one folder.
im not sure how to reverse the process a because i dont know and b because non of the commands work.
i can cd into the folder which i accidently moved everything into. but cannot move the files back out. any body have any suggestions will be much appreciated.
thanks
 
Old 10-08-2008, 09:43 AM   #2
junpa
Member
 
Registered: Aug 2008
Location: Northern Hemisphere
Distribution: Slackware, OpenVMS, fbsd
Posts: 50

Rep: Reputation: 16
What files, which folder, what errors do you see?

copy paste exerpt of command line maybe?
 
Old 10-08-2008, 09:53 AM   #3
fedora_user
Member
 
Registered: Jan 2006
Posts: 112

Original Poster
Rep: Reputation: 15
sorry, here more info

sorry
it started off with the following commands:
[root@puny bin]# mv * databasessl/
mv: cannot move `databasessl' to a subdirectory of itself, `databasessl/databasessl'
[root@puny bin]# mv * databasessl
-bash: /bin/mv: No such file or directory
[root@puny bin]# ls
-bash: /bin/ls: No such file or directory
[root@puny bin]# ls
-bash: /bin/ls: No such file or directory
[root@puny bin]# ls
-bash: /bin/ls: No such file or directory
...
...
as you can see the errors are that no commands are being recognised... realised this must be because i copied the bin folder into the databasessl folder as well. im trying to bring it back to its orignal state meaning copying everything back out. any help wor direction of help will be great
 
Old 10-08-2008, 09:53 AM   #4
fedora_user
Member
 
Registered: Jan 2006
Posts: 112

Original Poster
Rep: Reputation: 15
i knew i should have used the damn cp command!
 
Old 10-08-2008, 09:58 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
What do you mean you moved all files into one folder? All the files on the system? Do you mean you moved all of your system files as root? Give us some details here.

I'm going to hazard a guess that if the damage is as extensive as it sounds, it may be best to simply reinstall the os. There's no "revert" ability in the basic mv application, after all. Since you now can't seem to access most of the basic commands, it sounds to me like you've moved all of the /bin files at least, including the mv command itself. If you've also move the /usr/bin files or your /usr/lib files, then you've really got a headache on your hands and you probably only still have a working bash shell because because it's remained loaded in memory after your accident, and the second you close the shell you may be out of luck. BTW, that's why you can still use cd--because it's a built-in bash shell command and not a separate /bin binary like mv is.

Until then though, you should be able to at least access most of your commands by giving the full path to them; which in this case means the path to the directory you moved everything into. e.g. "/path/to/mv filea locationb". Whether this will do you any good or not depends on just how badly you've hosed your system.
 
Old 10-08-2008, 10:13 AM   #6
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
[Now that I've seen the follow-up posts]:

Ouch. I assume you were in / when you ran that command. You may be in luck. I'm guessing you simply moved the entire / tree into /databasessl as is. If you can run "/databasessl/bin/ls" and get a working directory list, then you should also be able to run "/databasessl/bin/mv" to move everything back out again.
 
Old 10-08-2008, 10:26 AM   #7
fedora_user
Member
 
Registered: Jan 2006
Posts: 112

Original Poster
Rep: Reputation: 15
Wink wow!

Hi david
thanks for the lengthy reply.
wow!
did as you said and it worked!!:


[root@puny bin]# /bin/databasessl/cp /bin/databasessl/* /bin/
[root@puny bin]# ls
arch cat csr.sh~ dms.ccls.globalsign.revoke.pw
...
...
etc


that was quite close. not sure what the alternative would have been if this didnt work but thanks a bunch for your help david, really appreciated.
 
Old 10-08-2008, 10:37 AM   #8
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Glad to hear you got it all worked out. Yeah, you've got to be very careful with mv (or rm, etc) and wildcards. I came close to nuking all of my home files recently that way myself.
 
Old 10-08-2008, 09:57 PM   #9
henry_shadowjet
Member
 
Registered: Oct 2006
Posts: 55

Rep: Reputation: 15
Ditto, I couldn't agree more, Dave!

Even a couple of days ago, I accidentally overwritten an AVI file with the subtitle, not sure how to recover it.... I don't think there is any recovery tool for ext3 filesystem.

It's really a mess, glad it worked out for you fedora_user :P

Cheers,
Henry
 
Old 10-09-2008, 09:10 AM   #10
junpa
Member
 
Registered: Aug 2008
Location: Northern Hemisphere
Distribution: Slackware, OpenVMS, fbsd
Posts: 50

Rep: Reputation: 16
you might want to use the -i switch with your mv and rm just to be on the safe side. If you look in the man file it will explain in detail, but basically rm -i <filename> or mv -i ... will cause the shell to promopt for confirmation....think of it as the windows version of "Are you sure you want to do xyz"

you can automate this with an alias:

Code:
shell$ alias rm="rm -i" 
shell$ alias mv "mv -i"
you can also add it to your config scripts:

.bash_profile
.bashrc

check your shell docs for more information.
 
  


Reply


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
Translating windows pscp command to linux scp command help robward Linux - General 2 01-17-2008 07:02 AM
Hardware address misuse srikrishna097 Slackware 3 03-13-2007 04:59 PM
LXer: Considering the Misuse of Open Source LXer Syndicated Linux News 0 12-13-2005 02:01 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 03:23 AM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 08:14 PM


All times are GMT -5. The time now is 12:13 PM.

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