deluser backup home remove group | usermod disable account

ubuntu@ubuntu:/home$ sudo deluser --remove-home --backup us1
Looking for files to backup/remove ...
Backing up files to be removed to . ...
backup_name = ./us1.tar
Removing files ...
Removing user `us1' ...
Warning: group `us1' has no more members.
Done.


ubuntu@ubuntu:/home$ ll
total 24
drwxr-xr-x  5 root   root   4096 Dec 11 07:13 ./
drwxr-xr-x 22 root   root   4096 Nov 27 10:23 ../
drwxr-xr-x  2 Elisa  Elisa  4096 Mar  3  2016 Elisa/
drwxr-xr-x  2 Jakob  Jakob  4096 Mar  6  2016 Jakob/
drwxr-xr-x 22 ubuntu ubuntu 4096 Dec  4 11:56 ubuntu/
-rw-------  1 root   root     46 Dec 11 07:13 us1.tar.bz2


$ deluser john guest # this will remove user john from group guest
$ deluser --group guest # this will remove a group
If you want to disable the user account rather than delete it, you can do it with the following commands:

ubuntu@ubuntu:~/Documents/testadmin$ usermod -e 1 us1
usermod: Permission denied.
usermod: cannot lock /etc/passwd; try again later.
ubuntu@ubuntu:~/Documents/testadmin$ sudo usermod -e 1 us1
ubuntu@ubuntu:~/Documents/testadmin$ su us1
Password: 
Your account has expired; please contact your system administrator
su: Authentication failure
ubuntu@ubuntu:~/Documents/testadmin$ 
$ sudo usermod --expiredate 1 john # disable the user account john
$ sudo usermod --expiredate "" john # re-enable user account john
$ sudo usermod -e YYYY-MM-DD john # specify expiry date

Comments

Popular posts from this blog

HAproxy logging

teamcity Automatic Agent Start under Linux

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all