0
0
Linux CLIscripting~10 mins

/etc/passwd and /etc/shadow in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to display the contents of the /etc/passwd file.

Linux CLI
cat [1]
Drag options to blanks, or click blank then click option'
A/etc/shadow
B/etc/hosts
C/etc/group
D/etc/passwd
Attempts:
3 left
💡 Hint
Common Mistakes
Using /etc/shadow instead of /etc/passwd, which requires root permission to view.
Trying to view /etc/group or /etc/hosts which are different files.
2fill in blank
medium

Complete the command to safely view the /etc/shadow file with root privileges.

Linux CLI
sudo [1] /etc/shadow
Drag options to blanks, or click blank then click option'
Atouch
Bls
Ccat
Decho
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ls' which lists files but does not show contents.
Using 'echo' which prints text but not file contents.
Using 'touch' which creates or updates files.
3fill in blank
hard

Fix the error in the command to list users from /etc/passwd by extracting the first field (username).

Linux CLI
cut -d: -f[1] /etc/passwd
Drag options to blanks, or click blank then click option'
A1
B3
C2
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing field 2 or 3 which contain other data like user ID or group ID.
Using wrong delimiter or field number.
4fill in blank
hard

Fill both blanks to create a command that counts the number of user accounts in /etc/passwd.

Linux CLI
cat /etc/passwd | [1] -d: -f1 | [2] -l
Drag options to blanks, or click blank then click option'
Acut
Bwc
Csort
Duniq
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sort' or 'uniq' instead of counting lines.
Not extracting the correct field before counting.
5fill in blank
hard

Fill both blanks to create a command that lists usernames from /etc/passwd who have a user ID greater than 1000.

Linux CLI
awk -F: '[1] $3 [2] 1000  print $1' /etc/passwd
Drag options to blanks, or click blank then click option'
A($3
B>
C)
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting parentheses causing syntax errors.
Using '<' instead of '>' which filters wrong users.
Not printing the first field ($1) which is the username.