Problem 8 (18 points): Answer the following questions regarding managing files and directories:
a) What command would remove the directory /trashbin and all of the files and subdirectories inside of it?
b) What command flag can you use with cp so that it doesn’t accidentally overwrite a file if it already exists?
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? For each of the following, give the necessary command. Pay attention to which types of filenames (absolute or relative) or permissions notation (symbolic or numeric) are specified. Use only one (1) command for each, and assume that each command affects the commands that follow it.
e) Change to the directory /usr/share/
f) Create two new directories called “oldcode” and “newcode” inside of this directory
g) 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.
h) While still inside of /usr/share, rename the “calculate.py” file inside of the “oldcode” directory to “calculate.backup” using an absolute path/filename.
i) Change to the directory “newcode”
j) Set the permissions of the “main.java” file (using symbolic notation) so that the group has read and write permissions, but no execute permission
k) Using relative path/file names, make a copy of the “main.java” file to the “oldcode” directory called “main.save”.
l) Change to the parent directory /usr/share/ using ‘..’ notation.
m) Delete all of the files inside of the “oldcode” directory, including the “oldcode” directory itself.
n) Inside of your current directory, remove the empty directory “tempcode” (assume it exists and contains no files).
Unfortunately due to Chegg rules I can answer only your first 4 subquestions. Do check them out.
a) rm -r directory/trashbin
Here rm is short for remove, -r is used to recursively
remove the files inside the directory(which can be non-empty)
We can use -rf also which will suppress warning messages, but it is
dangerous and risky.
b) cp -n myoldfile.txt mycopiedfile.txt
cp is short for copy, for n:
-n, --no-clobber
do not overwrite an existing file
c) rmdir directoryName
rmdir is used to remove a directory only if it is empty. Now you know why we couldn't use this in part (a)
d) mv /home/user/oldname /home/user/newname
mv renames your old file or folder to the new name
If you find this answer helpful then do upvote it to help others as well.
Problem 8 (18 points): Answer the following questions regarding managing files and directories: a) What command...
do numbers 4-8
4. Given any directory, use the Is command to display: • all files and sub-directories starting with the letter "D" (note do not list anything in any sub-directory) • its immediate sub-directories (sub-directories only, and no other ordinary files) its immediate hidden sub-directories only - take a screenshot (#3-3) that clearly shows the command and the result. 5. Assume that the following files are in the working directory: $ ls intro notesb ref2 section 1 section3 section4b...
Q.5] Answer the following questions based on the company database (based on the homework assignment 2) y database (based on the homework assignment 2) 3 IPage 1. For each department whose average employee salary is more than $30,000, write a SQL statement to retrieve the department name and the number of employees working for that department 2. Write a SQL statement to retrieve first name, last name, and address of each employee who lives in Houston, TX. 3. Write a...