Lab Linux
Lab Linux
1
Linux exercises
Answer the following questions:
1. Write the command(s) to create a directory in your home directory called mydir
2. Write the command(s) to change to the mydir directory
3. Write the command(s) to create two files called myfile1 and myfile2 in mydir
4. Write the command(s) to return to your home directory and show the directory tree
5. Write the command(s) to delete myfile1 and myfile2.
6. Write the command(s) to delete the mydir directory
4
Linux exercises (with your raspberry)
5
Linux exercises (with your raspberry)
1. Write the command to create a directory sub1 and create a directory sub2 in sub1.
Do this with one command
2. Write the command(s) to go to sub2 and create a file called myfile1
3. Write the command(s) to make a recursively copy of the whole sub1 directory by the
name of tree1
4. Now, you have two directory trees, named sub1 and tree1. Write the command(s) to
Move the directory tree tree1 into the sub1 subdirectory
5. Write the command(s) to list the contents of your home directory. Make a
recursively listing of all the files
6
Linux exercises (with your raspberry)
1. Create a “vi_test” file using VI in your home directory
2. Fill this file with the first 15 words of the alphabet. Add a word.
• a alpha
• b beta
• c charlie
• ….
3. Replace the all the “space characters” by “_”
4. Save your file
Describe every step (command) that you use in all the process. For instance,
the steps for creation, saving, replacing, etc.
7
Linux exercises (with your raspberry)
Create user accounts:
8
Linux exercises (with your raspberry)
4. Switch to VT1, where you are logged as user1, and look at the
permission on your home directory
5. Switch to VT2, where you are logged as user2, and try to change to the
home directory of user1, or read the contents of the home directory of
user1, does this work?
• If the last command fail. Switch to VT1 and change the permission on the home
directory of user1 so that other users are allowed to read and access it. Then try
to access to directory again as user2. Does this work?
6. As user2, try to create and delete files in user1 home directory, does this
work?
9
Linux exercises (with your raspberry)
7. Switch to VT1. Create a “bin” directory and copy the file /bin/ls in there.
Rename it to “my_ls” in the process
8. Logout and login again in VT1 as user1
9. Set the permission on “my_ls” to rw-r-----, then try to execute it. Execute
it as user1 and user2. Does it work? Why not?
10. Now set the permission on “my_ls” to rwxr-xr-x, then try to execute one
more time, both as user1 and user2. Does it work?
11. Try to execute “my_ls” as user1 and user2, with permissions: rw-------;
rw-rw----; rwx------; rwx--x---; rwx--x --x. What permissions are
required for user1 and for user2?
10