LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 06-24-2011, 08:28 PM   #1
dc_eros
Member
 
Registered: Nov 2006
Distribution: Slackware
Posts: 294

Rep: Reputation: 39
Accidentally chown'ed and chmod'ed recursively from "/"


Hi guys,

I really have a big problem here. I was trying to create a script and that what it did was copy a file, cd to the destination, chown and chmod them to 644 for files and 755 for dirs recursively I think.

But I got a variable typo and it goes to "/" instead whacking all the files.

Gladly I have a single root su'ed. I tried others but it says operation not permitted.

What I need to do to restore permissions?

Now I'm on /bin. Looks like everything is messed up. By the way this is on a VM. (work VM).

TIA

EDIT: I was lucky I have mounted ssh filesystem and it stops on a file on my /home

So it means that /bin, /boot, /dev, /etc, /home were now owned by me. "su -" will now issue:

su: Authentication failure

even if root password is correct.

Last edited by dc_eros; 06-24-2011 at 08:38 PM.
 
Old 06-24-2011, 08:51 PM   #2
lisle2011
Member
 
Registered: Mar 2011
Location: Surrey B.C. Canada (Metro Vancouver)
Distribution: Slackware 2.6.33.4-smp
Posts: 183
Blog Entries: 1

Rep: Reputation: 25
Accidently chowned and chmoded '/'

The symbolic links will not have changed. So you can rescue them.

I assume you did this as 'root'

It really depends on how many persons use the machine, have you changed all permissions and ownership in user directories?

If you are the only person using this machine then chown root:root * but forget the recursion because some files may not have been changed.

Since this is a VM perhaps you could scrape off your data and then re-install. You didn't indicate your status with this machine but clearly you have root access.

It is why we are warned to not perform trivial tasks using root - having this event happen.

Keep in touch - I'm pulling for you.
 
1 members found this post helpful.
Old 06-24-2011, 09:10 PM   #3
dc_eros
Member
 
Registered: Nov 2006
Distribution: Slackware
Posts: 294

Original Poster
Rep: Reputation: 39
Here is my script:

Code:
#!/bin/sh
cp -ruf /media/sf_vm-shared/payslips/* /zdata/lysender/spideroak/companies/xyzcomp/payslips/
cd /zdata/lysender/spideroak/companies/xyzcomp/payslips/

if [[ $? -ne 0 ]] ; then
    echo "Cannot cd to payslips"
    exit
fi

chown lysender:users -R *
find . -type f  -exec chmod 644 {} \;
find . -type d  -exec chmod 755 {} \;
That is what I'm trying to accomplish but the early version of that uses variables. There was a typo on the variable say:

Code:
SPIRDEROAK="/path/here"

cd "$SPIDEROAK/"
chown lysender:users -R *
find . -type f  -exec chmod 644 {} \;
find . -type d  -exec chmod 755 {} \;
Then, that's all that happened

I have restored /bin, /boot, /dev, /etc and /home and didn't go that far since the script stops at some error on /home. I think I'm having a problem with my /etc. Although I have changed the ownerships and permissions, I still cannot "su -" saying authentication failed.

But I still have the last root session open here. OMG this is a work environment!

By the way I'm the only user and this is a dev machine. I didn't perform any VM snapshots so bad.
 
Old 06-24-2011, 09:50 PM   #4
SeRi@lDiE
Member
 
Registered: Jun 2006
Location: /dev/null
Distribution: Slackware 13.1, Slackware 13.37, aptosid, rhel
Posts: 547
Blog Entries: 7

Rep: Reputation: 55
I hope you learn your lesson....
Every time I want to script such task as chmod, chown, chgrp, etc..... (Which I almost never do) I perform a sample script to execute in a dummy dir and than execute the scripts with a dry run to see what the script is doing.

Any who I hope you get everything back to normal. I attached the out put of getfacl to help you reset /etc

Also chmod 755 its a start

P.S.

learn xargs
Attached Files
File Type: txt etc_deafult_perm.txt (18.8 KB, 45 views)

Last edited by SeRi@lDiE; 06-24-2011 at 09:59 PM.
 
1 members found this post helpful.
Old 06-24-2011, 10:31 PM   #5
dc_eros
Member
 
Registered: Nov 2006
Distribution: Slackware
Posts: 294

Original Poster
Rep: Reputation: 39
Thanks for both of you. Yes, I got my lesson for today...

Will be trying to restore things.
 
Old 06-24-2011, 11:00 PM   #6
dc_eros
Member
 
Registered: Nov 2006
Distribution: Slackware
Posts: 294

Original Poster
Rep: Reputation: 39
Hi there,

I have solved my su problem by following this thread: http://www.linuxquestions.org/questi...ailure-298005/

chmod +s /bin/su

But I'm afraid there are still other bins that needs suid bit. I'm attaching my /bin permissions.

Many thanks for the help!
Attached Files
File Type: txt bin-perms.txt (10.4 KB, 23 views)
File Type: txt boot-perms.txt (1.8 KB, 11 views)
 
Old 06-25-2011, 02:45 AM   #7
mRgOBLIN
Slackware Contributor
 
Registered: Jun 2002
Location: New Zealand
Distribution: Slackware
Posts: 999

Rep: Reputation: 231Reputation: 231Reputation: 231
Try Camerons smprms script.
He's an old friend of mine and he actually lives in the same town =)

http://homepages.paradise.net.nz/~cameronk/progs.html.
 
1 members found this post helpful.
  


Reply



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
Python: how do you accomplish "chmod 2755 somedir" - os.chmod not working as expected BrianK Programming 2 11-29-2010 03:03 PM
Replace ":" from multiple files names (even recursively in directories) pepeq Linux - General 3 02-01-2010 11:09 AM
Recursively add missing ".jpg" to all JPEG files. Chekote Linux - General 4 09-14-2009 11:45 PM
Logged in as "root"/Fedora 8 but get "Operation not permitted" when using "chmod etc gosunlee Linux - Newbie 7 02-10-2008 05:56 AM
shell script to recursively "compare" all files in a directory... silex_88 Programming 3 05-12-2007 04:24 AM

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

All times are GMT -5. The time now is 11:41 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