Linux: Delete user password command

I am a new Linux user. I would like to disable a password for an account. How do I delete user Password under Linux operating system using command line option?

All user passwords are stored in /etc/shadow file. The quick way to remove/delete a user password is pass --delete option to the passwd command. First, login in as a root user using sudo command/su command and type the following command:

Command to delete user password under Linux

Type the following command to delete a user password:
# passwd --delete username
# passwd -d username
$ sudo passwd -d sweta
Removing password for user sweta.
passwd: Success

Above command delete a user’s password (make it empty). This is a quick way to disable a password for an account. It will set the named account passwordless. User will not able to login. It is also a good idea to setup user shell to nologin to avoid security related problems:
# usermod -s /usr/sbin/nologin usernameFor example to delete password for user sweta, Type:# passwd -d sweta
# usermod -s /usr/sbin/nologin sweta


Use the following chage command/grep command (feel free to replace the username sweta with actual username):
# chage -l sweta
# grep sweta /etc/passwd
# grep sweta /etc/shadow

Sample session:

Fig.01: All commands in action

See also:

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts