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

Comprehensive Questions (80 Pts) Use the file tree below for comprehensive quest

ID: 3739917 • Letter: C

Question

Comprehensive Questions (80 Pts) Use the file tree below for comprehensive questions 1-3 Kevin, Chris, and Danny share a single UNIX account. Each user has their own directory located in the home directory. Each user has various directories and files located in their own directory. (10 Pts) Suppose Danny is working in his Hw1 directory and realizes he hasn't started his homework. Without leaving his Hw1 directory, Danny wants to check ("Look') into Chris's allfile directory to see if has completed Part1 of the homework. How would Danny do this? 1) 2) (30 Pts) Danny wants to copy Part1.txt from Chris's allfile directory. Danny must change the access privileges of Part1.txt to copy the file. How would Danny check the access privileges of Part1.txt, change the access privileges of Part1.txt and copy the file all without leaving his Hw1 directory. (10 Pts + 6 Pts) Assume you are in Chris's Lab 1 directory. In one command line, devise a method to store all the files with the word hello in the name into a file named list. Extra Credit: Demonstrate 2 different ways to complete this task. 3)

Explanation / Answer

1)

Danny has to execute ls command for allfile directory :

ls -la /home/Chris/UNIX18/HW/Hw1/allfiles

This command will list all the files with basic details(-l) including hidden files coz of option -a which are:

Part1.txt

Part2.txt

Part1

2)

Executing above command which has -l will also include access privileges along with the listing where one can check permissions associated with Part1.txt

To be able to copy this file Danny has to have execute(x) permission on allfiles/Part1.txt

Update access privileges:

chmod 777 /home/Chris/UNIX18/HW/Hw1/allfiles OR

chmod 777 /home/Chris/UNIX18/HW/Hw1/allfiles/*

Here 777 gives all r/w/x permissions.

To copy the file execute:

cp        /home/Chris/UNIX18/HW/Hw1/allfiles/Part1.txt .

3)

find . -type f -name "hello" | tee list.txt

This command will search in current directory(.) for all the files(-type f, not directories) containing pattern "hello" and redirect output of find command to list.txt

***NOTE: This searches only for "hello" and not "Hello","HELLO",etc

Other possible options:

find . -type f -name "hello" > tee list.txt

grep -nr "hello" . > tee list.txt

find . -type f -print | xargs grep "hello" : This will search for all the entries in current directory which are of type file(filenames) and then grep those filenames which contains "hello.

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