0
0
Linux CLIscripting~20 mins

/etc/passwd and /etc/shadow in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Exploring /etc/passwd and /etc/shadow Files
📖 Scenario: You are a system administrator learning how to read user account information on a Linux system. The /etc/passwd file stores basic user info, and the /etc/shadow file stores secure password data.Understanding these files helps you manage users and security on your system.
🎯 Goal: Build simple commands to read and extract information from /etc/passwd and /etc/shadow files.
📋 What You'll Learn
Use cat to display file contents
Use cut to extract specific fields
Use grep to find lines matching a username
Understand the structure of /etc/passwd and /etc/shadow
💡 Why This Matters
🌍 Real World
System administrators often need to read and understand user account files to manage users and security on Linux systems.
💼 Career
Knowing how to read /etc/passwd and /etc/shadow is essential for Linux system administration and security auditing roles.
Progress0 / 4 steps
1
Display the contents of /etc/passwd
Use the command cat /etc/passwd to display the full contents of the /etc/passwd file.
Linux CLI
Need a hint?

The cat command shows the whole file content.

2
Extract the usernames from /etc/passwd
Use the command cut -d ':' -f 1 /etc/passwd to extract only the usernames (the first field) from the /etc/passwd file.
Linux CLI
Need a hint?

The cut command splits lines by ':' and selects the first part.

3
Find the line for the user root in /etc/shadow
Use the command grep '^root:' /etc/shadow to find the line starting with root: in the /etc/shadow file.
Linux CLI
Need a hint?

The grep command searches for lines starting with 'root:' in the file.

4
Display the username and encrypted password field from /etc/shadow
Use the command cut -d ':' -f 1,2 /etc/shadow to display only the username and encrypted password fields from the /etc/shadow file.
Linux CLI
Need a hint?

Use cut with fields 1 and 2 separated by a comma to get username and password.