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 : Perform Basic File Management
This exercise assumes you are working on CentOS Linux and that the system is booted.
Press CtrlAltF and log in as root.
Create a new user account by typing useradd user and press Enter. Youll learn more about creating user accounts in Chapter
Create a password for the new user account by typing passwd user and press Enter. At the first prompt for entering the new password, type in password and press Enter. At the second prompt to retype the password, type in password again.
Log out of the root account by typing logout and press Enter.
Login as user using the password from the earlier step.
Type in pwd and press Enter. You should see homeuser This is the user 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 homeuser 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, homeuser to see files listed there. It just so happens that your present working directory is also homeuser
Type in mkdir homeuserNewDir and press Enter. This will create a new subdirectory in homeuser 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 homeuserNewDir and press Enter. This will change your present working directory to the new subdirectory, homeuserNewDir 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 homeuserNewDir
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 homeuserNewDir to homeuser
Type pwd and press Enter. You should see that your present working directory is now homeuser
Type ls F homeuserNewDir and press Enter. You should see the MyFile file listed. Even though your present working directory is homeuser you can still see files in other directories using an absolute directory reference. In this step, you used an absolute directory reference, homeuserNewDir 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 homeuser this relative directory reference would not work.
Type mkdir Work and press Enter. This will create a new subdirectory homeuserWork 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 homeuserWork 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 homeuserWork 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 homeuser This is because you copied it Thus, a copy of the chores file was placed in the homeuserWork directory.
Type mv chores homeuserWorkchores and press Enter. This command will move the chores file to the homeuserWork directory and rename it to chores
Type ls and press Enter. You should no longer see that the original chores file in your homeuser This is because you moved it Thus, the original chores file is no longer located in the homeuser directory.
Type ls homeuserWork and press Enter. You should now see the files chores and chores in the subdirectory Work.
Type cd homeu can you write the commands
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
