You are on page 1of 10

Laboratory

Via Moodle submit a PDF file (one by team)


• For the execution commands, use print screens or take a photo

Deadline: Monday 08 midnight, 2023

1
Linux exercises
Answer the following questions:

1. What is the pwd command?


2. What is a superuser?
3. What is PID?
4. What is GUI?
5. What is Shell?
6. Explain the function of the cat command
7. Explain differences between relative path and absolute path
8. Explain how you can create a folder using Terminal?
9. Explain the following command: vmstat
10. Describe the root account 2
Linux exercises

11. How do you can change your password?


12. How do you display the system's date?
13. How do you display the calendar for the current year?
14. How do you display the month and the year of your birthday?
15. How do you generate a list of all users present on your system?
16. How do you display your login name?
17. How do you print the text "I love Linux" on your display?
18. How do you make sure you can receive messages?
19. How do you write the message "Hi boss" to the display of root?
20. How do you show the history commands of the last 20 commands?
3
Linux exercises (with your raspberry)

Working with directories:

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)

Working with files:

1. Write the command(s) to look at the contents of the /etc/passwd


2. Write the command(s) to copy the /etc/passwd file to your home directory, and
rename it to usersfile

5
Linux exercises (with your raspberry)

Working with files and directories recursively:

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:

1. On tty3, log in as root


2. Execute the following commands:
• # groupadd aguilas
• # useradd –m –g aguilas user1
• # useradd –m –g aguilas user2
• # passwd user1
• New password: aguila1
• Retype new password: aguila1
• # passwd user2
• New password: aguila2
• Retype new password: aguila2
3. On tty1, log in as user1, and on tty2, log in as user2

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

You might also like