In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shares with you the content of a sample analysis of file permissions and directory configuration in linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
A simple example of ls-al: =
-rw-r-r-. 1 root root 57494 Oct 1 08:08 install.log
The first column represents the permissions of the file and consists of 10 characters. The first character represents the file type:
D: indicates directory; -: indicates file; l indicates link file linkfile;b represents block device file (interface device that can be stored in device file); c represents character device file (serial port device in device file, such as keyboard, mouse, etc.), s represents socket sockets file, p represents pipeline FIFO file. The next three groups represent the permissions of owner, group, and other, respectively.
The second column indicates how many filenames are connected to this node (inode)
The third and fourth columns represent owner and group names, respectively.
The fifth column represents the file size in bytes bytes/B
The sixth column represents the file creation date or the most recent modification date, and if the modification date is too long from now, only the year, month and day information is displayed. You can display the full time with the parameter ls-al-full-time.
The seventh column is the file name, if there is one. The prefix means to hide the file.
= modify file properties =
Chown: change the owner of the file, and you can modify the group at will
Usage: chown [- R] ownner:group dirname/filename, where-R means to recursively modify the directory and all file attributes in that directory.
Chgrp: modify the group of a file
Usage: chgrp [- R] group dirname/filename
= modify file permissions =
Chmod: permissions can be changed either numerically or symbolically.
Usage: note that u stands for owner,g, for group,o, for other,a, for all.
Digital form: chmod [- R] 777 dirname/filename
= sign form: chmod [- R] upright rwx dir/file
+-form: chmod [- R] Uripr dir/file
The meaning of permissions for directories and files
Meaning to the document:
R: readable file contents
W: the contents of the file can be edited, added or modified, note that it is the content of the file. But does not include deleting the file
X: can be executed by the system
What it means to the directory:
R: the permission to read the directory structure list. When you have permission for a directory, it means that you can query the file name data in the directory. You can use the ls command to list the file names in the directory.
W: this writable permission is very powerful for the directory, and it has the permission to change the list of directory structure, that is, you can create new files and directories in the directory and delete the files and directories under the directory (regardless of the permissions of the files). Rename existing files or directories; transfer the location of files and directories in the directory.
X: enter the directory to make it the permission of the current working directory. To be able to view the contents of files in a directory, you must have x permission on that directory.
= directory configuration standard FHS===
The FHS standard recommends that the partition of the root directory (/) should be as small as possible, and the software installed by the application should not be placed in the same partition as the root directory, and keep the root directory as small as possible. In this way, not only the performance is better, but also the file system where the root directory is located is not prone to problems. In view of the above, FHS defines that the following subdirectories should exist under the root directory (/):
Directories should be placed File contents / the bin system has many directories where execution files are placed, but / bin is special. Because / bin places instructions that can be compared to operations in single-person maintenance mode. The instructions under / bin can be used by root and general accounts, mainly: cat, chmod, chown, date, mv, mkdir, cp, bash and other commonly used instructions. / boot this directory mainly stores the files used by the switch, including linux core files, boot menu and shutdown configuration files, etc. The common file name of linux kerne is: vmlinuz, if you are using grub, the boot manager, the directory / boot/grub will also exist. / dev on the linux system, any device exists in this directory as a file, and the more important ones are / dev/null, / dev/zero, / dev/tty, / dev/lp*, / dev/hd*, / dev/sd* and so on. Almost all the main configuration files of the / etc system are in this directory, such as the account number and password of the staff, and the startup files of various services. Generally speaking, the files in this directory can only be viewed by users, but only root can be modified and executed. FHS recommends that you do not place executables (binary) in this directory. The more important files are: / etc/inittab, / etc/init.d/, / etc/modprobe.conf, / etc/X11/, / etc/fstab, / etc/sysconfig/ and so on. In addition, the important catalogs are:
/ etc/init.d/: the default startup script for all services is placed here, for example, to start or disable iptables: "/ etc/init.d/iptables start", "/ etc/init.d/iptables stop"
/ etc/xinetd.d/: this is the profile of the services managed by the so-called super daemon.
/ etc/X11/: various configuration files related to X Window are here, especially xorg.conf, the configuration file of X Server.
/ home system home directory. More importantly, home catalogs have two code names:
~: the home directory of the current user
~ yidao: represents the home directory of yidao! There are a lot of function libraries in the / lib system, while / lib contains the function libraries to be used to boot and the ones that will be called by instructions under / bin or / sbin. Particularly important is the / lib/modules/ directory, because it will put kernel-related driver modules and so on! / mediamedia is the English word for "media". As the name implies, what is placed under this / media is a removable device! Including floppy disks, CD-ROMs, DVD, etc., are temporarily mounted here. Common ones are: / media/floppy, / media/cdrom, and so on. / mnt is temporarily mounted. It is generally recommended that you put it in this directory. In ancient times, the purpose of this directory was the same as / media! It's just that with / media, this directory temporarily mounts the / opt third-party software directory. For example, KDE, the desktop management system, is a stand-alone project, but it can be installed in the Linux system, so KDE software is recommended to be placed in this directory. In addition, if you want to install additional software yourself (not provided by the original distribution), you can also install your software here. However, in the previous Linux system, we were used to putting it in the / usr/local directory. / root system Manager (root) home directory. The reason for putting it here is that if you enter single maintenance mode and mount only the root directory, it will be able to have root's home directory, so we want root's home directory to be in the same partition as the root directory. / sbinLinux has a lot of instructions for setting up the system environment, which only root can use to "set" the system, and other users can only "query" them at most. Put under / sbin for the boot process, including the instructions needed to boot, repair, and restore the system. As for some server software, it is generally placed in / usr/sbin/. As for the system execution file (system binary) of the self-installed software on this machine, it is placed in / usr/local/sbin/. Common instructions include: fdisk, fsck, ifconfig, init, mkfs and so on. / srvsrv, which can be abbreviated to "service", is the data directory that these services need to access after some network servers are started. Common services such as WWW, FTP, etc. For example, the web data needed by the WWW server can be placed on the / srv/www/ profile. / tmp allows the general user or the executing program to place the file. This directory is accessible to anyone, so you need to clean it up regularly. Of course, important information can not be placed in this directory! Because FHS even recommends deleting all files under / tmp at boot time!
In fact, FHS's standard for root directories is only the above, but there are a lot of directories under our Linux that you need to know. Here are a few directories that are also very important in Linux:
The directory should place the file content / lost+found this directory is a directory that uses the standard ext2/ext3 file system format to place some missing fragments in this directory when an error occurs in the file system. This directory is usually at the top of the divider. For example, if you install a hard disk in / disk, it will automatically generate one of these directories "/ disk/lost+found" / proc. This directory is a "virtual file system (virtual filesystem)". The data he places is in memory, such as the system core, the process (process), the state of the perimeter setting, the state of the network, and so on. Because the data under this directory is in memory, it does not take up any hard disk space. Files that are more important than others such as / proc/cpuinfo, / proc/dma, / proc/interrupts, / proc/ioports, / proc/net/*, etc. The / sys directory is actually very similar to / proc. It is also a virtual file system, mainly recording core-related information. It includes the loaded core modules and the hardware information detected by the core, and so on. This directory also does not take up hard disk space.
* / the meaning and content of usr:
Usr is the abbreviation of Unix Software Resource. According to the basic definition of FHS, the data placed in / usr is shareable and immutable (shareable,static), and all default software of the system (software provided by distribution publishers) is placed under / usr, so this directory is somewhat similar to the C:\ Program Files directory in win. In general, the / usr subdirectory is as follows:
The directory should place the directory where the file content / usr/X11R6/ is placed for X Window System important data, named X11R6 because the last X version is version 11, and that version is released for the sixth time. / usr/bin/ most of the instructions available to users are put here! Please notice the difference between him and / bin. (whether it is related to the boot process) / usr/include/c/c++ and other programs such as header files (header) and inclusion files (include) are placed, when we install some data in tarball (*. Tar.gz), we will use the multiple inclusion files in it. / usr/lib/ contains function libraries for each application, object files (object file), and execution files or scripts (script) that are not commonly used by general users. Some software will provide some special instructions to configure the server, and these instructions will not be often operated by the administrator, so they will be placed in this directory. It is important to note that if you are using the Linux system of X860064, the / usr/lib64/ directory may be generated. / usr/local/ administrator installs the downloaded software (not a distribution default provider) on this machine. It is recommended to install it in this directory for ease of management. For example, if the software provided by your distribution is old, and you want to install the newer software but do not want to remove the old version, you can install the new version of the software in the / usr/local/ directory, which is different from the old one! You can go to / usr/local to see for yourself, this directory also has bin, etc, include, lib... The sub-catalogue of! / usr/sbin/ system instructions required for the normal operation of a non-system. The most common is the service instruction (daemon) of some network server software! / usr/share/ where shared files are placed, the data placed in this directory is almost readable regardless of hardware architecture, because it is almost all text files! These subdirectories are also common under this directory:
/ usr/share/man: online documentation
/ usr/share/doc: description of miscellaneous software documents
/ usr/share/zoneinfo: time zone file related to time zone
/ usr/src/ general source code is recommended here. Src means source. It is recommended that the core original code be placed in the / usr/src/linux/ directory.
* / the meaning and content of var:
If / usr is a directory that takes up a larger hard disk during installation, then / var is a directory that gradually takes up hard disk capacity after the system is running. Because the / var directory is mainly aimed at regular change files, including cache cache, login file date log file, and files generated by some software running, including program files (lock file,run file), or files such as mysql database. Common subdirectories are:
The directory should place the file contents / temporary files generated during the operation of the var/cache/ application itself; the data files that need to be used during the execution of the / var/lib/ program itself should be placed in this directory. In this directory, each software should have its own directory. For example, MySQL's database is placed in / var/lib/mysql/ and rpm's database is placed in / var/lib/rpm! / var/lock/ some settings or document resources can only be used by one application at a time, and if two programs use the device at the same time, some error conditions may occur, so you have to lock the device to ensure that the device is only used by a single software. For example, a burner is burning a CD. Do you think there will be two people using a burner disc at the same time? If two people burn it at the same time, whose information is written in that film? So when the first person is burning, the recording opportunity should be locked, and the second person has to unlock the setting (that is, the previous person has run out of it) before he can continue to use it. / var/log/ is too important! The directory where the login log file is placed! There are more important ones, such as / var/log/messages, / var/log/wtmp (recording the login information) and so on. / var/mail/ places a personal email mailbox in the directory, but this directory is also placed in the / var/spool/mail/ directory! Usually these two directories are connected to each other! / var/run/ after some programs or services start, they will place their PID in this directory. As for the significance of PID, I will mention it later. The / var/spool/ directory usually places some queue data, and the so-called "queue" is the data queued for other programs to use! These materials are usually deleted after they are used. For example, a new letter received by the system will be placed in / var/spool/mail/, but when the user receives the letter, the letter will in principle be deleted. If the letter cannot be mailed temporarily, it will be put in / var/spool/mqueue/ and will be deleted after it is sent. If it is the work scheduling data (crontab), it will be placed in the / var/spool/cron/ directory!
= END=
Thank you for reading! On the "linux file permissions and directory configuration example analysis" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!
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.