Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the document properties of Linux

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains the "what are the document properties of Linux", the content of the explanation is simple and clear, easy to learn and understand, please follow the editor's ideas slowly in depth, together to study and learn "what are the document properties of Linux"!

Write at the front

We all know that Linux is a system that supports multi-user and multi-task, which is also its best feature, that is, there may be many people working on the system at the same time, so do not force the shutdown. At the same time, in order to protect everyone's privacy and working environment, the Linux system defines three identities for a certain document (file, directory), namely, the owner (owner), the group (group), and others (others). Each identity corresponds to three permissions, namely readable (readable), writable (writable), and executable (excutable).

Document properties

Use the command ls-al-- full-time, or the abbreviated ll of this command, to view all the properties of a file or directory. As follows:

As you can see from the above, each row has seven columns, which are:

First column

A total of 10 bits, the first bit represents the document type, d represents the directory,-represents the file, l represents the linked file, d represents the random access device, such as U disk, etc., c represents the one-time reading device, such as mouse, keyboard, etc. The last 9 bits correspond to the permissions owned by the three identities, in the order of owner, group and others, and the order of permissions is readable, writable and excutable. For example, the meaning of the current document is that the current document is a file, the owner can read and execute, and the users in the same group can read and write, and others do not have any rights.

Second column

Represents the number of links

The third column

Represents the owner.

Fourth column

Indicates the group to which it belongs

Fifth column

Represents the size of the document in bytes

Sixth column

Indicates the last modification time of the document. Note that it is not the creation time of the document.

Seventh column

Represents the document name. To point (.) It starts with hiding the document.

Change owner (owner) location etc/passwd

Note: it must be an account that already exists in this location. That is, only the owner with a record in / etc/passwd can change. Syntax chown [- R] [account name] [file or directory] chown [- R] [account name]: [group name] [file or directory] Note: this command can also change the document group by the way, but it is recommended to use the chgrp command to change the document group. Option

-R recursive change, that is, all files (folders) in the subdirectory will be changed.

Usage

Chown daemon test changes the folder test account number to daemon.

Chown daemon:root test changes the folder test group to root.

Chown root.users test changes folder account to root and group to users

Chown .root test changes the group to root separately

Note: although it is possible to add a decimal point (.) between the owner and the group, in order to avoid the naming of some students, it is recommended to use the colon ":" to separate the owner from the group to avoid misjudgment. Change group (group) location etc/group

Note: you can see all the group syntax chgrp [- options] [group name] [document path] Note: for options, you can query the detailed usage through man chgrp, info chgrp, chgrp-- help and other commands. Usage

Chgrp-R users test changes the group of test folder and all its child files (folders) to users.

Note: if the group name is not in the location, an error invalid group will be reported.

Change of authority

There are only three basic permissions for Linux documents, namely read/write/execute, and only nine with identity owner/group/others. There are two ways to change permissions, which are symbolic method and digital method.

-symbolic method

Three identities are represented by uther gmeno, a for all identities, r, w and x for three kinds of permissions, and +, -, and = for operation behavior respectively.

Syntax chmod | u g o a | + (join)-(remove) = (set) | r w x | document path

Set permissions (=)

Change the permissions of the directory test so that anyone can read, write, and execute.

Chmod uprirwx, gendarwx, test, or chmod ugo=rwx test or chmod a=rwx test

Remove permissions (-)

Remove the directory test execution permission

Chmod Umurx test gripx test o Lay x or chmod ugo-x test or chmod

Note: execute permission (x), just to the directory is whether other users can cd test to become the working directory. Add permissions (+)

Increase directory test execution permissions

Chmod uprix test or chmod ugo+x test or chmod aquix test

Note: familiar with it, if we finish writing a shell file test.sh, we add file execution permissions through chmod adepx test.sh. -Digital method

As the name implies, numbers are used to represent permissions. Rrecoery wpencil x is 4meme2pr 1 respectively. The permission of an identity can be obtained by adding up the three kinds of permissions.

Set the permissions of the directory test so that anyone can read, write and execute.

Chmod 777 test

Set the permissions of the directory test so that anyone can read and write.

Chmod 666 test

Give a shell file test.sh executable permission, the owner can read, write, execute, group accounts and others can read and execute.

Chmod 755 test remarks: have you found that the numerical method is simpler! Differences in file and directory permissions

Document permissions vary greatly between files and directories

File

For the contents of the file

Readable can read the actual contents of the file

Writable can edit, add, or modify the contents of the file

Executable has permissions that can be executed by the system

Note: files cannot be deleted with w permissions. Deleting files is the scope of directory permission control! Remember that the right of the file is the content of the file. Catalogue

For the file objects in this directory

Readable has permission to read the directory structure list, that is, you can query the directory list through the ls command.

Writable has the right to change the directory structure list, that is, you can create, migrate, delete, and rename files in this directory.

Executable has permission to enter this directory, that is, through the cd command, you can go to the working directory.

Note: as can be seen from the above, when opening the directory to anyone to browse, at least r or x permissions are required. To read the contents of a directory file, you need at least directory permissions x and file permissions r. Summary

Each document in Linux can be assigned rwx permissions for three identities; chgrp command changes file group, chmod command changes file permissions, and chown changes file owners; then remember to use document permissions to protect data security later.

Thank you for your reading, these are the contents of "what are the document properties of Linux?" after the study of this article, I believe you have a deeper understanding of what the document properties of Linux have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report