Question: Project: cp,mv and rm Commands (NOTE: PLEASE INCLUDE ALL TASK)! Assignment Objectives: On completing this lab, you should be able to: Demonstrate copying files with

Project: cp,mv and rm Commands (NOTE: PLEASE INCLUDE ALL TASK)!

Assignment Objectives:

On completing this lab, you should be able to:

  • Demonstrate copying files with the cp command.
  • Demonstrate moving files with the mv command.
  • Demonstrate removing files with the rm command.

Part 1

Instructions:

Demonstrate using the cp command by completing the tasks below. You will also be required to complete tasks previously covered in prior sections and in class. Perform the task on your vSphere virtual machine. Provide the requested answer or screenshot as indicated in the task.

Task

Task 1

Read the handout in Virtual Lab folder in Canvas for this class to access your virtual machine. Log in to the sysadmin account with the password netlab123 and open the terminal program.

Task 2

In the terminal window, verify that you are in sysadmins home directory. If not, change directory to it.

Task 3

Use the touch command to create the sample1, sample2 and sample3 files (if not already created).

Task 4

Create a new directory named mysamples. What command did you use?

Your answer below:

Task 5

The copy command needs both a source file (or directory) to copy and a destination, which can be the current directory (.) and/or a new filename. Execute the following: cp sample1 sample1A , then use the ls command to verify that you successfully created a copy.

Task 6

Copy the sample1 file again, but this time copy it to the mysamples child directory and name it sample1B, using a relative path: cp sample1 mysamples/sample1B .

Task 7

Copy the sample1 file a third time, but copy it to the mysamples directory without changing the filename: cp sample1 mysamples/ .

Task 8

Copy the file sample1B in your mysamples directory to your home directory. This can be done a few ways, either, cp mysamples/sample1B /home/$USER or cp mysamples/sample1B ~ .

Task 9

You can copy more than one file at a time. For instance, cp sample1 myfile sample3 mysamples, copies three files in the current directory to the child directory. The last argument on the cp command line is considered the destination.

NOTE: Because sample1 already exists in the mysamples directory, you may get the following message: Overwrite mysamples/sample1? Choose y and press Enter.

You will not get the warning message if your Ubuntu version is not actually running cp -i. The -i option is for interactive so the cp command stops and asks you first before overwriting a file. On some systems, both cp and mv are aliased as cp -i and mv -i. Type alias and see if this is so on your system.

Task 10

Copy the /etc/hosts file to your home directory. Provide the command you would use below.

Your answer below:

Task 11

Copy your sample1 to the /tmp directory. Provide the command you would use below.

Your answer below:

Task 12

Navigate to the /usr/local bin directory (cd /usr/local/bin). Copy the /etc/passwd file to your home directory. Provide the command you would use below.

Your answer below:

Task 13

Navigate back to your home directory. Copy all the files that end in .txt in your users home directory to /tmp directory. Provide the commands you would use below.

Your answer below:

Task 14

Copy the /var/log/messages and the /etc/resolv.conf and the /proc/cpuinfo file to the /tmp directory. Provide the command you would use below.

Your answer below:

Part 2

Task 15

Make sure you are in your home directory. Verify that you have the following files in your home directory: sample1, sample1A, sample1B, sample2 and sample3. If not, then create any missing files with the touch command.

Task 16

The mv command can be used to rename files. For example type the following command to find the inode number of the sample1B file, ls -i sample1B . The inode number is like a location number for the file on the hard drive. Make not of the inode number for this file.

Task 17

Use the mv command (move or rename) the sample1B file to sample4: mv sample1B sample4 . Display the inode number for the renamed file sample4 (ls -i sample4). If the inode number is different from Task 16 then the file moved, however if the inode number is the same then the file never moved location on the hard drive, just known by a different name. Is the inode number the same or different? Explain.

Your answer below:

Task 18

Move the sample4 file into the mysamples child directory using a relative path: mv sample4 mysamples .

Again, the file sample4 did not actually move anywhere on the hard drive, only the reference to it changed in the file system. The user doesnt care where on the hard drive the file is, they only care that they can find the file in the file system. so, It is still stored in the same place on the harddisk. Its inode still did not changed (ls -i mysamples/sample4)

Task 19

Move the sample4 file back to sysadmins home directory, using a relative path. Provide the command used to complete this task.

Your answer below:

Task 20

You can move a file to another directory and rename it at the same time: mv sample4 mysamples/test4 .

Task 21

You can move more than one file at a time using a wildcard: mv sample? mysamples .

This will move sample1, sample2, and sample3, but not sample1A because the ? wildcard metacharacter matches any one character in its position only, which is the 7th position. The A is in the 8th position.

Task 22

Move the sample1,sample2 and sample3 back to your home directory. Provide the command you used below.

Your answer below:

Task 23

To move all the sample files at one time, you need to use the * wildcard, which matches zero or more characters in its position onward: mv sample* mysamples .

Task 24

Use the touch command to create files picA.jpg, picB.jpg and picC.jpg.

Task 25

Move all pic files created in Task 24 to /tmp in one command. Provide the command you used below.

Your screenshot below:

Task 26

Use the touch command to create files justin.mp3 bieber.mp3 rocks.mp3 in the Music directory in your home. From your home directory move the newly created mp3 files to your current location (your home). Provide the command you used below.

Your answer below:

Task 27

Rename the file justin.mp3 to selena.mp3 and the file bieber.mp3 to gomez.mp3 and the file rocks.mp3 to forever.mp3. Provide the commands you used below.

Your answer below:

Task 28

To delete (remove) files, use the rm command. To remove the forever.mp3 file, type the command, rm forever.mp3 .

Task 29

Remove the selena.mp3 and gomez.mp3 files. Provide the command you used below.

Your answer below:

Task 30

Remove the cpuinfo file in the /tmp directory from task 14. Provide the command you used below.

Your answer below:

Part 3

Instructions:

Answer the following questions about this lab.

Task 31

Describe your experience with this lab. Did you experience any challenges during this lab? If so, what were the challenges and how did you overcome them? Explain why or why not. What did you like and dislike about this lab?

Your answer below:

Task 32

Did this lab help you better understand how to use the cp, mv and rm command? Explain.

Your answer below:

When Completed

  1. Save this document with your answers.
  2. Submit this completed document in the assignment Dropbox.

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!