In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to set file permissions and directories in Linux. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
File permissions and directories
The first character means that the file is "directory, file, or linked file, etc.": when [d], it is a directory, such as the line named ".config" in the above table; when it is [-], it is a file, such as the line named "initial-setup-ks.cfg" in the above table; if it is [l], it is represented as a linked file (link file). If [b], it is represented as a peripheral device that can be stored in the device file (random access device); if it is [c], it is expressed as a serial port device in the device file, such as keyboard and mouse (one-time read device).
In the following characters, a combination of three parameters, all of which are "rwx". Where [r] represents readable (read), [w] represents writable (write), and [x] represents executable (execute). It is important to note that the location of these three permissions will not change, if there are no permissions, there will be a minus sign [-]. The first group is "permissions that the file owner can have". Take the file "initial-setup-ks.cfg" as an example, the owner of the file can read and write, but cannot be executed; the second group is "permission to join accounts in this group"; and the third group is "permission to join other accounts who are not in this group".
How to change file properties and permissions
Chgrp: change the group to which the file belongs chown: change the file owner chmod: change the permissions of the file, SUID, SGID, SBIT, etc.
Numeric type changes file permissions:
RRRV 4 > wRV 2 > xRV 1
For example: what if you want to change permissions to "- rwxr-xr--"? Then the score of permission is [4 / 2 / 1] [4 / 0 / 1] [4 / 0 / 0] = 754! So you need to send "chmod 754 filename".
Executable file permissions: chmod 755 test.sh
Symbol type changes file permissions:
We can use u, g, o to represent the authority of the three identities! In addition, a stands for all, that is, the full identity! Then the read and write permissions can be written as r, w, x! That is, you can see it in the following ways:
| | chmod | u g o a | + (join)-(remove) = (set) | r w x | File or directory |
For example:-rwxr-xr-x: chmod uprirwx.bashrc
-rwxr-xr--: chmod uprirwx filename
If I don't know the original file properties, and I just want to increase the permissions that everyone in the .bashrc file can write to.
Chmod axiw.bashrc
And what if you want to remove permissions without changing other existing permissions? For example, to take away the executable rights of all people.
Chmod Amurx .bashrc
Effect of permissions on files and directories
Component content iteration object rwx file detailed data data file folder read file content modification file content execution file content directory file name sortable drawer read file name modify file name permission to enter that directory
Note: to view files in the file directory, this folder requires X permission.
Linux file type and extension
Regular file (regular file): a character is [-], such as [- rwxrwxrwx]. According to the contents of the document, it can be roughly divided into:
Plain text file (ASCII): for example, you can click "cat~/.bashrc" to see the contents of the file.
Binary file (binary): for example, the instruction cat just issued is a binary file.
Data format file (data): for example, our Linux will record the login data in the file / var/log/wtmp when the user logs in. The file is a data file, and he can read it through the command last!
Directory (directory): is the directory ~ the first attribute is [d], for example, [drwxrwxrwx].
Link file (link): it's a shortcut similar to the one under the Windows system! The first attribute is [l] (lowercase of L), for example, [lrwxrwxrwx]
Devices and device files (device): usually concentrated in the / dev directory! It is usually divided into two categories:
Block device files: for example, hard disk and floppy disk, etc. The first attribute is [b],
Character device files: keyboard, mouse, etc.! These devices are characterized by "one-time read", and the first attribute is [c].
Data interface file (sockets): this type of file is usually used to receive data on the network. The first attribute is [s] data transfer file (FIFO, pipe): its main purpose is to solve the error problem caused by multiple programs accessing a file at the same time. FIFO is the abbreviation of first-in-first-out. The first attribute is [p].
Linux file extension:
Unlike the file extension in window, basically, there is no so-called "extension" in Linux file, and the extension only serves as a representation of what kind of file it is.
Linux directory configuration
The basis of Linux directory configuration-- FHS (Filesystem Hierarchy Standard)
The first part of the contents of the document shall be placed in the catalogue:
The main directories / bin that FHS requires must exist are: cat, chmod, chown, date, mv, mkdir, cp, bash and other commonly used instructions. / boot this directory is mainly used to place the files used by the machine. / dev any devices and peripherals exist in this directory in the form of files. Almost all the main configuration files of / etc system are placed in this directory, such as the account password file of personnel, the startup file of various services, and so on. FHS recommends that you do not place cocoa executable files (binary) in this directory. The / lib system has a lot of function libraries, while / lib places the function libraries that will be used when booting, as well as the function libraries that will be called by instructions under / bin or / sbin. / media this / media below is the removable device! Including floppy disks, CDs, DVD, etc. / mnt if you want to mount some additional devices temporarily, it is generally recommended that you put them in this directory. / opt this is the directory for third-party collaboration software. If you want to install additional software yourself, you can also install your software here. However, in previous Linux systems, we were used to placing it in the / usr/local directory. / all the information generated after the run system is powered on. / srvsrv, which can be seen as an abbreviation for "service", is the data directory that some network services need to access after they are started. / tmp the place where the program being executed temporarily places the files. / usr layer 2 FHS settings, which will be introduced later. / var has been set up by FHS for the second time, mainly for placing changeable data, which will be introduced later. The second part: FHS suggests that the directory / home system default user home folder (home directory) / lib is used to store binary function libraries in different formats from / lib, such as the home folder of / root system administrator (root), which supports 64-bit / lib64 function libraries.
In addition to the directories defined by FHS, here are a few directories that are also very important in Linux:
Directory should place file contents / lost+found this directory is a directory that uses the standard ext2/ext3/ext4 file system format to place missing fragments in this directory when there is an error in the file system. However, if you are using the xfs file system, this directory will not exist! The / proc directory itself is a "virtual file system (virtual filesystem)". The / sys directory is actually very similar to / proc. It is also a virtual file system, which mainly records information related to the core and system hardware information.
The meaning and content of / usr:
Many readers will misunderstand that / usr is the abbreviation of user. In fact, usr is the abbreviation of Unix Software Resource, that is, the directory where "Unix operating system software resources" are placed, not the user's data!
In general, the subdirectory recommendations for / usr are as follows:
The first part of the contents of the document shall be placed in the catalogue:
The directory that FHS requires must exist / usr/bin/ all the instructions that can be used by ordinary users are put here! / usr/lib/ is basically the same as / lib, so / lib is linked to this directory! / usr/local/ system administrators install their own downloaded software on this machine. / usr/sbin/ is not the system instructions required for the normal operation of the system. The most common is the service instruction (daemon) of some web server software. / usr/share/ mainly places data files of read-only architecture, including shared files. Part II:
FHS recommends directories that can exist / usr/games/ data placement related to games / usr/include/c/c++ and other programming languages file start (header) and include file (include) placement / usr/libexec/ some executable files or scripts (script) that are not commonly used by general users, etc. / usr/lib/ and / lib/ function is the same So currently / lib is linked to this directory / usr/src/ general source code is recommended to be placed here, src means source.
The meaning and content of / var:
If / usr is a directory that takes up a large amount of hard disk capacity during installation, then / var is a directory that gradually takes up hard disk capacity after the system is running. For example, files in the MySQL database, and so on. Common subdirectories are:
The directory should place the first part of the contents of the file.
Copies: directories that FHS requires to exist / some scratch disks generated during the running of the var/cache/ application itself; directories where data files need to be used during the execution of the var/lib/ program itself. / var/lock//var/log/ this is the directory where the login file is placed! There are more important documents such as / var/log/messages, / var/log/wtmp (recording the information of the lander) and so on. / var/mail/ the directory where you put your personal email / var/run/ some programs or services will put their PID in this directory when they start up. The / var/spool/ directory usually places some queue data, and the so-called "queue" is queuing for data used by other programs!
Directory tree:
Absolute path and relative path
Absolute path: the file name or directory name written from the root directory (/), such as / home/dmtsai/.bashrc; relative path: the file name relative to the current path. For example,. / home/dmtsai or.. /.. / home/dmtsai/, etc. Anyway, it doesn't / belong to the relative path at the beginning.
. Represents the current directory, or you can use. / to indicate;. : represents the directory above, or.. / to represent.
The above is how to set file permissions and directories in the Linux shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.