Linux system file type soft and hard links



December 27, Ding You year Name: Wang Guang

1. File types are divided into:

Ordinary file; directory file d; pipe file p; device file (character device file c "can receive character streams, such as printers and terminals"/block device file b "readable and writable, such as disk"); link file l
[Note: The role of /dev/null in character files: everything sent to this device is ignored, and if you redirect the program's output to /dev/null you won't see any information. You can use this to direct the user's shell to the file to prevent him from logging in b. Redirect some junk files to it to ensure the stable operation of the system]
2. View the file:
file [View file type]
ls -l /ll /lh / 1 /a [View file permissions, /lh shows the size of the specific; /1 long format display; /a hidden files are displayed]

3. Linux directory structure: (Linux file system has a root file system, including system boot and other The necessary files for the file to be mounted; it also includes the necessary content of the user state, repairing the file system and restoring the backup and other files)
The Linux directory structure is a hierarchical tree structure. The following are the main functions of the directory file:
– /
root directory , all files are mounted under it
– ~
the home directory of the current user, equivalent to $home
– /home The home
directory of each user, the subdirectory is named after the user name
– /root
The home directory of the root user
– /bin
stores commonly used users Commands
– /sbin
stores common commands for system administrators and ROOT users
– /dev
device files
– /lib
Shared files and kernel module files
– /lib/modules
core loadable files, recovering modules needed to boot when a damaged system
– /tmp
temporary files
– /mnt
provides default mount directories for devices (hard disks)
– /proc
virtual file system, Does not exist on the disk, generated by the kernel memory, used to view the relevant information of the provided system and set the kernel parameters
/proc/version system version
/proc/cpuinfo CPU information
/proc/meminfo memory information
/proc/ioports I/O ports
/ proc/filesystems file system information
– the following are all files –
– /boot
contains Linux kernel files and boot loader (such as GRUB) files
– /sys
Linux system newly designed virtual memory-based file system, in addition to /proc function In addition to the management of the Linux unified device model
– /opt
third-party application installation files
– /media
CD-ROM, floppy disk, U disk default mount directory
– /etc
Most of the configuration files
– /usr
stores infrequently changed data, generally used as Mount it as a separate partition
– /var
Store data that changes infrequently, such as system logs, print queues, DNS database files
– /srv
The data directory required after some services are started
– /run is
equivalent to /var/run, which is saved to the effective system information before the next boot Information file
– /lost+found
The system stores those “free” files due to unexpected power failure or
abnormal
shutdown

5. File access principle:

When a new file is created, the kernel will assign an inode (index node) number to it, and the file attributes will be saved in it. When accessing the file, the node will be copied to the memory, so as to achieve fast access
. 6. Link file
a.ln -s source file target file [none The option is to create a hard link]
b. Classification:

Soft link (symbolic link) hard link
1. The path name of the link file, which can be a directory (equivalent to: shortcut)
2. It can be used for cross-partition links, resulting in high frequency of use
3. Delete the source file, the link file has no content
4. When ls -l is viewed, the file capacity Small (shortcut) can also see "b->a" (b source file is a) the number of links is 1
5. You can link non-existing files (broken chain), and you can also link yourself in a loop
1. Pointer to the index node (inode) of the file (equivalent to: backup)
2. Only link in this partition
3. Delete the source file, the linked file still saves the content of the source file (backup!)
4. ls -l View When the file size is the same, the number of connections is 2.
5. Do not create hard links for directories




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325939165&siteId=291194637