2009年11月30日 星期一

Linux Command - useradd/userdel/groupadd/groupdel

// Add a user, create his/her home directory, make he/she in the specified group
# useradd -m -G groupname newUsername

// Delete the specified user and the data of his/her home directory
# userdel -r userName

// Add the specified group, and make it as a system group (usually group id lower than 500, often 470 by default)
# groupadd -r groupName
# cat /etc/group | grep groupName
groupName:x:470:

# modify userABC as a mail/ftp user without login ability
/usr/sbin/usermod -s /sbin/nologin userABC
userABC:x:508:508::/home/userABC:/sbin/nologin

The command to change the permission flags is "chmod". Only the owner of a file can change its permissions.

The command to change the group of a file is "chgrp". Only the owner of a file can change its group, and can only change it to a group of which he is a member

So we need to set the user into multiple groups if we wish the user is a member of the specified group.

沒有留言: