Linux praktikum 1: Difference between revisions

From TÜ Narva Kolledži Wiki
Jump to navigation Jump to search
Content deleted Content added
No edit summary
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Working with permissions and attributes of files and directories==
== Praktikum 1. Работа с разрешениями и атрибутами файлов и каталогов==


'''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
Создайте каталоги Maria и Juku в каталоге /home/user


Change only the owner's name of the directories according to the names of the directories
Добавьте пользователей maria и juku


Check their presence and attributes
Поменяйте только имя владельца у каталогов в соответствии с именами каталогов

Проверьте их наличие и атрибуты


[[File:Prak1_Picture_1.png]]
[[File:Prak1_Picture_1.png]]


Move to /home/user directory
Создайте в каталоге Juku файл jukufile.txt


Create a file jukufile.txt in the Juku directory
Смените пользователя на juku


Create a file jukufile2.txt in the Juku directory
Создайте в каталоге Juku файл jukufile2.txt


Create a file jukufile3.txt in the Juku directory
Создайте в каталоге Juku файл jukufile3.txt


Добавьте права на запись пользователям “other” для jukufile3.txt
Add write permissions for “other” users to jukufile3.txt


Check their presence and attributes
Проверьте их наличие и атрибуты


[[File:prak1_Picture 2.png]]
[[File:prak1_Picture 2.png]]


Change the user to maria
Смените пользователя на maria


Which files can the user maria delete?
Какие файлы может удалить пользователь maria?


Create a directory sticky in the Maria directory
Создайте в каталоге Maria каталог sticky

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


Создайте в каталоге sticky файл script.sh со следующим содержанием
<pre>
<pre>
#!/bin/bash
#!/bin/bash
Line 41: Line 41:
</pre>
</pre>


Add execution permission for all user categories (all) to the file
Добавьте всем категориям пользователей (all) разрешение на запуск файла


Check its presence and attributes
Проверьте его наличие и атрибуты


[[File:prak1_Picture 3.png]]
[[File:prak1_Picture 3.png]]


Run the script file


⚫
[[File:prak1_Picture 4.png]]
Запустите скрипт


Remove execution rights (x) from all users for the sticky directory
⚫
[[prak1_Picture 4.png]]


Go to the Maria directory


Can you view the contents of the script.sh file and execute it?
Уберите права у всех пользователей на выполнение (x) у каталога sticky


Try the following commands as well:
Перейдите в каталог Maria


Можете ли вы посмотреть содержимое файла script.sh, а также запускать его?

Попробуйте также команды:
<pre>
<pre>
cd sticky
cd sticky
Line 66: Line 65:
</pre>
</pre>


Do the programs work correctly?
Корректно ли работают программы?


Return the execution rights of the sticky directory to all user categories
Верните права на выполнение каталога sticky всем категориям пользователей


Добавьте “Sticky bit” каталогу sticky
Add the “Sticky bit” to the sticky directory


Check the attributes
Проверьте атрибуты


[[File:prak1_Picture 5.png]]
[[File:prak1_Picture 5.png]]


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


Check the attributes
Поставьте права доступа 777 и каталогу sticky и файлу script.sh

Проверьте атрибуты


[[File:prak1_Picture 6.png]]
[[File:prak1_Picture 6.png]]


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”
Смените пользователя на juku


Create a directory sgid in the Juku directory
Попробуйте удалить каталог sticky и файл script.sh командой rm -rf sticky, несмотря на то что у них стоят разрешения «всем все разрешено - 777»


Give write permission to the directory for all user categories
Создайте в каталоге Juku каталог sgid


Set the “sgid” attribute on the sgid directory
Дайте разрешение на запись в каталог всем категориям пользователей


Check the “sgid” attribute, make sure that it is in the right place
Поставьте атрибут «sgid» на каталог sgid

Проверьте атрибут «sgid», что он находится в правильном месте


[[File:prak1_Picture 7.png]]
[[File:prak1_Picture 7.png]]


Change the user to Maria


Create a file in the sgid directory
Смените пользователя на maria


What group did the created file get, why juku?
Создайте файл в каталоге sgid


Change the user to juku
Какую группу получил созданный файл, почему juku?


Remove execution rights (x) for the group from the sgid directory
Смените пользователя на juku


What has changed?
Уберите права на выполнение (x) для группы у каталога sgid

Что поменялось?


[[File:prak1_Picture 8.png]]
[[File:prak1_Picture 8.png]]


Set permission 1777 on the sgid directory


What has changed? Has the “Sticky bit” been added?
Поставьте разрешение 1777 на каталог sgid

Что поменялось? Добавился ли “Sticky bit”?

Поменяйте рекурсивно права доступа в каталоге Juku на 644 от имени суперпользователя.


Recursively change access rights in the Juku directory to 644 as the superuser.
Запустите команду ls -lR /home/user и покажите преподавателю.


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


[[File:prak1_Picture 9.png]]
[[File:prak1_Picture 9.png]]

Latest revision as of 14:56, 11 November 2025

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.