Linux Ownership Changing

LinuxLinuxBeginner
Practice Now

Introduction

Imagine that you have been transported back to an ancient oriental temple where a mysterious traditional healer, well-versed in the arts of both medicine and digital alchemy, seeks your assistance. The temple, housed at the foot of a mountain, has long been a sanctuary of knowledge for the villagers. The monks of the temple have just begun learning about the mystical world of Linux, which they believe will enhance their ability to preserve ancient scriptures and medicinal formulas. To ensure these sacred texts are safeguarded, they need to protect them with the correct ownership permissions.

Your goal is to help the healer teach the monks how to change and manage file ownership in Linux using the chown command, reinforcing the security and sanctity of their digital archives.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicFileOperationsGroup(["`Basic File Operations`"]) linux/BasicFileOperationsGroup -.-> linux/chown("`Ownership Changing`") subgraph Lab Skills linux/chown -.-> lab-271243{{"`Linux Ownership Changing`"}} end

Understanding the chown Command

In this step, you will learn about the chown command, which is used to change the owner of a file or directory in Linux. We will start by creating a file named ancient_scripture.txt that will represent a piece of sacred text.

Execute the following commands in the terminal to create the file:

cd ~/project
touch ancient_scripture.txt
ls -l

You should see the file listed with its current ownership details. The file's owner is likely the user you are currently logged in as.

Now, we add a new user healer:

sudo adduser healer

Next, we change the ownership of this file to the user healer:

sudo chown healer ancient_scripture.txt

To check if the ownership has changed, use ls -l again and look at the owner column.

Changing File Group Ownership

Now that the file ownership has been changed, it is equally important to manage the file's group ownership for the monks to categorize their scriptures securely.

Create a group named monks:

sudo groupadd monks

Next, we change the group ownership of ancient_scripture.txt to this new group:

sudo chown healer:monks ancient_scripture.txt

Remember to verify the group ownership change with ls -l. The group should now be set to monks.

Summary

In this lab, we ventured into an ancient temple to understand and apply the chown command in a mythical yet practical setting. The design was aimed at providing an engaging context for an otherwise technical skill, serving to captivate the learners' attention and make the learning process enjoyable. Through this lab, learners would grasp the essentials of file ownership management in Linux, ensuring they are equipped to maintain proper security and organization within their files and directories. This experience highlights the confluence of storytelling and instruction, making the act of learning both effective and memorable.

Other Linux Tutorials you may like