Skip to main content

Password commands in Ubuntu

/etc/passwd file

 In Ubuntu each user is assigned to user id and password. You can find out details of users in the file /etc/passwd.

So let us display its content

cat /etc/passwd

This file stores user names, their uids, their home directories. Historically this file used to save encrypted password. Now it does not - just an x to indicate whether user has a password.

Now you are relieved. Now you know that your passwords are not visible in this file. (In fact /etc/shadow stores passwords in encrypted form)

Protecting your files

Can we prevent other users from seeing your files?

Of course. You know that there are 3 sets of permissions for each file and directory. If we remove read(and write) permission of a directory for "others" then other users can not open that directory.

So you remove read permission to your home directory by others. 

chmod o-rwx /home/yourusername

This command removes read write and execute permissions to others for your home directory.

Root privileges

Some adiministrative commands require you to have root privileges. Traditionally Linux systems have used su command for this purpose. But Ubuntu uses sudo.

su command asks for root password and starts a root shell for you. You can run multiple commands as a root user until you give "exit".

But sudo lets you run a single command as root. And instead of prompting for root password, the system prompts for your own password for authentication.  That way you need not know multiple passwords. 

But to run a Sudo command you must be in sudoer list.

You have seen the use of sudo many times before. 

Su for changing user

su can also be used to switch user. 

su uh

lets us run commands as user "uh" after authenticating password of "uh". 

Advanced :

Password aging : You can use chage command to set password validity period so that user is forced to change password frequently. At the end of validity period user is prompted to change password.

syntax
chage username 


Note: the command is chage- not change.



Comments