Question: anaging Files, Directories, and Text Exercise 1 : Perform Basic File Management This exercise assumes you are working on CentOS Linux and that the system

anaging Files, Directories, and Text
Exercise 1: Perform Basic File Management
This exercise assumes you are working on CentOS Linux and that the system is booted.
Press Ctrl+Alt+F2 and log in as root.
Create a new user account by typing useradd user1 and press Enter. Youll learn more about creating user accounts in Chapter 7.
Create a password for the new user account by typing passwd user1 and press Enter. At the first prompt for entering the new password, type in pass1_1word and press Enter. At the second prompt to retype the password, type in pass1_1word again.
Log out of the root account by typing logout and press Enter.
Login as user1 using the password from the earlier step.
Type in pwd and press Enter. You should see /home/user1. This is the user1 home directory. Remember the pwd command shows you the present working directory of your user.
Type ls -F and press Enter. You should see files listed with a forward slash (/) at the end of their file name. The / symbol at the end of a file name indicates the file is actually a subdirectory. This / symbol designation is only shown when you use the F option on the ls command.
Type in ls -F /home/user1 and press Enter. You should see the same files listed as in the earlier step. In the earlier step, you looked at the files in your present working directory. In this step, you used an absolute directory reference, /home/user1, to see files listed there. It just so happens that your present working directory is also /home/user1.
Type in mkdir /home/user1/NewDir and press Enter. This will create a new subdirectory in /home/user1 called NewDir. You are using an absolute directory reference with the mkdir command to create the new subdirectory.
Type ls -F and press Enter. You should see the new subdirectory you just created called NewDir.
Type cd /home/user1/NewDir and press Enter. This will change your present working directory to the new subdirectory, /home/user1/NewDir. Notice that you used an absolute directory reference with the cd command.
Type ls -F and press Enter. You should not see any files in this new subdirectory you just created called NewDir. You will just get a prompt again.
Type touch MyFile and press Enter. The touch command creates an empty file. In this case, you just created a blank empty file called MyFile.
Type ls -F and press Enter. You should now see the file you just created, called MyFile, in the new subdirectory /home/user1/NewDir.
Type cd .. and press Enter. Yes, that is two periods (or dots) after the cd command! Dont leave them off. This will move your present working directory from /home/user1/NewDir to /home/user1.
Type pwd and press Enter. You should see that your present working directory is now /home/user1.
Type ls -F /home/user1/NewDir and press Enter. You should see the MyFile file listed. Even though your present working directory is /home/user1 you can still see files in other directories using an absolute directory reference. In this step, you used an absolute directory reference, /home/user1/NewDir, to see files listed there.
Type ls -F NewDir and press Enter. You should see the MyFile file listed. Now you are using a relative directory reference NewDir to see files listed there. If your present working directory was not /home/user1, this relative directory reference would not work.
Type mkdir Work and press Enter. This will create a new subdirectory /home/user1/Work. You used a relative directory reference to create it.
Type touch chores and press Enter. This will create an empty file in your pwd called chores.
Type ls -F and press Enter. You should see the both new subdirectory you just created called Work and the empty file called chores.
Type cp chores /home/user1/Work and press Enter. This will copy the file chores into the subdirectory you just created Work. If the Work subdirectory was not created before you typed in the cp command, you would have created another empty file called Work.
Type ls /home/user1/Work and press Enter. You should now see the file chores in the subdirectory Work.
Type ls Work and press Enter. This should also show you the file chores you copied to the subdirectory Work. You used a relative address with the ls command this time.
Type ls and press Enter. You should see that the original chores file is still in your /home/user1. This is because you copied it. Thus, a copy of the chores file was placed in the /home/user1/Work directory.
Type mv chores /home/user1/Work/chores2 and press Enter. This command will move the chores file to the /home/user1/Work directory and rename it to chores2.
Type ls and press Enter. You should no longer see that the original chores file in your /home/user1. This is because you moved it. Thus, the original chores file is no longer located in the /home/user1 directory.
Type ls /home/user1/Work and press Enter. You should now see the files chores and chores2 in the subdirectory Work.
Type cd /home/u can you write the commands

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 Programming Questions!