Go Back   The UNIX and Linux Forums > Operating Systems > HP-UX
Search Forums:



HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-07-2012
Registered User
 

Join Date: Feb 2012
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
owner Permission changed automatically

HI all,

We had created new user using the command useradd -d /home/selva -s /usr/local/bin/bash selva . But it didnt created the home directory on /home. So i manually created, copied skel files manually and changed the owner from root to selva. At the same time i observed that so many files copied from /etc to /home directory on the same time and some files owners are showing as selva.



Code:
Output of /etc/default/useradd
#default useradd options
HOMEDIR /home
GROUPID 20
INACT -1
EXPIRE
CHOWN_HOMEDIR no
CREAT_HOMEDIR no
START_PROGRAM /sbin/sh
SKEL_DIR /etc/skel
ALLOW_DUP_UIDS no
COMMENT


Code:
Output of selva id:
uid=109(selva) gid=20(users)


Code:
Group output of Users:
users::20:root

Fully I am confused...I have attached files which was created automatically in /home and see the owners and my history file.
Attached Thumbnails
owner-permission-changed-automatically-issue1.jpg   owner-permission-changed-automatically-issue2.jpg  

Last edited by methyl; 02-07-2012 at 09:10 AM.. Reason: please use code tags
Sponsored Links
    #2  
Old 02-07-2012
Registered User
 

Join Date: Feb 2012
Location: India
Posts: 102
Thanks: 9
Thanked 2 Times in 2 Posts
u missed -m argument

# useradd -d /home/selva -s /usr/local/bin/bash -m selva

--Shirish Shukla
Sponsored Links
    #3  
Old 02-07-2012
Registered User
 

Join Date: Feb 2012
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
For that only I did manually...but why should unwanted files copied from /etc/ to /home. and also owners of all users home directory changed to selva as owner. and some /usr/, /var/, /opt files also got changed...What will be the reason behind...?
    #4  
Old 02-07-2012
methyl methyl is offline Forum Staff  
Moderator
 

Join Date: Mar 2008
Posts: 5,646
Thanks: 203
Thanked 560 Times in 539 Posts
Quote:
So i manually created, copied skel files manually and changed the owner from root to selva. At the same time i observed that so many files copied from /etc to /home directory on the same time and some files owners are showing as selva.
We assume that you were logged in as "root" and typed one of more commands incorrectly which caused unexpected change to the system.

What did you actually type?
(If you have a .sh_history file , have a look at it with the "strings" command).

Ps. I can't read your ".jpg" attachments. Can you post in text?

Last edited by methyl; 02-07-2012 at 09:22 AM..
Sponsored Links
    #5  
Old 02-08-2012
Registered User
 

Join Date: Feb 2012
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
HI Shirish Shukla,

By missing -m, how the files will copy and file permission got changed.
Sponsored Links
    #6  
Old 02-08-2012
Registered User
 

Join Date: Feb 2012
Location: India
Posts: 102
Thanks: 9
Thanked 2 Times in 2 Posts
When u missed -m option then -d /homepath get updated in /etc/passwd file ... but dir /homepath will not get created that had happend at your case ... and you had created that dir after and copied that files from skel dir right ...

Better recreate the user ... with right parameters ...

--Shirish Shukla
Sponsored Links
    #7  
Old 02-08-2012
methyl methyl is offline Forum Staff  
Moderator
 

Join Date: Mar 2008
Posts: 5,646
Thanks: 203
Thanked 560 Times in 539 Posts
Finally managed to read the .jpg examples.

The issue is with these commands. I've posted them as comments
because we don't want people executing them.

Code:
# bad line 1 # vi /etc/passwd
# bad line 2 # cp -rf /etc/skel/.* /home/selva/
# bad line 3 # chmod -R selva:users /home/selva/.*
# bad line 4 # chown -R selva:users /home/selva/.*

1) NEVER use "vi" on /etc/passwd. If you are expert, use the "vipw" command, but in your case you probably just needed "view".

2) This command is terrifying. Try this to see what I mean:
ls /etc/skel/.*
Compared with:
ls /etc/skel/.??*

3) This command is a syntax error and didn't do anything.

4) This command is terrifying. Try this to see what I mean:
ls /home/selva/.*
Compared with:
ls /home/selva/.??*

The problem is your use of ".* " when you expected it to match filenames starting with a ". " . It actually expanded the the parent directory ". " in both occasions. Your problem was made so much worse by using recursive (-r/-R) and overwrite (-f) options to commands when there was no point in that context.
It should be possible to use the "ls" commands I posted above to determine which files were copied or changed in error. However because you used the "-f" switch to "cp" be careful about detecting files which were overwritten (if any).
It's such a mess that it may be quicker to go back to backup, but it depends on how many files you had in /home and whether all permissions are easy to fix.

The change of permissions of some files in /usr /var /opt will be because many of the original files in /etc are LINKS and having copied the lot to /home/selva your commands then issue a recursive "chown" on the copies. Scary. I'm surprised that this system is still running, but don't reboot the system without repairing all the permissions of system files.

QED.

Last edited by methyl; 02-08-2012 at 12:02 PM.. Reason: typos (lots)
Sponsored Links
Reply

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
/usr/bin has been changed with 777 permission bullz26 Solaris 5 09-03-2009 07:06 AM
automatically change owner and group borderblaster Shell Programming and Scripting 1 04-24-2009 07:11 AM
how I know owner of file and its permission through c program amitpansuria Programming 4 10-05-2008 04:19 AM
How to changed Permission on Tape real-chess Linux 6 09-09-2008 08:42 AM
permission, owner and group pascalbout Shell Programming and Scripting 2 01-14-2006 10:47 AM



All times are GMT -4. The time now is 11:26 PM.