Post date: Oct 24, 2017 6:50:10 AM
Lab #2: Unix Commands Cheat Sheet and Practice Exercises
Exercises
1. Make a directory called assign1 under your home directory.
2. Change to this directory.
3. Make three empty files: file1 file2 and file3.
4. Change back to your home directory.
5. Store the list of all the directories (long listing) in a file called dirfile.
6. Display the contents of dirfile on the screen.
7. Display on the screen the current time in the format hh:mm:ss. (Hint:- man date )
8. Copy /home/nandkumar/file.txt as CP_FILE.txt under the directory assign1.
9. Make assign1 as your current directory.
10. Execute a sequence of commands so that file2 contains the first five lines and the last ten lines of CP_FILE.txt. (you can use more than one command for this task).
11. Count the number of times the word program appears in CP_FILE.txt. (Hint: -o option)
12. Change access privileges of file2 such that none except you can modify it but every user (including you) can read and execute it.
13. Print only the total number of lines of CP_FILE.txt and file2.
14. Print the current file structure of your home directory.
15. Open file3 using vi editor and add the following line of text to it: This is file3!
16. Save and exit editing file3.
17. Append the contents of file2 to file3.
18. Open file3 using vi editor again, and insert the following line after the first line: (25 stars)
*************************
19. Insert such a line after the last line of file3, just by using vi commands (that is, do not type out the line again).
20. Save the modified file into another file named file4.
21. Now, count the number of characters in file4, without exiting vi editor.
Exit vi editor, so that none of these changes you made is re