A command to list all users? And how to add, delete, modify users?
____________________________________________________________________________
I need a command to
list all users in terminal. And how to add, delete, modify users from
terminal.
That could help in
administrating your accounts easily by terminal.
|
||||
Answers:
Just press Ctrl+Alt+T on your keyboard
to open Terminal. When it opens, run the command(s) below:
cat /etc/passwd
OR
less /etc/passwd
more /etc/passwd
You can also use
awk:
awk -F':' '{ print $1}'
/etc/passwd
|
||||
To get a list of
all users you type (as users are listed in /etc/passwd)
getent passwd
To add a user newuser
to the system you would type
sudo adduser newuser
to create a user
that has all default settings applied.
Bonus: To add any
user (for instance anyuser) to a group (for instance cdrom)
type
sudo adduser anyuser
cdrom
You delete a user
(for instance obsolete) with
sudo deluser obsolete
If you want to
delete his home directory/mails as well you type
sudo deluser
--remove-home obsolete
And
sudo deluser
--remove-all-files obsolete
will remove the
user and all files owned by this user on the whole system.
|
||||
user (tab tab)
gives me as
possible options useradd userdel usermod users users-admin
if you want to know more about a command google it or type man man useradd gives useradd - create a new user or update default new user information ... ...
to list users you
should go with what Mitch said.
Hope that helps I
love tab completion in bash saves me from remembering things.
|
|||||
--------------------------------------------------------------------------------------------------------
|
|||||
list of all users who
can login (no system users like: bin,deamon,mail,sys, etc.)
awk -F':' '$2 ~
"\$" {print $1}' /etc/shadow
add new user
sudo adduser
new_username
or
sudo useradd
new_username
delete/remove username
sudo userdel username
If you want to
delete the home directory (default the directory /home/username)
sudo deluser
--remove-home username
or
sudo rm -r
/path/to/user_home_dir
If you want to
delete all files from the system from this user (not only is the home
diretory)
sudo deluser
--remove-all-files
|
|||||
0 comments:
Post a Comment