You are on page 1of 2

Linux lab

problem Sheet #1 Linux basics-1


Objective: To learn basic Linux commands- file creation,paths,subdirectory, move,copy,delete,access rights.
Refer manual (man command )for more details about commands covered here)
(Be careful -commands are case sensitive)
1. Create following text file (cat > file1)
this a text file create using cat.
Display it content using cat
good by
(press Ctrl+D)
1b. Display contents of file1 (cat)
2. Create following another text file (cat > file2)
linux lab experiments
the basic commands of linux
now I shall work in linux
(press Ctrl+D)
2b. Display contents of file2 (cat)
3. Display contents of present directory (ls)
4. Display all contents of present directory (ls -a)
5. Display all contents of present directory in long format (ls -al)
6. Execute following commands (one after another)
ls -A ; ls -R ; ls -r ; ls -d ; ls -i; ls -F ; ls -X
7. Print present working directory path (pwd)
8. Move two level up using relative path (cd)
9. Back to user's home directory (UHD) using ~ (tilde) (or cd space and enter)
10. Repeat step 8 with absolute path
11. Back to user's home directory using relative path
12. Display all contents of root in long format (without leaving UHD)
13. Create four level nested directory structure eldr11/eldr12/eldr13/eldr14 in your UHD.
(first create eldr11 , move to this level. Now create next lower level. so on )
(mkdir ,pwd and cd ) (run commands four times)
14. Repeat 9 (currently you are in eldr14 folder)
Follow the given instructions WITHOUT CHANGING current working directory ( presently you are in UHD )
15. Create four level nested directory structure fldr11/fldr12/fldr13/fldr14 in your UHD using relative path of each nested depth
(run commands four times, without changing PWD. only changing parameters)
(mkdir)
16. Repeat 14 for directory structure gldr11/gldr12/gldr13/gldr14 in your UHD using single command (mkdir -p )
17. Show the directory structure of your UHD (tree)
18. Show the directory structure of root (tree path) (use Ctrl+C to stop scrolling screen)
18. Show the directory structure of fldr12 (tree)
19. Copy file1 from UHD to eldr14 by same name (cp) use relative path
20. Copy file1 from UHD to gldr12 by different name(file9) (cp)
21. Repeat 20 for gldr13 ,gldr14,fldr14 (destination names file8,file7,file6 respectively)
22. Copy directory gldr12 to fldr14 (cp -r)
23. Copy all contents(only files) of gldr12 to current directory (cp source-path/* .)
24. Remove all contents of gldr12 (not to remove gldr12 itself) (rm -r)
25. Make copy of file2 as file21 ( cp)
26. Rename filef21 as file3 (mv)
27. Move all contents of fldr14 to gldr12 (not fldr14 itself) (mv)
28. Move file6 to UHD by same name
28b. Copy fldr12 to gldr13
29. Move to fldr12 directory (NOW fldr12 becomes current working directory)
30. Copy all contents of gldr12 to current directory (cp)
31. Copy all contents of gldr12 to fldr14 directory (cp)

32. Move to UHD (NOW UHD becomes current working directory)


33. Remove fldr13 (rmdir) (IS there ERROR message?)
34. Remove fldr14 (rm -r)
34b. Remove fldr13 (rmdir)
35. Show the directory structure of your UHD (tree)
36. Move to gldr13 directory (NOW gldr13 becomes current working directory)
37. Change access right of file8 as only readable (chmod)
38. Append a sentence to file8 (cat >>)(IS there ERROR message?)
39. Change access right of file8 as only writable
40. Display contents of file8 (cat)(IS there ERROR message?)
40b. Append a sentence to file8 (cat >>)
41. Concatenate file3 , file8, file6 to file4 (cat)
42. Append file1 to file4(cat)
43. Make hard link of file4 by name file4h in eldr12(ln original new) (cp -l also creates hard link)
44. Make soft link of file4 by name file4s in gldr14(ln -s) (cp -s also creates soft link)
45. Append a sentence to file4 (cat >>)
46. Display contents of file4h and file4s without changing directory (cat)
47. Rename file4h to file4hr (mv)
48. Make hard link of file4 by name file4hh in current directory(ln)
49. Append a sentence to file4s (cat >>)
50. Display contents of file4hr , file4hh and file4 without changing directory (cat)
51. Remove file4
52. List directory structure of UHD
53. Display contents of file4hr , file4hh and file4s without changing directory (cat)
54. Make hard link of gldr13 in UHD as lkg11 (IS there ERROR message?)
54b. Make soft link of gldr13 in UHD as lkg11
55. Display contents of lkf11
56. Copy eldr12 to fldr14
57. Move to UHD (NOW UHD becomes current working directory)
58. Show the directory structure of your UHD (tree)
59. Move to lkg11 and remove file7 (file in nested somewhere in directory )
59b. Remove symbolic link of file4s (as original file4 does not exist)
Ensure following -There are three 4-level nested sub directories in your UHD eldr11/eldr12/eldr11/eldr12/;
fldr11/fldr12/fldr11/fldr12/; gldr11/gldr12/gldr11/gldr12/; each level has a file file[subdirectoryfirstname][levelnumber]for example- filee1,filee2,fileg3,filef4
(UHD is current working directory)
(use chmod -c for more information of action of chmod. verify access right using ls -l, cat etc to read/write or create file/folder)
60. Change access mode of fldr3 to rw (owner and others)only,display the contents of fldr3 (chmod accessright target)
61. Change access mode of eldr4 to r (owner and others)only,display the contents of eldr4
62. Change access mode of eldr3 to w (owner and others)only,display the contents of eldr3
63. Change access mode of eldr2 to rx (owner and others)only,display the contents of eldr2
64. Change access mode of eldr2 to wx (owner and others)only,display the contents of eldr2
64b. Change access mode of eldr2 (ALL -nested)to rwx (owner) and rx (group and others)only
65. Change access mode of filef1 to w (owner and others)only,display it
66. Change access mode of filef2 to r (owner and others)only,concatenate a word in it and display it
67. Change access mode of your UHD to ---(owner) (from within, using relative path), display directory
68. Change access mode of your UHD to rx(owner) (from within), display directory
69. Change access mode of your UHD to rw(owner) (from within), display directory
70. Change access mode of your UHD to wx(owner) (from within), display directory
71. Change access right of your UHD to default (rwx)
72. Open your UHD to your friend by changing access right for others
73. Check the UHD of others you can access (note down access right)
74. Request your friend to browse your sub directories and files (as per right set by you in 61-67)
75. Let your friend to create/delete/link to one of your directory/file into his/her UHD
76. Let your friend to create/delete/link/append/modify a file/directory (so linked in 75) into his/her UHD
(repeat 74-76 on your friend's UHD)

You might also like