LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-09-2006, 08:14 AM   #1
manishsingh4u
Member
 
Registered: Oct 2005
Location: Bhopal, India
Distribution: RHEL 6
Posts: 422

Rep: Reputation: 30
How can I restore original ownerships on /


Hello friends,
I just broke everything on my operating system. I was having ownership problems with some files and folders. So, accidently I changed the ownerships of all files/folders on / to root:root. Here's
what I did. I know it's really a dumb thing.
1) logged in as root
2) unmounted other linux partitions
Code:
umount -at ext2
3) unmounted /home
Code:
umount /home
4) Changed ownerships of all files on / to root
Code:
chown -cR root:root /
Now, I can't do much from my local user account. can't ping, can't even use su.
Is there any way around to fix the ownerships to their orignal form? Any suggestions?
 
Old 07-09-2006, 09:53 AM   #2
ledow
Member
 
Registered: Apr 2005
Location: UK
Distribution: Slackware 13.0
Posts: 241

Rep: Reputation: 34
Seeing how you've wiped out the ownership of EVERYTHING and that linux does not come with an UNDO button, you're quickest and best bet is to restore from a backup (you DO have a backup?) or to reinstall.

The problem is, yes you could fix your home directory for yourself but there are about 1000 seperate executables, no end of libraries etc. that all have differing permissions. You won't be able to guess those easily, or "blanket" permission them. Restore from backup.
 
Old 07-09-2006, 10:18 AM   #3
manishsingh4u
Member
 
Registered: Oct 2005
Location: Bhopal, India
Distribution: RHEL 6
Posts: 422

Original Poster
Rep: Reputation: 30
Hello ledow,
Thanks for the reply. I do have a backup of all my data files but I don't keep any backup of the operating system as I usually change it every month.
It's my personal PC only and even if the operating system crashes, it's not gonna hurt. But, I didn't just do a reinstall as I thought I should learn to fix it.
At present, the situation is a bit better. Now I can login with my normal account in KDE.
I changed the ownership of / again so that I can backup some newly installed config files.
Code:
chown -cR root:users /
My normal username is mann, so
Code:
chown -cR mann:root /tmp/*mann*
Now I am going to reinstall it. Right now I am copying the basic configuration files to a backup folder like smb.conf, vsftpd.conf, inet1.conf etc..so that I wouldn't have to config them again after installation.
I have one more question before I proceed for a reinstall. Should I format the / partition or just do installation over the current one without formatting it? What would u suggest?

Last edited by manishsingh4u; 07-09-2006 at 10:28 AM.
 
Old 07-09-2006, 10:56 AM   #4
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
Quote:
Originally Posted by manishsingh4u
Hello friends,
I just broke everything on my operating system. I was having ownership problems with some files and folders. So, accidently I changed the ownerships of all files/folders on / to root:root.
basically there are alot of files/scripts that need to be 'world readable' ......since root is the only one who can read them, much needed system scripts can't/won't start........to get everything back to normal you don't need to re-format!! just re-install everything over the the existing files and the ownership/permissions will get reset to what they
were/should be..........
 
Old 07-09-2006, 12:38 PM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,902

Rep: Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590
Here's a script which will restore the perms for eevery file on yur system, using the MANIFEST to know what they are.
Actually, this is a script which *writes* a script to do it. The resulting script will prbably be around 30MB!

Something I found awhile back from an old slacker:

http://distro.ibiblio.org/pub/linux/...s-Utils/smprms

Just copy it into /usr/local/bin and make executable to use.
 
Old 07-09-2006, 02:14 PM   #6
manishsingh4u
Member
 
Registered: Oct 2005
Location: Bhopal, India
Distribution: RHEL 6
Posts: 422

Original Poster
Rep: Reputation: 30
Thanks a lot friends. I have reinstalled my slackware. And now it's working really fine. Thanks again.
Hello 320mb,
I tried reinstalling over the previous installation but, at the end it gave me some error about less disc space. (I have 3.1 gb for / on reiserfs). And want the full installation so, formatted it and did a fresh install. As I had all the required configuration files and packages in hand, so it didn't take more than 30 min to install extra packages like mplayer, k3b, amsn etc etc. As opposed to this time, when I installed slackware first time, it took me 2 days to bring it to my desired configuration.

Hello gnashley,
You have given me something really amazing. I am gonna recreate this problem on my machine next saturday and will try this script. If it worked, I will name this script as Magic script.

Once again, thanks to all of u.

Last edited by manishsingh4u; 07-09-2006 at 05:57 PM.
 
Old 07-09-2006, 02:17 PM   #7
manishsingh4u
Member
 
Registered: Oct 2005
Location: Bhopal, India
Distribution: RHEL 6
Posts: 422

Original Poster
Rep: Reputation: 30
I was just wondering if I could save my system's current ownership / permission settings to some text file or something incase I screw it up again. Is it possible?
 
Old 07-09-2006, 02:52 PM   #8
Daga
Member
 
Registered: Apr 2006
Location: A comfy chair...
Distribution: Slackware
Posts: 110

Rep: Reputation: 15
Quote:
Originally Posted by gnashley
Something I found awhile back from an old slacker:

http://distro.ibiblio.org/pub/linux/...s-Utils/smprms
That's pretty cool

The one time I made a mistake like manishsingh4u did, I inserted the Slackware CD 1 and did this (as root, of course):

Code:
mount /mnt/cdrom
upgradepkg --reinstall /mnt/cdrom/slackware/*/*.tgz
umount /mnt/cdrom
and then repeated for CD2. Now I would probably expand it to "ls /mnt/cdrom/slackware/*/*.tgz|grep -v '^aaa'|while read PACKAGE; do installpkg $PACKAGE; done", but it seemed to work well.
 
