Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How linux users change their password without root privilege?

I've been noticed that normal users can change their own passwords without sudo. But as far as i know, to change password has to write the /etc/shadow file which is accessible only by root.

How does that happen??

like image 723
Chen Avatar asked Oct 27 '13 16:10

Chen


People also ask

Can a normal user change password in Linux?

The easiest way to do that is to log in as a root or sudo user, as you can use the passwd [username] command to change the user password easily. Remember that non-root sudo users will have to use the sudo passwd command instead. Plus, they will have to enter their passwords to proceed with the command.

How a non-root user can change his own password when he does not have write permission to the ETC shadow?

How a non-root user can change his own password when he does not have write permission to the /etc/shadow? The effect is that a passwd process adopts the identity of the owner, in this case root. This is how it can modify the shadow file.

How do you log in as root if you do not have root password?

sudo instead of su - . sudo ("super user do") is a command that lets you run other commands as root temporarily. This is the best way for most users to run root commands, as the root environment is not maintained, and the user doesn't need to know the root password.

What if I forgot root password in Linux?

Enter the following: mount -o remount rw /sysroot and then hit ENTER. Now type chroot /sysroot and hit enter. This will change you into the sysroot (/) directory, and make that your path for executing commands. Now you can simply change the password for root using the passwd command.


1 Answers

The passwd program in installed setuid root:

$ ls -l `which passwd`
-rwsr-xr-x 1 root root 41284 Sep 12  2012 /usr/bin/passwd

Note the s in the fourth position. This is a flag that can be set in the file permissions that tells Linux to assume the privileges of the user that owns the executable when it is run - in this case, root.

like image 90
pobrelkey Avatar answered Sep 21 '22 21:09

pobrelkey