I am attempting questions from a textbook to brush up on my linux skills.
The question is :
- Using /etc/passwd, extract the user and home directory fields for all users on your Kali machine for which the shell is set to /bin/false. Make sure you use a Bash one-liner to print the output to the screen. The output should look similar to Listing 53 below:
kali@kali:~$ YOUR COMMAND HERE...
The user mysql home directory is /nonexistent
The user Debian-snmp home directory is /var/lib/snmp
The user speech-dispatcher home directory is /var/run/speech-dispatcher
The user Debian-gdm home directory is /var/lib/gdm3
Listing 53 - Home directories for users with /bin/false shells
This is my current progress:
┌──(root💀kali)-[/home/kali]
└─# cat /etc/passwd | cut -f 1 -d ":" | grep -v '/bin/false' | awk '{print "The user " $0;}'
Output:
The user root
The user daemon
The user games
The user mail
I can't find a way to pipe/chain commands such that i can add "home directory" at the back to format my output. Can anyone help?