Linux praktikum 1

From TÜ Narva Kolledži Wiki
Jump to navigation Jump to search

Working with permissions and attributes of files and directories

Task: Learn how to work with commands for changing user permissions

Create directories Maria and Juku in the /home/user directory

Add users maria and juku

Change only the owner's name of the directories according to the names of the directories

Check their presence and attributes

Move to /home/user directory

Create a file jukufile.txt in the Juku directory

Create a file jukufile2.txt in the Juku directory

Create a file jukufile3.txt in the Juku directory

Add write permissions for “other” users to jukufile3.txt

Check their presence and attributes

Change the user to maria

Which files can the user maria delete?

Create a directory sticky in the Maria directory

Create a file script.sh in the sticky directory with the following content

#!/bin/bash

echo “Hello, World!”

Add execution permission for all user categories (all) to the file

Check its presence and attributes

Run the script file

Remove execution rights (x) from all users for the sticky directory

Go to the Maria directory

Can you view the contents of the script.sh file and execute it?

Try the following commands as well:

cd sticky

ls -l sticky

Do the programs work correctly?

Return the execution rights of the sticky directory to all user categories

Add the “Sticky bit” to the sticky directory

Check the attributes

Set access rights 777 to both the sticky directory and the script.sh file

Check the attributes

Change the user to juku

Try to delete the sticky directory and the script.sh file with the command rm -rf sticky, despite the fact that they have permissions “everyone is allowed everything - 777”

Create a directory sgid in the Juku directory

Give write permission to the directory for all user categories

Set the “sgid” attribute on the sgid directory

Check the “sgid” attribute, make sure that it is in the right place

Change the user to Maria

Create a file in the sgid directory

What group did the created file get, why juku?

Change the user to juku

Remove execution rights (x) for the group from the sgid directory

What has changed?

Set permission 1777 on the sgid directory

What has changed? Has the “Sticky bit” been added?

Recursively change access rights in the Juku directory to 644 as the superuser.

Run the command ls -lR /home/user and show it to the teacher.