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

So, here is my question: I want to search for all the pathnames that start with

ID: 3891495 • Letter: S

Question

So, here is my question: I want to search for all the pathnames that start with /etc/apt for the string apt. I also want to include all the subdirectories.

Second questioin is what does the does "string " means in this sentence.

I have used these two commands:

find /etc/apt

find . | grep apt

find /etc/apt . | grep apt

Thrid question I have:

I want to list all the filenname that start with "/etc/apt " and atleast have one occurance of string "apt"

Currently i am using this command : "find /etc/apt apt -maxdepth 1"

I don't this it is right.

4th question I have is : What is is right command to find line number of the searched term. example. I want to search for "max" in this file "/etc/group"

This is what I am using currently "grep -nr max /etc/group"

5. How can I list all the accounts in /etc/passwd file that do NOT use bash shell?

This is the commnad I am using " awk -F/ '$NF != "nologin" ' /etc/passwd "  

But won't list non bash users.

6. How to check the total number of accounts that do NOT use bash shell in this file /etc/passwd.

I have no Idea.

7. Give a command that displays the percentage of space being used in, and
the filesystem type of, the filesystem mounted at /home.

Explanation / Answer

Q.2) What I can Understand from given sentence is that "/etc/apt" and its subdirectories might have files and we need to search those files for string/word "apt".

Q.1)  grep -rlnw '/etc/apt/' -e 'apt'

Q.3) This is same as Q.1.

Q.4)  grep -Hn "max" /etc/group

Q.5) I think we need to also indicate that bash should not be last variable indicated by NF variable:

awk -F/ '$NF != "nologin" && $NF != "bash" ' /etc/passwd

This will list all accounts except non-login and bash ones.

Q.6) Just Count the number of line of the above output.

awk -F/ '$NF != "nologin" && $NF != "bash" ' /etc/passwd | wc -l

Q.7) We can use df command here:

df /home

I have tried to answer whatever I could conclude from given info(Which is a little ambiguous). If you face any problem I am available in the comments.

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