How to list user in Linux box, add an user to a group!
I have found for time but i still don' know how to list the user in my linux box, also how can I add an exist user to a group!
|
To list the users:
cat /etc/passwd | cut -d":" -f1 Hmm, not sure about how to add an existing user to a group though. |
Depending on distro and desktop, you probably have several gui's to choose from.
Search the menu, or systems control-center (if any), or kde's controlcenter. Or do it the manual way: List users: # cat /etc/passwd Add user to a group: edit /etc/group Syntax is: cdrom:x:22:peterh,charles The user of course has to exist or you'll have problems... Command-line tools: useradd and groupadd |
Re: How to list user in Linux box, add an user to a group!
Quote:
thank you, but this print all user includes system user (samba,apache ...) Pingu, I am running Radhat box and I have not X installed, is there other way? |
See if this helps.
|
Re: How to list user in Linux box, add an user to a group!
Quote:
See the manpage. |
well I see many answered to the listing users,but not so clear answers to adding an existing user to a group (no offense); you can do this by using the "gpasswd -a user group" command.
I know my answer is only a few years late but for googling people it might be nice :) |
As long as the thread got drug up...
Quote:
Quote:
|
Listing Groups
For those following along at home, listing groups can be accomplished in the same way as users:
Code:
cat /etc/group | cut -d":" -f1 |
Quote:
Code:
awk -F: '$3 > 1000 {print $1}' /etc/passwd | xargs -I USERNAME sudo usermod -a -G sftponly USERNAME |
Quote:
usermod: invalid option -- 'a' I tried another option and it works. Since I cannot get any manual/manpage/help about it, you may try it by using non-important user_name first: usermod -A Group1 user_name , which adds an existing user 'user_name' to an existing group 'Group1' without changing the group list the user belongs to. |
Bash script to display the detailed user information in Linux
A very useful bash script to display the detailed user information in Linux
<moderated> |
Quote:
in SuSE linux, there is No -a (this article states that the '-a' retains existing groups and 'adds' new group '-G'), but in openSuSE 12.2, there is no '-a' option to usermod, it keeps existing groups by default, i guess... Code:
# id lunar |
All times are GMT -5. The time now is 04:24 AM. |