02. Learning Notes-linux common file types

Source: Internet
Author: User

Common types of Linux files are: Normal file (-), directory (d), character device file (c), block device file (b), Symbolic link file (l), etc. it is important to note that the Linux file types and the file names of Linux files represent two different concepts. We create through general applications such as File.txt, file.tar.gz, these files, although to be opened with different programs, but in the Linux file type measurement, mostly regular files (also known as ordinary files).

1 Common Files

[Email protected] ~]# LS-LH Install.log

-rw-r--r--1 root root 53K 03-16 08:54 Install.log

We use LS-LH to see the properties of a file, we can see similar-rw-r--r--, it is worth noting that the first symbol is-, such a file in Linux is a normal file. These files are typically created with some related applications, like tools, document tools, archive tools .... or CP tools. This type of file is deleted using the RM command;

2 Catalog

[Email protected] ~]# LS-LH

Total 14M

-rw-r--r--1 root root 2 03-27 02:00 Fonts.scale

-rw-r--r--1 root root 53K 03-16 08:54 Install.log

-rw-r--r--1 root root 14M 03-16 07:53 kernel-2.6.15-1.2025_fc5.i686.rpm

Drwxr-xr-x 2 users 4.0K 04-04 23:30 mkuml-2004.07.17

Drwxr-xr-x 2 root root 4.0K 04-19 10:53 Mydir

Drwxr-xr-x 2 root root 4.0K 03-17 04:25 public

When we execute in a directory, see similar drwxr-xr-x, such files are directories, directories in Linux is a more special file. Note that its first character is d. The command to create a directory can be used with the mkdir command, or the CP command, where CP can copy a directory to another directory. Remove the RM or RMDIR command.

3 character device or block device file

If you enter the/dev directory, list the files, you will see similar to the following;

[Email protected] ~]# Ls-la/dev/tty

Crw-rw-rw-1 Root TTY 5, 0 04-19 08:29/dev/tty

[Email protected] ~]# ls-la/dev/hda1

Brw-r-----1 Root Disk 3, 1 2006-04-19/dev/hda1

We see that the/dev/tty property is crw-rw-rw-, note that the first character in front is C, which represents the character device file. such as the cat and other serial devices

We see that the/dev/hda1 property is brw-r-----, note that the first character in front is B, which indicates a block device, such as a hard disk, an optical drive, and other devices;

This kind of file is created with Mknode and deleted with RM. Currently in the latest Linux distributions, we generally do not have to create the device files ourselves. Because these files are associated with the kernel.

4 sets of interface files

When we start the MySQL server, a mysql.sock file is generated.

[Email protected] ~]# Ls-lh/var/lib/mysql/mysql.sock

srwxrwxrwx 1 mysql mysql 0 04-19 11:12/var/lib/mysql/mysql.sock

Note that the first character of the property of this file is S. This is the type of socket file that is rarely seen in general.

5 Symbolic Link File

[Email protected] ~]# LS-LH Setup.log

lrwxrwxrwx 1 root root one 04-19 11:18 setup.log install.log

When we look at the properties of a file, we see something like lrwxrwxrwx, note that the first character is L, and this type of file is a linked file. is the new file name by ln-s the source file name. Above is an example that indicates that Setup.log is a soft link file for Install.log.


02. Learning Notes-linux common file types

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.