Old 07-10-2006, 05:19 AM   #9
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,902

Rep: Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590
"save my system's current ownership / permission settings to some text file" can be done like this:
cd /
ls -lR > /path/to/file.list

But I don't think that the smprms script can use the format. You'd need to create a custom MANIFEST showing just the packages you have installed. I'd love it if someone would write a short BASH script that will parse the MANIFEST and print out entries. my PkgBuild program will build an individual MANIFEST entry, but that's for stuff compiled using PkgBuild.

I keep a copy around of another nice tool called slackdeptrack which will tell you what each package on your system provides and depends on.

You might also be interested in this script:
http://distro.ibiblio.org/pub/linux/...bin/chksysdeps
Which will find every executable on your system and run 'ldd' on it, showing the results color-coded. Might surprise you...
 
Old 07-10-2006, 06:00 PM   #10
manishsingh4u
Member
 
Registered: Oct 2005
Location: Bhopal, India
Distribution: RHEL 6
Posts: 422

Original Poster
Rep: Reputation: 30
Code:
ls -lR > /path/to/file.list
Thanks gnashley. Now, I think I should code a program in C or C++ which I will use to restore the ownerships / permissions on files. I have once coded a program the changes the permission flags 07xx on files but never thought about the ownerships. I am not good at shell scripting so I don't know which approach would be better. But, yes both of them is gonna teach me a lot I guess.
 
Old 07-11-2006, 03:22 AM   #11
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,902

Rep: Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590
Just use a BASH script -a C program would be overkill.
 
  


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
How to restore the original prompt ? kronecker General 1 01-06-2006 02:32 PM
How to restore original root crontab vrillusions Slackware 1 04-21-2004 09:54 PM
how to restore back the gnome original desktop Egyptian_Isis Linux - Newbie 2 10-31-2003 12:20 AM
Restore Original WinXP MBR under suse 8.0 Taspharel Linux - General 4 07-24-2003 10:40 PM
ownerships Config Linux - General 5 07-02-2002 06:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:50 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
Open Source Consulting | Domain Registration