- Managing Linux Users and Groups
- Managing File Ownership and Permissions
- Lab Exercise 3.1: Managing Linux Security
- Managing the Linux Networking Configuration
- Managing Linux Applications and Services
- Lab Exercise 3.2: Installing Linux Products and Managing Processes
- Implementing and Configuring NTP
- Lab Exercise 3.3: Implementing NTP
- Summary
Lab Exercise 3.1: Managing Linux Security
In this exercise, you will work with Linux users, groups, ownership, and permissions. Complete the following steps:
-
Boot your Linux server and authenticate as your student user with a password of novell.
-
Open a terminal session.
-
Change to the root user account by entering su and providing a password of novell.
-
Create a new text file by completing the following:
-
At the shell prompt, enter cd /tmp.
-
Create a new text file called example.txt by entering vim ./example.txt at the shell prompt.
-
Press Ins.
-
For the contents of the file, enter This is a text file.
-
Press Esc and then enter :exit.
-
Check the properties of example.txt by entering ls l example.txt at the shell prompt.
Who owns the example.txt file? What group is it assigned to?
If you completed these steps correctly, root should be the owner of example.txt and the root group should be assigned to the file.
What permissions have been automatically assigned to example.txt?
Owner should be assigned Read and Write permissions. Group should be assigned the Read permission. Other should be assigned the Read permission.
Test the permissions by completing the following:
-
At the shell prompt, enter exit.
-
At the shell prompt, enter cd /tmp.
-
Select Applications, KDE Menu, Editors, KWrite.
-
Select File, Open.
-
Browse to and select /tmp/example.txt and then click OK.
-
Add a line after the first line that reads "This is the second line."
-
Select File, Save.
Were you able to save the file? Why or why not?
You should see a warning indicating that you don't have the Write permission. Recall that you are now authenticated as the student user. This user isn't the file owner and isn't a member of the root group. That makes the permissions assigned to Other applicable. Other was assigned only Read permissions.
Continue with these steps:
-
In the warning dialog, click OK.
-
Select File > Quit.
-
When prompted to save changes, select No.
Change the permissions assigned to example.txt by completing the following:
-
In your terminal session, enter su and supply a password of novell.
-
Enter cd /tmp.
-
Remove the Read permission from Others by entering chmod 640 ./example.txt at the shell prompt.
-
Verify the permissions assigned to example.txt by entering ls l example.txt. It should have -rw-r----- permissions assigned to it.
-
Enter exit at the shell prompt.
Now try to access example.txt as the student user:
-
Select Applications, KDE Menu, Editors, KWrite.
-
Select File, Open.
-
Browse to and select /tmp/example.txt and then click OK.
Can you see the contents of example.txt? Why or why not?
If you assigned permissions correctly, you should not be able to see the contents of the file. As the student user, you have no permissions to the file.
Create a restricted folder by completing the following steps:
-
In your terminal session, enter su and provide a password of novell.
-
At the session prompt, enter cd /tmp.
-
Create a directory named HideMe by entering mkdir HideMe at the session prompt.
-
Make the HideMe directory restricted from anyone but root or the root group by entering chmod 640 ./HideMe.
-
Enter exit.
Try to access the HideMe directory as the student user by completing the following steps:
-
At the session prompt, enter cd /tmp.
-
Generate a listing of the contents of /tmp by entering ls |more.
Do you see the HideMe directory displayed?
You should be able to view the directory.
Now try changing to the HideMe directory by entering cd /tmp/HideMe.
Were you able to change to the HideMe directory? Why or why not?
You should receive a message indicating that you don't have the appropriate permissions to access the directory.
Execute a script file by completing the following steps:
-
Change back to the root user account by entering su and entering a password of novell.
-
Change to the /tmp directory by entering cd /tmp.
-
At the shell prompt, enter ls scriptfile.txt.
-
You should see the scriptfile.txt file you created in the previous chapter. This file contains a series of commands that can be executed from within the file. If you skipped that exercise, go back now and create the text file according to the lab instructions.
-
Verify that scriptfile.txt contains the correct commands by entering cat ./scriptfile.txt. You should see the commands you entered in the previous exercise.
-
Try to execute the file by entering ./scriptfile.txt.
What happens? Why?
You should see a message indicating that permission to run the file is denied. This happens because the Execute permission has not been granted.
Continue by following these steps:
-
Grant the Execute permission to all users by entering chmod 777 ./scriptfile.txt at the shell prompt.
-
Execute the script by entering ./scriptfile.txt.
What happens this time?
The file should execute the commands.
To finish this lab exercise, enter exit at the shell prompt.
That's it for this lab exercise. You now know how to manage basic Linux file system privileges. You'll now learn how to manage your system's network configuration.