Add a user with no password

I want to add a user like below in Linux. Please assist

Below is the information from /etc/passwd file

---------- Post updated at 02:04 PM ---------- Previous update was at 10:05 AM ----------

Not sure why there is X in shadow file

This is not, what a shadow file looks like. If you look closer, you will see, that both lines are identical and they are from the passwd file. A shadow file entry looks like this:

test:$6$rW7KQGB/$ir3tl2gier.4PuoNtoQAecl/FtXBCF87bGsJJ4uAoWhFhpko3ae4hKlIZDFjrhPigdl.vX4uh1DXSTReGI.Wz0:15628:0:99999:7:::

No i am sure the entry is same on both /etc/passwd and /etc/shadow files.

---------- Post updated at 02:38 PM ---------- Previous update was at 02:35 PM ----------

Btw if i want to run a script with user "test" and there should be a home directory created for the user, how should i create the account?

when i issued below command, so looks like it is passworded, but thwn i look it in /etc/passwd and /etc/shadow files there is X as mentioned above.

To create a user, use the useradd -command. To create a home directory at the same time, use the -m option.

Thank you for the reply, but how can we set the user account to "x" in shadow file? or what do we mean by "X" in shadow file

---------- Post updated at 03:57 PM ---------- Previous update was at 02:46 PM ----------

Sorry below is what i have in the /etc/shadow file

The x in the passwd file means, that the password hash is stored in the shadow file.

In the shadow file, it means, that there is no valid password set. So the user is not locked, but can not log in.

To set a password for the user, use

passwd username

as root to set a password for the user.

If that's how your shadow file looks, then you're in trouble. Stuff like group membership and login shell are what gets stored in /etc/passwd. The fields in /etc/shadow should all be related to password policy and password hashes. I'm willing to bet they both came from /etc/passwd otherwise your system would be in total failure and that would probably take

It's probably better to focus on _why_ you're interested in getting rid of passwords. If it's to get scripted access to this account from a remote system, you can set up passwordless ssh. If it's for scripted access to the account locally, use sudo.

If it's just to keep from having to enter your password at the login prompt you may ask whether this is really something you want to do and if so just blanking out the hash field will get you out of entering a password on most systems.

For example, where you have:

testuser:!!:15668:0:99999:7:::

or

testuser:$6$4IMQBefy$J3rmoxs9b/aErid5ihr2N4PDLtPRRpQHATaUmSaazohR1K0vvZClhX.5aueEq6nOCRYkjBruYEMVaEKqofbwO1:15668:0:99999:7:::

Should become:

testuser::15668:0:99999:7:::

I've only tested this on logging into the desktop and from a TTY. Logging in remotely can be taken care of the other way (via ssh) though.