Verify user shell in /etc/passwd
In the previous step, you used echo $SHELL
to see the shell you are currently using. This is the shell that was launched for your current terminal session. However, the system also keeps a record of each user's default login shell in a configuration file.
This configuration file is /etc/passwd
. It contains information about all the users on the system. Each line in /etc/passwd
represents a user account and is divided into fields separated by colons (:
). The last field on each line specifies the user's default login shell.
To view the contents of /etc/passwd
, you can use the cat
command. Since we are only interested in the line for the labex
user, we can combine cat
with the grep
command to filter the output. grep
is a powerful tool for searching text patterns in files.
Type the following command in your terminal and press Enter:
cat /etc/passwd | grep labex
Let's break down this command:
cat /etc/passwd
: This command reads the content of the /etc/passwd
file and prints it to the standard output.
|
: This is a pipe. It takes the output of the command on the left (cat /etc/passwd
) and sends it as input to the command on the right (grep labex
).
grep labex
: This command searches the input it receives for lines containing the string "labex" and prints those lines.
You should see a single line of output similar to this:
labex:x:5000:5000:LabEx user,,,:/home/labex:/usr/bin/zsh
This line contains several pieces of information about the labex
user, separated by colons. The fields are (in order):
- Username (
labex
)
- Password (represented by
x
, the actual password hash is stored elsewhere for security)
- User ID (UID) (
5000
)
- Group ID (GID) (
5000
)
- User information (GECOS field) (
LabEx user,,,
)
- Home directory (
/home/labex
)
- Default login shell (
/usr/bin/zsh
)
The last field, /usr/bin/zsh
, confirms that the default login shell for the labex
user is indeed zsh
, matching what you saw with echo $SHELL
.
Click Continue to move on.