Linux File Type

Source: Internet
Author: User

1. Common files

For example, to determine the/user/bin/file and/bin/date file types, run the following command:

# File/user/bin/file/bin/date

2. Directory files

Note: file names starting with "." indicate hidden files, which can be listed using the LS command with the-A option.

3. Device Files

In Linux, all devices are treated as special files. The system uses them to represent the drives of various devices, and the kernel uses them to communicate with hardware devices.

An example of a device file is a terminal currently in use. The tty command can display the file name. For example:

# Tty

/Dev/pts/2

Usually, the device file is in the/dev directory.

4. link files

Linux has the function of naming multiple files as a link. The linked files can be stored in the same directory or different directories. the names in the same directory cannot be repeated. You only need to modify the file in a directory to modify the linked files in all directories.

1) hard link

When a hard link is created, a file is registered in multiple directories.

The ln command is used to create a link. By default, the ln command creates a hard link. The following restrictions apply to hard links:

I) The directory file cannot be hard linked.

Ii) hard links cannot be made between different file systems, that is, the linked file and the linked file must be located in the same file system.

2) Symbolic Link (soft link)

Unlike hard links, symbolic links are indeed a new file. There is no hard link restriction on symbolic links. You can do symbolic links to directory files, you can also use symbolic links between different file systems.

Use the Ln-s command for symbolic links. It is best to use absolute paths for source files.

Note the differences between symbolic links and source files or directories:

A) When deleting a source file or directory, only the data is deleted and the link is not deleted.

B) in the directory list, the symbolic link is displayed as a special file type. Its first letter is L.

C) The Symbolic Link size is the number of bytes in the path name of the linked file.

Ln command format:

Ln [Option] <Source File> [target file]

The-s command is used as a symbolic link instead of a hard link.

The linked object can be a file or a directory.

 

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.