Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 06-30-2004, 08:33 PM   #1
LQ Newbie
Registered: Jun 2004
Posts: 28

Rep: Reputation: 15
help, accidentally deleted /root directory

ok, heres what happend, i mad a user which home directory i set as /root, well i decided to remove the user so i clicked delete at the User and Groups options, and it came up with, Delete user's directory? and i just reacted and hit Yes. boy oh boy. big mistake, it deleted my /root folder. and all my desktop icons are gone, i logged out and back in and it gave me a default root folder. is there any way i can get my old /root directory back??? like with a rescue disk or something!!! please??!?!?!
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 06-30-2004, 09:10 PM   #2
Senior Member
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
So you deleted the root user??

I don't think you can really recover what you lost, but you really should have a normal user account and not be using root all the time.

Did you keep backups of your files and config and such?

Old 06-30-2004, 09:15 PM   #3
Senior Member
Registered: Dec 2001
Location: 35.7480 N, 95.3690 W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 47
Why would you create a normal user and set there home directory as /root?
Old 06-30-2004, 09:28 PM   #4
LQ Guru
Registered: Jul 2003
Distribution: Gentoo 2004.2: Who needs exmmpkg when you have emerge?
Posts: 1,795

Rep: Reputation: 47
The only solution I see is to somehow gain root privilage (you can't login as root to add a new user since you don't have a root user) and add root and attach full privilage to it. I wouldn't know how to do that (a shame on my Guru title ), mind you . Sorry.
Old 07-01-2004, 12:28 AM   #5
LQ Newbie
Registered: Jun 2004
Posts: 28

Original Poster
Rep: Reputation: 15
sigh, and i just reinstalled about 2 days ago. and had everything installed and working. DAMN! oh well... one of those things i learned the hard way.
Old 07-01-2004, 01:52 AM   #6
Registered: Oct 2002
Location: Bangalore
Distribution: Gentoo Linux
Posts: 96

Rep: Reputation: 16

Try this:

Get a single user shell, by passing the "single" boot param at boot-time. If you use lilo, instead of typing "linux", type "linux single". Otherwise, if you have to select the OS, then, you can press Ctrl+X to get a boot prompt and type "linux single".

If you use grub, then, type "e" at the prompt. It goes into edit mode. Go to the line having "linux ...". Type "e" again. It'll give you a prompt. At the end of the line, add "single".

This should give you a single user shell, after booting the OS. Then, edit /etc/passwd and add the line: [Remove the old line.]

The /home/root above should be an existing directory. If you're confused about what directory to give, give the directory of a real user (if you have one). Otherwise, just give /, like so:

Reboot. Login as root (you won't need a password). Change the home directory in /etc/passwd to /root after you remake the directory. Set a new password and make a new user who WON'T be able to delete the root directory.

Tell me if it doesn't work,

PS: If all else fails, get a Knoppix CD and edit /etc/passwd, and add the line above.

PS: Are you sure just a "su -" won't work?

Last edited by arvind_sv; 07-01-2004 at 01:58 AM.
Old 07-01-2004, 02:02 AM   #7
Senior Member
Registered: Mar 2003
Location: Beautiful BC
Distribution: RedHat & clones, Slackware, SuSE, OpenBSD
Posts: 1,791

Rep: Reputation: 50
From your initial post, I gather that you have not deleted the root account and can still function as normal root. When you logged into X as root, your icons, etc went missing and perhaps your desktop looked very "un-root".

Although you won't be able to retrieve your old configs,

you can change the default home of the other user to /home/otheruser using the usermod command as

#usermod -d /home/otheruser otheruser

create a home directory for otheruser

#chown otherusertheruser /home/otheruser
#chmod 700 /home/otheruser

restore root rights to the /root directory

#chown -R root:root /root
#chmod 750 /root

Last edited by ppuru; 07-01-2004 at 02:04 AM.
2 members found this post helpful.


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
accidentally renamed my root " / " directory rioguia Linux - Newbie 24 10-28-2004 02:47 PM
Accidentally deleted files rwalkerphl Linux - Newbie 3 06-24-2004 06:11 PM
Accidentally deleted /etc/init.d .. what do i do? :| waste Linux - General 5 03-04-2004 03:39 AM
accidentally deleted /etc/profile tanbetien Fedora 2 11-21-2003 09:42 PM
accidentally rm -fr in root (/) directory Under Fire Linux - Newbie 2 11-15-2003 10:03 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:43 AM.

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
Open Source Consulting | Domain Registration