What is a file
On Linux systems, all resources are files, and the types of files under the Linux system include
- Normal file (-)
- Catalogue (d)
- Symbolic Link (l)
- Character device file (c)
- Block device file (b)
- Sockets (s)
- Command Pipeline (P)
normal file : Just a byte sequence, Linux does not specify any structure for its content. Ordinary files can be any file, Linux does not discriminate between these files, only the application processing these files will be based on the contents of the file to give them the corresponding meaning.
In the doc and Windows environments, the suffix of all filenames can represent the type of file that can be executed in a Linux environment, as long as it is an executable file and has an enforceable property, regardless of the filename suffix, the common file suffix
- *.txt: Text File
- *.conf: Configuration file
- *.html/*.xml/*.yml/*.sql:html/xml/yaml/sql file
- *.c/*.cpp:c/c++ Language source Program Files
- *.so/*.ko/*.lib: module files, library files
- *.sh/*.php/*.py/*.pl/*.rb:shell/php/python/perl/ruby script File
- *.rpm:rpm Bag
- *.tar:tar Archive File
- *.GZ/*.BZ2/*.XZ: Compressed file generated by GZIP/BZIP2/XZ
- *.TAR.GZ/*.TGZ/*.TAR.BZ2/*.TBZ/*.TAR.XZ/*.TXZ: Compressed tar package file
- *.lock: A lock file used to represent a program or a service that is running
- *~ Backup Files
Directories and Hard Links
A catalog file consists of a set of catalog items that can point to other files or to sub-directories under them. In fact, the name of a file is stored in its parent directory, rather than being stored together with the contents of the file itself.
Hard Links: Two file names (stored in the directory entry in their parent directory) point to a storage control on the hard disk, and modifying any of the two files will affect the other file. is actually creating a directory entry in a directory, so that more than one directory can refer to the same file, the increase/deletion will affect the number of links to the file
PS: Hard links are not a special type of file, but a mechanism that allows multiple directory entries to point to the same file in the same file system.
1 Ln file1 file2
Symbolic Links
A symbolic link is also called a soft link: A file name that points to another file. It only records the file name to point to, so the space is very small, the number of links to add/delete files will not change, if the target file is deleted, pointing to the file will be called dead link
1 Ln -S file1 file2
Device files
A device is a peripheral hardware device in a computer, that is, all devices except CPU and memory. All hardware devices are placed in the/dev directory.
/dev/hd*:ide hard disk device, such as Hda1,a represents the first hard disk, 1 represents the 1th partition
/DEV/SD*:SCSI/SATA/SAS/USB hard disk device, such as Sda1,a represents the first hard disk, 1 represents the 1th partition
/dev/null: Empty device, typically used to mask command line output
Linux directory structure
/: root directory, general root directory only, do not store files,/etc,/bin,/dev,/lib,/sbin should and root directory placed in a partition
/bin:/usr/bin: Executable binary directories, such as common commands ls, tar, MV, Cat, and so on.
/ Boot: Place some files that are used by the Linux system when it is started. /boot/vmlinuz is the kernel file for Linux, as well as/boot/gurb. Recommended separate partition, partition size 100M
/ Dev: storage device files under Linux system, access to a file in this directory, equivalent to access to a device, often mounted CD-ROM mount/dev/cdrom/mnt.
/ etc: The directory where the system configuration file is stored, it is not recommended to store executable files in this directory, important configuration files are/etc/inittab,/etc/fstab,/ETC/INIT.D,/etc/x11,/etc/sysconfig,/etc/ Xinetd.d remember to back up before modifying the configuration file. Note:/etc/x11 stores settings related to x Windows.
/Home: The system Default User home directory, when adding user account, the user's home directory is stored in this directory, ~ represents the current user's home directory, ~test represents the user test home directory. It is recommended to separate partitions and set up a large disk space for user-friendly data storage
/lib:/usr/lib:/usr/local/lib: The system uses the library's directory, the program in the execution process, need to call some additional parameters when the function library to assist, compare the important directory for/lib/modules.
/lost+fount: When an error occurs, some missing fragments are placed in this directory, which is usually automatically located in the appliance directory. If the hard drive is loaded in/disk, the directory will be automatically generated in this directory/disk/lost+found
/mnt:/media: The CD default mount point, usually the disc is mounted under/mnt/cdrom, or not, you can choose any location to mount.
/opt: A directory for the host to install additional software. For example: The Fedora Community development software used by FC4, if you want to install new KDE desktop software yourself, you can install the software in this directory. In the previous Linux system, it is customary to place it in the/usr/local directory
/proc: This directory data are in memory, such as system core, external device, network status, because the data are stored in memory, so do not occupy disk space, the more important directory has/proc/cpuinfo,/proc/interrupts,/PROC/DMA,/proc/ Ioports,/proc/net/*, etc.
/root: The system administrator root home directory, the system first boot partition is/, so it is best to put/root and//placed under a partition.
/sbin:/usr/sbin:/usr/local/sbin: Place executable commands that the system administrator uses, such as Fdisk, Shutdown, Mount, and so on. Unlike/bin, these directories are commands for the root of the system administrator, and the average user can only "view" and not be set up and used.
/ tmp: The general user or the executing program temporarily holds the file directory, anyone can access, important data cannot be placed in this directory
/srv: The data directory that needs to be accessed after the service starts, such as the Web page data that the WWW service needs to store within/SRV/WWW
/ usr: Application storage directory,/usr/bin storage applications,/usr/share storage of shared data,/usr/lib storage can not be directly run, but many programs are necessary to run some library files. /usr/local: Store the software upgrade package. /usr/share/doc: System description file storage directory. /usr/share/man: Program Description file directory, the use of man LS will query/usr/share/man/man1/ls.1.gz content recommended separate partition, set a large disk space
/ var: Placing files that change frequently during the execution of the system, such as log files that change at any time/var/log,/var/log/message: All login Files directory,/var/spool/mail: Mail storage directory,/var/run: After the program or service starts, Its pid is stored in this directory. It is recommended to separate partitions to set large disk space
Specific directory structure reference: "Linux directory Structure"
File and Linux directory structure