Home Linux Server Why should you not use 777 permissions on Linux?

Why should you not use 777 permissions on Linux?

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

When you first come into contact with Linux, surely the terms decentralization, chmod, chown are no longer strange to you. However, have you assigned the right permissions and what do the rights you regulate mean and what rights should not be abused?

Maybe sometimes you will encounter the message You don't have permission to or permission denied when using and working on a Linux server. And the fastest way that I read in tutorials and on forums is to use chmod -R 777 file-hoac-folder. This command will solve your problem, but is it effective and safe? So let’s learn about permissions in Linux.

Why should you not use 777 permissions on Linux?

Before going into decentralization, let’s ask why it is necessary to decentralize.

I will take a real-life example for you to imagine easily:

Assuming you have a phone, it belongs to you, then you have the right (to use, sell or throw it away). And another person borrows your phone, and you only allow them to hold, see, not sell, then the act of agreeing to lend and only allow to see is a form of decentralization and division of permission.

And if that person knowingly sells your phone without your consent, that’s a violation. But on Linux, this behavior will be prevented immediately.

Why should you not use 777 permissions on Linux?

How to decentralize in Linux

Before going into decentralization in Linux, you need to know the following 2 important components:

Permission Groups

The users in the system will be divided into 3 groups as follows:

  • Owner: The owner of the file.
  • Group: A certain group and given any permissions to the file, the users in the group will have that permission.
  • Other: The remaining users (not in the above 2 types)

Permission Type

There are 3 basic types of permissions in Linux: read, write and execute files as shown in the table below:

PermissionSymbolNumber formDescribe
Readr4Read file
Writew2Write/edit file
Executee1Execute file

At this point, you can understand the meaning of the number 7 in the set of 777 rights. It is the sum of the 3 numbers above (Read+Write+Execute=4+2+1=7), i.e., are all read, write and execute permissions.

But why 777? Let’s continue to check the current file permissions. If you are familiar with the ls command to list files/folders, just add the -l option to see the details of permissions as follows:

CleanShot 2022 05 21 at 22.27.44@2x

In this image, you will see some columns and ranges of numbers and symbols and I will explain each, so you are clear.

Column 1: In this column, each file/directory will have different permissions with different symbols. For example, the first file is -rw-r–r–, then this set will include the following:

  • : this sign is to identify the file type, ie if there is a sign, it is a file and the letter d is a directory, the letter c is the device and the letter l (L) is the link.
  • rw-: the first 3 are Owner’s permissions
  • r-: the next trio is the Group’s permission
  • r–: the remaining 3 are Other’s permission

Column 2: (Number 1) this number indicates the number of links to the file, the number 1 here means it has only 1 hard link pointing to itself

Column 3: The owner of the file here is the root

Column 4: The group that owns the file in this image is the root

The next columns show the size, time, file name and folder information.

When you have seen this section, you must have understood decentralization in Linux, right? Then go back to the question and article title about the 777 permission. Each number will correspond to the Owner/Group/Other authority.

chmod -R 777

With this permission, you give any user full rights to your file/folder. This is a dangerous activity, and you should not use it indiscriminately. And should only be used when necessary and you must have complete control over it.

Hopefully, this article will help you understand more about the numbers in decentralization and how to decentralize in Linux.

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign