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

Linux / Unix: Please help as much as you can. Thanks. (1) For the following comm

ID: 3854364 • Letter: L

Question

Linux / Unix: Please help as much as you can. Thanks.

(1) For the following command explain the following:

$ cp /tmp/abc /tmp/cbs .

a. How can the command fail. List two reasons
b. (unrelated to a.) What would happen if /tmp/abc is a directory?

(2)

a. How does "ls -l" and "ls -ltr" differ ?

b. Write a command to create a symlink to $HOME/homework in /tmp
          Explain what will happen after the operation, if the link file is removed.
          Explain what will happen if $HOME/homework is removed.

(3) mv $HOME/project /tmp

explain.

(a) What happens if $HOME/project is a directory?

(b) for (a) how can cmd fail? if project already exists and is not owned by you.
if project exists in /tmp and is owned by you but is a regular file
          # student verify

(4)

For the following command explain the following

          $ cp /tmp/abc /tmp/cbs .

a. How can the command fail. List two reasons
b. (unrelated to a.) What would happen if /tmp/abc is a directory?

Explanation / Answer

1.a) Below are 2 reasons:
The source and target paths does not exist.
If the user does not have proper read/write/execute access to the source and target paths.

b.If tmp/abc is a directory then all the valid files having proper read/write/execute access from tmp/abc will be copied to tmp/cbs.

2.a)

ls -l : -l will show the entries as a long list along with various attributes.

Example:
$ ls -l
total 16
drwxrwxr-x 2 raj raj 4096 Jul 6 13:35 data
-rw-rw-r-- 1 raj raj 88 Jul 6 13:50 filenames.txt
ls -ltr :

-t option will sort the entries by modification date (with newest first)
-r will reverse the sorting order.
As -t will sort by modification time with newest first, -r will cause the reverse i.e. oldest entries will be shown first now.

Example (Adding a file and a directory to make it clearer) :
$ ls -lt
total 16
drwxrwxr-x 2 raj raj 4096 Jul 6 13:50 log
-rw-rw-r-- 1 raj raj 88 Jul 6 13:50 filenames.txt
-rw-rw-r-- 1 raj raj 208 Jul 6 13:49 move.sh
drwxrwxr-x 2 raj raj 4096 Jul 6 13:35 data

$ ls -ltr
total 16
drwxrwxr-x 2 raj raj 4096 Jul 6 13:35 data
-rw-rw-r-- 1 raj raj 208 Jul 6 13:49 move.sh
-rw-rw-r-- 1 raj raj 88 Jul 6 13:50 filenames.txt
drwxrwxr-x 2 raj raj 4096 Jul 6 13:50 log


b)

command to create a symlink to $HOME/homework in /tmp:

ln -s $HOME/homework /tmp

Explain what will happen after the operation, if the link file is removed.
Ans) If the link is removed , it will not reference the file anymore.

Explain what will happen if $HOME/homework is removed.
Ans) If $HOME/homework is removed the link will still remain as links remain if the original file is deleted.

3. mv $HOME/project /tmp

$HOME/project file will be moved to /tmp directory.

3.a)If $HOME/project is a directory it will get moved under /tmp directory.
b)To execute the command we need read access at source $HOME/project and write access to target if project already exist. If not command will fail.

Also if project exists in /tmp and is owned by current user but is a regular file , command will fail because directory is also considered to be type of file in unix. No two files can have same name under same path.

4.a) Below are 2 reasons:
The source and target paths does not exist.
If the user does not have proper read/write/execute access to the source and target paths.

b.If tmp/abc is a directory then all the valid files having proper read/write/execute access from tmp/abc will be copied to tmp/cbs.

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