Linux的文件类型

1. 查看识别在某个目录下文件类型:

$ ls -ld <file name>

2. 文件可能的类型, 跟着不一样的后缀

1     – : regular file
2     d : directory
3     c : character device file
4     b : block device file
5     s : local socket file
6     p : named pipe
7     l : symbolic link

3. 对各个文件的解释: 来源>https://linuxconfig.org/identifying-file-types-in-linux

1) regular file

It governs different files such as .txt, images, binary files, shared files. create by touch,by using "ls" command "-"can be seen, which donates the identification code for the regular file, to remove a regular file use "rm".

2)Directory

1 mkdir <FileTypes>
2 
3 rmdir <FileTypes>

Note: when trying to remove directory with the rmdir command, which contains additional files you will get an error massage:

rmdir: failed to remove `<FileTypes>/': Directory not empty

In this case you need to use a command

1 $ rm -r <FileTypes>/

3)Character device and Block device

Character and block device allow users and programms to communicate with hardware peripheral devices.

1 $ ls -ld /dev/vmmon 
2 crw------- 1 root root 10, 165 Jan  4 10:13 /dev/vmmon#
3 
4 $ ls -ld /dev/sda
5 brw-rw---- 1 root disk 8, 0 Jan  4 10:12 /dev/sda

4) Symbolic Links

symbolic link can be thought of as a pointer to an original file, two types of symbolic links:

soft links and hard links.

The difference between them is that soft links use file name as reference and hard link use direct reference to the iriginal file. Furthermore, hard links cannot cross file system and partitions.

1 $ echo file1 > file1
2 $ ln -s file1 file2
3 $ cat file2 
 file1
5 $ ls -ld file2 
 lrwxrwxrwx 1 lubos lubos 5 Jan 10 14:42 file2 -> file1

to remove the symbolic

posted @ 2023-08-18 17:46  七块蛋糕  阅读(12)  评论(0编辑  收藏  举报