Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Three linux problems Below is a two-column report showing the number (first colu

ID: 3850085 • Letter: T

Question

Three linux problems

Below is a two-column report showing the number (first column) of each different group-id (second column) from the /etc/passwd file. Use a pipe of cut/sort/uniq to re-create this output. Some man page perusing may be required!

$

From your home directory, use egrep/cut/sort to produce a list showing the username and real name of all the students in the /etc/passwd file; the list should be lexicographically sorted by username. Copy/paste just your command for hand-in.

3.

Rewrite it to make it as UN-complex as possible while still working! Hint: The solution uses just 3 characters with special meaning whereas the above solution uses ~13 (depending on how you count them!)

Explanation / Answer

# Problem 2
# ====
echo "Problem 2"
echo "===="
# Script for showing usernames:realnames
cat /etc/passwd |
egrep -i '.*?/bin/bash$' |
cut -d : -f 1,5 |
sort |
cut -d , -f 1


# Problem 3
# ====
echo "Problem 3"
echo "===="
# This should suffice since only the comment field can contain a character
# like 'v' at start and that too the realname is the one right next to ':'
# .I don't know about the other conditions but in /etc/passwd this will
# work.
egrep -i "w:v" /etc/passwd


# Problem 1
# ====
echo "Problem 1"
echo "===="
cut -d : -f 4 /etc/passwd |
sort -n |
uniq -c

I cannot show you any output since that will reveal integrity of my linux pc. I have tested the code, works just fine.

Cheer,

PH

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote