top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Explain the fields in /etc/passwd and /etc/shadow ?

+4 votes
460 views
Explain the fields in /etc/passwd and /etc/shadow ?
posted Jul 2, 2015 by Mohammed Hussain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

The /etc/shadow file stores actual password in encrypted format with some additional properties related to user password.It mainly holds athe account aging parameters. All fields are separated by a colon (:) symbol. It contains one entry per line for each user listed in /etc/passwd file Generally, shadow file entry looks as below.

steve:$1$XOdE07rn$WA6qFm4W5UIqNfaqE5Uub.:13775:0:99999:7:::

Here is the explanation of each field.

User name : Your login name

Password: Your encrypted password.

Last password change : Days since Jan 1, 1970 that password was last changed

Minimum: The minimum number of days required between password changes.

Maximum: The maximum number of days the password is valid.

Warn : The number of days before password is to expire that user is warned that his/her password must be changed

Inactive : The number of days after password expires that account is disabled

Expire : days since Jan 1, 1970 that account is disabled. It indicates an absolute date specifying when the login may no longer be used

The /etc/passwd file stores essential information, which is required during login /etc/passwd is a text file, that contains a list of user account related parameters like user ID, group ID, home directory, shell, etc.

Here is the sample entry from /etc/passwd file

steve:x:6902:6902::/home/steve:/bin/bash

Username: User's login name.

Password: An x character indicates that encrypted password is stored in /etc/shadow file.

User ID (UID): Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for root.

Group ID (GID): The primary group ID

User Info: The comment field. It allow you to add extra information about the user.

Home directory: The absolute path to the directory the user will be in when they log in.

Command/shell: The absolute path of a command or shell (/bin/bash).

answer Jul 6, 2015 by Manikandan J
Similar Questions
+1 vote

I am running below script on sles 11 and getting different output.

#!/bin/bash
PID=$(/bin/ps aux | grep sro-rest | grep -v grep | awk '{print $2}')
echo "PID = $PID"
. /etc/rc.status
PID=$(/bin/ps aux | grep sro-rest | grep -v grep | awk '{print $2}')
echo "PID = $PID"

Output:

PID = 2453
PID =

After debugging, I get to know that once we run . /etc/rc.status then output of ps aux is getting short.
See below script for example,

#!/bin/bash
echo "Before ==================================> "
/bin/ps aux | grep java | grep -v grep
. /etc/rc.status
echo "After ==================================> "
/bin/ps aux | grep java | grep -v grep

Output :

Before ==================================>
root      2453  4.9  7.8 8496196 615020 ?      Sl   Jun05  60:31 /usr/java/jre1.8.0_77//bin/java -Djava.net.preferIPv4Stack=true -Djava.library.path=/opt/sro/lib -Dserver.port=50000 -Dspring.profiles.active=gal -jar /opt/sro/ui/lib/sro-rest-SNAPSHOT.jar
After ==================================>
root      2453  4.9  7.8 8496196 615020 ?      Sl   Jun05  60:31 /usr/java/jre1.8.0_77//bin/java -Djava.net.preferIPv4Stack=true -Djava.l

Can anyone explain why different behavior for the same command?

0 votes

I am a python script which tries to create a file under directory /etc/ but I am getting the error as

IOError: [Errno 13] Permission denied: '/etc/file'

Any Idea how to create a file in /etc as non-root user?

...