Find the answer to your Linux question:
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.
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    21

    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

    Code:
    bash: cd: /root: No such file or directory
    doing a ls -lah gives me (and of course other files are there too)
    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

  2. #2
    Linux Engineer khafa's Avatar
    Join Date
    Apr 2008
    Location
    Tokyo, Japan
    Posts
    858
    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

  3. #3
    Linux 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 /" ?

  4. $spacer_open
    $spacer_close
  5. #4
    scm
    scm is offline
    Linux 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

  6. #5
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    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!

  7. #6
    Just Joined!
    Join Date
    Mar 2008
    Posts
    21
    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.

  8. #7
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by raydawg View Post
    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.
    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...

  9. #8
    Just Joined!
    Join Date
    Mar 2008
    Posts
    21
    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

  10. #9
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    mv file /~ (I think thats what I typed)
    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.

    Not running is root is sound advice - it won't stop you doing stupid things, but you can do a lot less damage!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •