Accidentally Changed File Ownership to Include a "Comment" [AIX] | Unix Linux Forums | Emergency UNIX and Linux Support

  Go Back    


Emergency UNIX and Linux Support Please post your urgent questions here for highest visibility. Posting a new thread to this forum requires Bits. We monitor this forum to help people with emergencies, but we do not guarantee response time or answers. This forum is "best effort" only. Members who reply to posts here receive a bonus of 1000 Bits per reply.

Accidentally Changed File Ownership to Include a "Comment" [AIX]

Emergency UNIX and Linux Support


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-05-2012
Scott's Avatar
Scott Scott is online now Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 24 October 2014, 12:03 PM EDT
Location: Zürich
Posts: 8,484
Thanks: 332
Thanked 1,047 Times in 914 Posts
Accidentally Changed File Ownership to Include a "Comment" [AIX]

Hi.

I've had a little mishap.

To cut a long story short, I've accidentally recursively ran chown on a directory (actually a bunch of 'em). Not a problem in itself, but I had a slight error in the code I used to get the list of directories and ended up with a comment in the file ownership.

For example, I now have directories full of stuff like:


Code:
$ ll php
total 40
drwxr-xr-x   4 # Scott -  staff    136  3 Oct 12:37 .
drwxr-xr-x  14 root   system    476  5 Oct 16:24 ..
-rw-------   1 # Scott - staff  12288  3 Oct 12:39 .swp
-rwxr--r--   1 # Scott -  staff   4817  3 Oct 10:14 test.php

And I can't seem to find a way to change it back.

Any help would be appreciated!

Thanks.

Last edited by Scott; 10-05-2012 at 10:41 AM.. Reason: update
Sponsored Links
    #2  
Old 10-05-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 24 October 2014, 7:36 AM EDT
Location: Switzerland - GE
Posts: 5,835
Thanks: 162
Thanked 414 Times in 389 Posts
Was the # part of your command line?
Where are you the tree in on what you show us just above? ( root of any filesystem?)
Sponsored Links
    #3  
Old 10-05-2012
Ygor's Avatar
Ygor Ygor is offline Forum Advisor  
Advisor
 
Join Date: Oct 2003
Last Activity: 2 May 2014, 7:14 AM EDT
Location: 54.23, -4.53
Posts: 1,801
Thanks: 1
Thanked 112 Times in 98 Posts
I thought that file ownership is just a user ID number, which you can see using ls -ln
The Following User Says Thank You to Ygor For This Useful Post:
Scott (10-05-2012)
    #4  
Old 10-05-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 24 October 2014, 7:36 AM EDT
Location: Switzerland - GE
Posts: 5,835
Thanks: 162
Thanked 414 Times in 389 Posts
Hi scott, do you remember whaat you typed? (hehe so I can corrupt my machine also...)
I cant recreate the situation so difficult to give any suggestion for now...
Sponsored Links
    #5  
Old 10-05-2012
Scott's Avatar
Scott Scott is online now Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 24 October 2014, 12:03 PM EDT
Location: Zürich
Posts: 8,484
Thanks: 332
Thanked 1,047 Times in 914 Posts
OK, the longer version

A while ago I was asked to remove some users from a production system. Rather than removing them I commented them out in /etc/passwd

i.e.
Code:
# Scott - removed 16.09.12 - userX:*:12345:45678.....

I also removed a symbolic link in /home to the actual home directory, and renamed the actual home directory to something else (i.e. /app/some/dir/prod/userX_DELETEME).

This was handy because a few days later I was asked to put some of the users back!

It's quite a few users so I thought I would write a script to do it recreate the link and rename the directories.

I've generated code to grab the username from the /etc/password but somehow got "# Scott" instead, and for reasons unbeknown seem to have run chown -R on the directory using "# Scott" as the owner, instead of the username.

I'm not quite sure why I ran chown but I have, and now I have a whole bunch of home directories which, when listed, show the owner as "#Scott -". ls -ln .
Sponsored Links
    #6  
Old 10-05-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 24 October 2014, 7:36 AM EDT
Location: Switzerland - GE
Posts: 5,835
Thanks: 162
Thanked 414 Times in 389 Posts
So what you are seeing is in fact the UID translated from /etc/passwd then ?
The Following User Says Thank You to vbe For This Useful Post:
Scott (10-05-2012)
Sponsored Links
    #7  
Old 10-05-2012
Scott's Avatar
Scott Scott is online now Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 24 October 2014, 12:03 PM EDT
Location: Zürich
Posts: 8,484
Thanks: 332
Thanked 1,047 Times in 914 Posts
Yes.

OMG. I have never seen this before.

When I added the users back, I copied them and removed the comment.

I just removed the commented line for one of them and it looks OK.

How could I never have seen this before?

ROFL. That was a waste of 20,000 bits!

Thanks
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk command to replace ";" with "|" and ""|" at diferent places in line of file shis100 Shell Programming and Scripting 7 03-16-2011 08:59 AM
Mapping between "Pseudo name" and "Logical device ID" in powerpath with SVM changed.... Reboot Emergency UNIX and Linux Support 1 11-17-2010 05:09 AM
Compare file names and select correct elements to include in "for each loop" cgkmal Shell Programming and Scripting 2 11-04-2010 04:38 PM
perl file, one line code include "length, rindex, substr", slow jimmy_y Shell Programming and Scripting 3 06-09-2010 09:44 AM



All times are GMT -4. The time now is 12:10 PM.