User and Group

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

 

Who connected to the server

w

Create new user

RHEL - RedHat, CentOS, Oracle Linux

useradd -g oinstall -G dba,oper,asmadmin,asmdba,asmoper oracle
/usr/sbin/useradd -u 503 -g oinstall -G asmadmin,asmdba,asmoper,dba grid

FTP user (don't allow connect through ssh)

useradd -G ftpgroup newuser -s /sbin/nologin -d /FTP/newuser
passwd newuser

FreeBSD, ftp user (don't allow connect through ssh)

pw adduser newuser -d /FTP/newuser -g 717 -s/bin/sh
passwd newuser

Set password

passwd grid

Change user settings

usermod -aG oinstall -G dba,oper,asmadmin,asmdba,asmoper oracle

FreeDSB:  pw usermod username -aG wheel,operator,operator,mail

Check current settings

id oracle

cat /etc/passwd
cat /etc/passwd | grep oracle                    !! - means that user locked

cat /etc/shadow

Groups

groupadd asmadmin

Ask to change password at next logon

expire

Show account aging information

change -l oracle Last password change, expires, days between change

Password expire

change -E 2016-05-31 oracle                  on date
passwd -x 90 oracle                                 after 90 days

Disable (lock) user

passwd -l username

Enable (unlock) user

passwd -u username

Remove or drop user

tar -zcvf /nas/backup/account/deleted/v/vivek.$uid.$now.tar.gz /home/vivek/ - replace $uid, $now with actual UID and date/time
 # pgrep -u baduser
 # ps -fp $(pgrep -u baduser)
 # killall -KILL -u baduser
 userdel -r vivek
  /usr/sbin/userdel baduser
  userdel -r baduser  - also removes home folder
 # find /var/spool/at/ -name "[^.]*" -type f -user baduser -delete  - del. at jobs
 # crontab -r -u baduser
 # lprm baduser  - del. print jobs
 # find / -user baduser -print  - find all files owned by user vivek
 # find / -user baduser -exec chown newUserName:newGroupName {} \;  - find file owned by a user called vivek and change its ownership as follows

Second root, sudo

useradd -ou 0 -g 0 newuser
passwd newuser

visudo
newuser ALL=(ALL) ALL
newuser ALL=(ALL) NOPASSWD: ALL

To switch root user use
[newuser@server ~]$ sudo su -

vi /etc/pam.d/su
auth            sufficient      pam_rootok.so add these rows after, if you need su - from newuser user w/o passwd
auth       [success=ignore default=1] pam_succeed_if.so user = root
auth       sufficient   pam_succeed_if.so use_uid user = newuser

id newuser                         check new settings
grep newuser /etc/passwd

FreeDSB:  adduser
FreeDSB:  vi /usr/local/etc/sudoers 
newuser ALL=(ALL) ALL

Resset root passwd, Boot CD

Boot from Linux CD
Troubleshooting
Rescue a Red Hat Enterprise Linux System

chroot /mnt/sysimage

passwd root
rm -f /.autorelabel

Samba

Show users and their settings
pdbedit -L -v

Reset user password
smbpasswd username

Newsletter

Enter your email to join our mailing list

Quick Contact