Sponsored Content
Homework and Emergencies Emergency UNIX and Linux Support Accidentally Changed File Ownership to Include a "Comment" [AIX] Post 302711069 by Scott on Friday 5th of October 2012 11:06:20 AM
Old 10-05-2012
OK, the longer version Smilie

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.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl file, one line code include "length, rindex, substr", slow

Hi Everyone, # cat a.txt a;b;c;64O a;b;c;d;ee;f # cat a.pl #!/usr/bin/perl use strict; use warnings; my $tmp3 = ",,a,,b,,c,,d,,e,,f,,"; open(my $FA, "a.txt") or die "$!"; while(<$FA>) { chomp; my @tmp=split(/\;/, $_); if ( ($tmp =~ m/^(64O)/i) || ($tmp... (3 Replies)
Discussion started by: jimmy_y
3 Replies

2. Shell Programming and Scripting

Compare file names and select correct elements to include in "for each loop"

Hi everyone, I`ll try to be most clear I can explaining my help request. I have 2 folders Folder A-->This folder receives files through FTP constantly Folder B-->The files from Folder A are unzipped and then processed in Folder B Sometimes Folder A doesn`t contain all... (2 Replies)
Discussion started by: cgkmal
2 Replies

3. Emergency UNIX and Linux Support

Mapping between "Pseudo name" and "Logical device ID" in powerpath with SVM changed....

Dear All, I was having powerpath 5.2 on SUN server with SVM connected to CLARIION box.Please find the following output : root # powermt display dev=all Pseudo name=emcpower3a CLARiiON ID=CK200073400372 Logical device ID=60060160685D1E004DD97FB647BFDC11 state=alive; policy=CLAROpt;... (1 Reply)
Discussion started by: Reboot
1 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Script to echo "File permissions or ownership changed from required " when accidentally changed.

Hi All, I have to work in the late nights some times for server maintenance and in a hurry to complete I am accidentally changing ownership or permission of directories :( which have similar names ( /var in root and var of some other directory ).:confused: Can some one suggest me with the... (1 Reply)
Discussion started by: shiek.kaleem
1 Replies

6. Red Hat

Accidentally changed ownership-unable to SSH into server.

Hi All, Accidentally changed ownership of /var directory as root :eek: thinking that I am changing ownership of var directory in other location in the file system:D.Now unable to SSH into the server:(. By gods grace I was able to regain the access again as server was in control of me at that... (5 Replies)
Discussion started by: shiek.kaleem
5 Replies

7. AIX

"Accidentally" destroyed my filesystem

I was trying to delete and recreate a filesystem, thinking it would be a quick way of deleting all of the files off of it, and I fear that I messed up. Here is the original entry from /etc/filesystems: data01: dev = /dev/fslv00 vfs = jfs2 log ... (5 Replies)
Discussion started by: bstring
5 Replies

8. AIX

How to enable "TCP MD5 Signatures" and "https" on AIX?

I have searched many times but nothing found. Somebody help please :(:(:( (1 Reply)
Discussion started by: bobochacha29
1 Replies

9. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

10. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
RMUSER(8)						    BSD System Manager's Manual 						 RMUSER(8)

NAME
rmuser -- remove users from the system SYNOPSIS
rmuser [-yv] [-f file] [username ...] DESCRIPTION
The rmuser utility removes one or more users submitted on the command line or from a file. In removing a user from the system, this utility: 1. Removes the user's crontab(1) entry (if any). 2. Removes any at(1) jobs belonging to the user. 3. Sends a SIGKILL signal to all processes owned by the user. 4. Removes the user from the system's local password file. 5. Removes the user's home directory (if it is owned by the user), including handling of symbolic links in the path to the actual home directory. 6. Removes the incoming mail and POP daemon mail files belonging to the user from /var/mail. 7. Removes all files owned by the user from /tmp, /var/tmp, and /var/tmp/vi.recover. 8. Removes the username from all groups to which it belongs in /etc/group. (If a group becomes empty and the group name is the same as the username, the group is removed; this complements adduser(8)'s per-user unique groups.) 9. Removes all message queues, shared memory segments and semaphores owned by the user. The rmuser utility refuses to remove users whose UID is 0 (typically root), since certain actions (namely, killing all the user's processes, and perhaps removing the user's home directory) would cause damage to a running system. If it is necessary to remove a user whose UID is 0, see vipw(8) for information on directly editing the password file. If rmuser was not invoked with the -y option, it will show the selected user's password file entry and ask for confirmation that the user be removed. It will then ask for confirmation to delete the user's home directory. If the answer is in the affirmative, the home directory and any files and subdirectories under it will be deleted only if they are owned by the user. See pw(8) for more details. As rmuser operates, it informs the user regarding the current activity. If any errors occur, they are posted to standard error and, if it is possible for rmuser to continue, it will. The options are as follows: -f file The rmuser utility will get a list of users to be removed from file, which will contain one user per line. Anything following a hash mark ('#'), including the hash mark itself, is considered a comment and will not be processed. If the file is owned by anyone other than a user with UID 0, or is writable by anyone other than the owner, rmuser will refuse to continue. -y Implicitly answer ``yes'' to any and all prompts. Currently, this includes prompts on whether to remove the specified user and whether to remove the home directory. This option requires that either the -f option be used, or one or more user names be given as command line arguments. -v Enable verbose mode. Normally, the output includes one line per removed user; however, with this option rmuser will be much more chatty about the steps taken. username Identifies one or more users to be removed; if not present, rmuser interactively asks for one or more users to be removed. FILES
/etc/master.passwd /etc/passwd /etc/group /etc/spwd.db /etc/pwd.db SEE ALSO
at(1), chpass(1), crontab(1), finger(1), passwd(1), group(5), passwd(5), adduser(8), pw(8), pwd_mkdb(8), vipw(8) HISTORY
The rmuser utility appeared in FreeBSD 2.2. BUGS
The rmuser utility does not comprehensively search the file system for all files owned by the removed user and remove them; to do so on a system of any size is prohibitively slow and I/O intensive. It is also unable to remove symbolic links that were created by the user in /tmp or /var/tmp, as symbolic links on 4.4BSD file systems do not contain information as to who created them. Also, there may be other files cre- ated in /var/mail other than /var/mail/username and /var/mail/.pop.username that are not owned by the removed user but should be removed. The rmuser utility has no knowledge of YP/NIS, and it operates only on the local password file. BSD
May 10, 2002 BSD
All times are GMT -4. The time now is 08:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy