Skip to content

admins 24×7

Everything works!

  • Practice
  • Theory
  • Tips & tricks
  • Uncategorized
  • Utilities
  • About

HowTo Disable a User Account in Linux

Published on March 11, 2015 Author admin

linux

How to disable a user account in Linux

How to disable a user account in Linux? How to completely disable a user account Linux server?

The best practise is to use usermod command. This does not effect password and you can revert changes and enable user again.

Syntax:

Shell
1
2
$ usermod -L -e 1 {user}
$ usermod -L -e 1970-01-01 {user}

Example:
In this example, local disable a user account for user1 and kick user from console:

Shell
1
$ sudo usermod --expiredate 1 user1 && sudo /usr/bin/pkill -u user1

If user1 was connected to the server, he will see in console:

Shell
1
2
3
4
5
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Mar 10 10:17:08 2015 from user1
user1@laptop:~$ Connection to somehost closed by remote host.
Connection to somehost closed.

If user1 will try to connect again, he will see:

Shell
1
2
3
user1@laptop ~ $ ssh somehost
Your account has expired; please contact your system administrator
Connection closed by 10.0.0.20

To enable user again:

Shell
1
$ sudo usermod --expiredate 99999 user1

Categories Practice, Tips & tricksTags cli, command line, Linux, login, ssh

Post navigation

Previous Previous post: GeoIP log analysis with bash
Next Next post: FreeBSD htop

Recent Posts

  • CloudFlare domain management tool
  • How to generate LA?
  • Private Docker Registry
  • MongoDB performance best practices
  • Redis replication and availability

Recent Comments

    Archives

    • February 2017
    • November 2016
    • August 2016
    • March 2016
    • February 2016
    • November 2015
    • October 2015
    • July 2015
    • March 2015
    • December 2014
    • November 2014
    • August 2014
    • July 2014
    • April 2014
    • March 2014
    • January 2014
    • December 2013
    • October 2013

    Tags

    3306 apt-get badblocks bads bash CentOS CPU crontab dd Debian e2fsprogs FreeBSD HDD HighLoad htop Java la Linux Load average master-slave monitoring my.cnf Mysql nginx Percona percona-toolkit Percona toolkits Percona tools performance practice pt-query-digest ramdisk replication shell ssh sysutils tcpdump theory tmpfs top Ubuntu Unix w yum Zabbix

    © admins 24×7. Powered by WordPress & Krusze Theme.