pwunconv Command in Linux



The pwunconv command in Linux converts the /etc/passwd file from shadow password format back to a standard format. The standard format for the /etc/passwd file refers to the format where user account information, including the password hash, is stored directly in the /etc/passwd file. This is in contrast to the shadow password format, where the password hashes are stored separately in the /etc/shadow file for better security.

The pwunconv command essentially disables shadow passwords by merging the contents of /etc/shadow into /etc/passwd.

Table of Contents

Here is a comprehensive guide to the options available with the pwunconv command −

Syntax of pwunconv Command

The syntax of the Linux pwunconv command is as follows −

pwunconv

The pwunconv command does not require additional arguments. It is designed to perform a single task without the need for customization.

Important Considerations Before Using pwunconv Command

Shadow passwords improve security by storing password hashes in /etc/shadow, which is only accessible by privileged users. Using the pwunconv reduces security, as /etc/passwd is world-readable.

Before using pwunconv, always create backups of /etc/passwd and /etc/shadow to avoid accidental data loss.

To create the backups, use the following commands −

sudo cp /etc/passwd /etc/passwd.bak
sudo cp /etc/shadow /etc/shadow.bak

Note − To re-enable shadow passwords after running pwunconv, the pwconv command can be used.

Example of pwunconv Command in Linux

The pwunconv command is generally used for debugging or specific system configurations, but it is not recommended for regular systems due to security implications.

The execution of the pwunconv command requires sudo privileges −

sudo pwunconv
pwunconv Command in Linux1

The above command places the password hash directly in the /etc/passwd file. For verification, access the /etc/passwd file −

cat /etc/passwd
pwunconv Command in Linux2

The output shows the hash of the user’s password.

Warning: Avoid leaving the system in the non-shadowed state, as it exposes password hashes in /etc/passwd, creating a significant security risk.

Reenabling the Shadow Password Format

To re-enable the shadow password format, use the pwconv command −

sudo pwconv

This command also does not produce any output. For verification, view the /etc/passwd file.

Now, the hash will be replaced with x as shown in the output image below −

pwunconv Command in Linux3

Conclusion

The pwunconv command in Linux converts the /etc/passwd file from the shadow password format back to the standard format by merging password hashes from /etc/shadow into /etc/passwd. This reduces security, as /etc/passwd becomes world-readable.

It is primarily used for debugging or specific configurations and requires caution, including creating backups of both files before execution. Re-enabling the shadow password format can be done using the pwconv command to restore better security practices.

In this tutorial, we covered the pwunconv command, its syntax, important considerations, and usage in Linux with examples.

Advertisements