A puzzle – how can a regular user change their password?

Let's say you're logged in as seawolf. For security reasons, you want to update your weak password (hello123, whoops!) to a strong secure one. We know that the password is stored in the /etc/passwd file. Well, we also saw that on modern Unixes (including Linux of course), for better security it's shadowed: it's actually stored in a file called /etc/shadow. Let's check it out:

$ ls -l /etc/shadow-rw-r----- 1 root shadow 891 Jun  1  2017 /etc/shadow$ 

(Remember that we're on an Ubuntu 17.10 x86_64 system; we often point this out, as the exact output might vary on different distributions, and if kernel security mechanisms, such as SELinux, are installed.)

As highlighted, you can see that ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.