Comprehensive Questions (80 Pts) Use the file tree below for comprehensive quest
ID: 3739887 • 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
Unix operating system has a shell prompt available. The directory structure is given in the question. Danny is working in Hw1 directory. The various commands he can use in unix shell include:
PART 1
pwd
This command list the present working directory of the user. For Danny, the system will respond with /root/home/Danny/Hw1.
But he wishes to see the contents of /root/home/Chris/UNIXS18/HW/Hw1/allfiles. So, he should give the following command in the shell
ls –l /root/home/Chris/UNIXS18/HW/Hw1/allfiles
ls command lists the contents of the directory mentioned. The –l option request for ‘long format', which contains lots of useful information, e.g. the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified. Thus using ls command Danny will be able to see the contents of Chris Directory without leaving his current directory.
PART 2
To check the access privileges of file Part1.txt, Danny should type.
ls –l /root/home/Chris/UNIXS18/HW/Hw1/allfiles/Part1.txt
The access permission of files includes read permission(r), write permission (w) and execute permission(x). Further, the permission can be given separately for Owner, Group and Others.
To change the access privileges to ensure that file can be read, Danny can give chmod command to add the read permission. That is
chmod +r /root/home/Chris/UNIXS18/HW/Hw1/allfiles/Part1.txt
Then Danny can use cp command to copy the file to his directory. That is
cp /root/home/Chris/UNIXS18/HW/Hw1/allfiles/Part1.txt .
PART 3
To store all files with word hello into a file names list, one should give following command.
cat *hello* >list
Here, cat is a command which outputs the contents of the files. *hello* is the regular expression which list all the filenames with word hello. And >list send the output of the command to the file list.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.