Question: UNIX PROGRAMMING Problem 8 (18 points): Answer the following questions regarding managing files and directories: a) What does the command rm -r /trashbin/ accomplish? b)

UNIX PROGRAMMING

Problem 8 (18 points): Answer the following questions regarding managing files and directories:

a) What does the command rm -r /trashbin/ accomplish?

b) What command flag can you use with cp so that it doesnt accidentally overwrite a file if it already exists (hint: look up the man page for cp)?

c) What command exists to delete a directory if and only if it is already empty?

d) Which command can be used to rename a file or directory?

e) Give the needed commands to accomplish the following scenario (use only 1 command for each one, and assume that each command affects the commands that follow it):

- Change to the directory /usr/share/

- Create two new directories called oldcode and newcode inside of this directory

- While still inside of /usr/share, create two new files, one called main.java inside of the newcode directory and another called calculate.py inside of the oldcode directory (use relative path/file names instead of absolute path/file names)

- While still inside of /usr/share, rename the calculate.py file inside of the oldcode directory to calculate.backup (use an absolute path/file name instead of a relative path/file name)

- Change to the directory newcode

- Set the permissions of the main.java file (using symbolic notation) so that the group has read and write permissions, but no execute permission

- Make a copy of the main.java file to the oldcode directory called main.save (use relative path/file names)

- Change to the parent directory /usr/share/ using .. notation

- Delete all of the files inside of the oldcode directory, including the oldcode directory itself

- Inside of your current directory, remove the empty directory tempcode (assume it exists and contains no files)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!