• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

? "Believe It!" - Mastering Linux File Permissions with Naruto ?

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
In the shinobi world, (I don't know this first-hand, this is only for presentation) not everyone can access the Hokage's scrolls or enter top-secret villages.

Similarly, in the Linux world, not all users can read, write, and execute every file. That's where Linux permissions and the legendary change commands come in:

  • chmod – Change a file’s jutsu access level (permissions)
  • chown – Change the ninja who controls the file (owner)
  • chgrp – Change the clan responsible for it (group)

Today, we'll walk through real-world examples of these commands, with Naruto and his pals.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



?️ Table of Contents

  • Setup: Hidden Leaf Village Training Grounds
  • chown: Who Owns the File?
  • chgrp: Clan Control
  • chmod: Jutsu Access Levels
    • Understanding Numeric Permissions
    • Symbolic Notation Examples
    • Understanding Symbolic Permissions
  • Bonus: Hidden Jutsu for Directory Permissions
  • Summary Table: Ninja Commands
  • Final Words from Ichiraku Ramen


? Setup: Hidden Leaf Village Training Grounds


Let’s create a playground for our ninjas to train in. Open your terminal and run:


mkdir -p ~/ninja_village/mission_scrolls
cd ~/ninja_village
touch naruto.txt sasuke.txt sakura.txt

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

These are the shinobi profiles. Inside mission_scrolls, we’ll keep top-secret files. We'll take a look at this later.


? chown: Who Owns the File?


In the ninja world, being assigned to a mission means having ownership of that task. Similarly, chown gives control of a file to a specific user.

Let’s say Kakashi-sensei gives Naruto his own scroll.


sudo chown naruto naruto.txt

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Hmmm...What did we miss?

If you created naruto as a user before using chown or recognized that the cmd would not work, I want to encourage you to keep learn! We are actually grasping the concepts!
Create naruto as a user and try the chown cmd again...

Now Naruto is the owner of naruto.txt.

Check ownership with:


ls -l

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


? chgrp: Clan Control


Sometimes missions are assigned to a clan, like the Uchiha or Hyuga. chgrp lets us assign a file to a group.

Let’s put Sasuke's file under the Uchiha clan’s control:


sudo chgrp uchiha sasuke.txt

You can view the group with:


ls -l

Make sure the group uchiha exists:


sudo groupadd uchiha

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


? chmod: Jutsu Access Levels


Now comes the fun part... permissions! Think of these as who can read, write, or execute (perform jutsu) on a file.

If Naruto’s file should only be read by him and no one else:


sudo chmod 600 naruto.txt

To make Sakura’s file world-readable:


sudo chmod 644 sakura.txt

If Sasuke wants to execute a mysterious script:


sudo chmod 755 sasuke.txt

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


? Understanding Numeric Permissions


Linux permission numbers are calculated using:

  • 4 = Read (r)
  • 2 = Write (w)
  • 1 = Execute (x)

Add them together to get the level of access:

NumberMeaningBinaryExample Description
7rwx (full)111Read, write, and execute
6rw-110Read and write only
5r-x101Read and execute only
4r--100Read only
3-wx011Write and execute
2-w-010Write only
1--x001Execute only
0---000No permissions

So chmod 755 means:

  • Owner = 7 = rwx
  • Group = 5 = r-x
  • Others = 5 = r-x


? Symbolic Notation Examples (u, g, o + - =)


Instead of using numbers, you can also use symbolic characters:

? Add permissions (+)


Give Naruto’s file execute power (so he can run his own shadow clone jutsu):


sudo chmod u+x naruto.txt
? Remove permissions (-)


Prevent others from reading Sakura’s file:


sudo chmod o-r sakura.txt
? Set exact permissions (=)


Only allow the group (Team 7) to read and write Sasuke’s file—nothing else:


sudo chmod g=rw sasuke.txt

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


? Understanding Symbolic Permissions


Symbolic permissions allow you to modify file access in a more human-readable way using characters and symbols instead of numbers.

? Syntax of Symbolic Mode:


chmod [who][operator][permissions] filename
? [who] – Who are you assigning permissions to?

SymbolWho it affectsMeaning
uUserThe owner of the file
gGroupThe group assigned to file
oOthersAll other users
aAllEquivalent to u, g, and o
⚙ [operator] – What are you doing?

SymbolActionMeaning
+AddAdd specified permissions
-RemoveRemove specified permissions
=Assign exactlySet only the specified permissions (removes others)
? [permissions] – What type of access?

SymbolPermission TypeDescription
rReadView the contents of a file
wWriteModify or delete a file
xExecuteRun the file as a program/script
? Example Combinations:

CommandMeaning
chmod u+x file.txtAdd execute permission for the user
chmod g-w file.txtRemove write permission from the group
chmod o=r file.txtSet others to have only read permission
chmod a+rw file.txtGive read and write permission to user, group, and others
chmod ug=rw file.txtSet user and group to have read/write, and remove other permissions
chmod o= file.txtRemove all permissions from others


? Bonus: Hidden Jutsu for Directory Permissions


Inside mission_scrolls, let’s add a secret mission file and set special permissions.


touch mission_scrolls/s-rank.txt
sudo chmod 700 mission_scrolls
sudo chmod 600 mission_scrolls/s-rank.txt

Only the Hokage (root user) can access this!


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


? Summary Table: Ninja Commands

CommandMeaningNaruto Analogy
chownChange file ownerAssign mission to a specific ninja
chgrpChange group ownershipAssign mission to a clan
chmod (numeric)Set permissions with numbersBroad mission rank setting
chmod (symbolic)Add/remove exact permissionsGrant or revoke access like chakra seals


? Final Words from Ichiraku Ramen


Managing file permissions is like managing missions in the ninja world, you need the right person (or group) with the right access. Give too much access, and you risk a rogue ninja (or hacker) sabotaging the mission. Too little, and the mission might fail before it starts.

So next time you're setting permissions, channel your inner Hokage, and do it with precision.

“I’m not gonna run away, I never go back on my word! That’s my nindo: my ninja way!” – Naruto Uzumaki
?

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу