Results 1 to 9 of 9
i was moving a file into my root folder and instead of typing out /root/ as the destiation I using the ~ sign....and now my root folder was totally renamed ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-19-2008 #1Just Joined!
- Join Date
- Mar 2008
- Posts
- 18
Root folder renamed to ~ sign????
i was moving a file into my root folder and instead of typing out /root/ as the destiation I using the ~ sign....and now my root folder was totally renamed to the ~ sign. all my data is in there, but I cannot even CD into the folder because every time i try i get the error
doing a ls -lah gives me (and of course other files are there too)Code:bash: cd: /root: No such file or directory
Code:-rw-r--r-- 1 root root 13M 2008-09-19 09:04 ~
so i cant renamed that folder or do anything to it.........any suggestions? there is stuff in that folder I really to get to.
thanks
- 09-20-2008 #2
what command did you run(curiosity)?
is it / or /root that you renamed?
can you run pwd to tell us where you at now.
to rename ~ just refer to it as \~Linux and me it's a love story
- 09-20-2008 #3Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
Just to be sure, can you -please- post the output of "ls -l /" ?
- 09-20-2008 #4Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
How are trying to cd to ~, just typing cd? If so, you'll be using the HOME directory which presumably is still /root - if that no longer exists, it obviously won't find it. Try
Code:mv /\~ /root
- 09-22-2008 #5
While I don't understand exactly what happened, I can tell you some of the details about what's going on.
The problem is that '~' has special meaning to most shells: it means "my home directory". It's equivalent to the environment variable $HOME.
Some when you type "cd ~", the shell is automatically changing that to "cd /home/user" (or, if you're root, "cd /root"). If that doesn't exist, you will obviously get an error.
Having said all of that, scm's solution is correct. By saying instead "cd \~", you will escape the ~, so the shell will treat it as a literal '~', and not the magic '~'.
I hope that makes sense!
- 09-23-2008 #6Just Joined!
- Join Date
- Mar 2008
- Posts
- 18
hey guys, sorry i was out of the office for a few days and didn't get a chance to check back.
yes it was the /root folder that got renamed not the / directory.
and SCM's idea kinda worked....the command worked...but it turns out that my root folder was not renamed to ~
what happened apparently is that my root folder was entirely wiped out and the file I was trying to move got renamed to ~
I have no idea how that happened by just doing a command
mv file /~ (I think thats what I typed)
looking at it now i can see maybe how the file was renamed to ~ because i put that / in front when i shouldn't have. but i have no idea why my root folder would get deleted.
- 09-23-2008 #7Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
This demonstrates why it's not a good idea to operate as root more time than strictly necessary. It's also necessary to double check carefully everything, overall the rm and mv operations, and overall if they include a -R
A typo can destroy your whole system. It happened to all of us at some point...
- 09-23-2008 #8Just Joined!
- Join Date
- Mar 2008
- Posts
- 18
yea for reals. oh well, there wasn't anything super critical in there...just a couple backup scripts that im going to have to rewrite now i guess lol
- 09-25-2008 #9Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
If you give mv a file and a directory (in that order) the file should be moved into that directory, so I suspect that whatever you did to wipe out your home directory, it wasn't that. Edit: Having engaged my brain and done a little test if you prefix the ~with the slash your shell won't interpet the slash as your home directory, so you should end with the file renamed to ~ in the root directory. That shouldn't affect your home directory, so you'll have to look elsewhere for the blame.mv file /~ (I think thats what I typed)
Not running is root is sound advice - it won't stop you doing stupid things, but you can do a lot less damage!


Reply With Quote

