Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

There are several kinds of files under Linux

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you there are several documents under Linux, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

We all know that everything under Linux is a file, mainly as follows:

-ordinary files

D directory

L symbolic link

S socket

B block equipment

C character device

P pipeline

These kinds of documents.

The prefix characters here can be observed through the ls command:

$ls-l test.log-rw-r--r-- 1 root root 33 Nov 17 17:03 test.log

Its result is preceded by -, so it's a normal file.

$ls-al / dev/null crw-rw-rw- 1 root root 1, 3 Sep 11 20:33 / dev/null

Its result is preceded by c, so it is a character device. The file briefly introduces several character device files, which can provide good help in our functional testing.

/ dev/null

/ dev/null can receive data indefinitely, so you can think of it as a black hole, so if we need to discard some terminal output, we can redirect it here:

$echo "shouwangxiansheng" > / dev/null

So if you have data you don't need, you can write it here.

/ dev/full

It will read a continuous stream of NUL (zero value) bytes when reading, and return the result of full disk space when writing, which will be helpful when testing your program, that is, when the disk is full:

$echo "bianchengzhuji" > / dev/full-bash: echo: write error: No space left on device

/ dev/zero

Similar to / dev/null, all data is discarded when written to it, but a stream of NUL (zero value) bytes is generated when read.

$cat / dev/zero | od-x 0000000 0000 0000 0000

/ dev/random

/ dev/random can provide random data flow, which ensures the randomness of the data, but causes waiting when reading, for example:

$cat / dev/random | od-x 0000000 2b07 daac 42f4 e1fd fb62 2098 870e e0af 0000020 3022 2099 e5da 4e1c d6db 548b a979 1217 0000040 3777 bb6a 957d 1279 ab29 e8a4 6a36 ecca 0000060 39ec 2285 126c 30ea ea67 1526 5e4a 2dd9

The data will appear after a while, and for ease of viewing, we use the od command to view its hexadecimal contents.

/ dev/urandom

As can be seen from the name, it is used to generate random data. Its generation speed is very fast, but the randomness of the data is not as good as / dev/random.

Cat / dev/urandom | od-x 0547560 f43e 696a 8936 2b27 36c8 4446 2802 1d47 0547600 b8af 249d aae9 edbf 8971 b1d1 0c73 3e2d 0547620 237b 9a81 6348 cb2a 1972 4486 028a 3573 0547640 1690 c388 64e1 aec1 d5f4 1964 bbb9 19f 0547660 f242 51ba 62a3 fc13 ff53 fb50 e3d8 0547700 ef32 3658b335 75ee 62de 409668c9790547720 01b9 c23878d 12fc 5cfa 5691 89e1 e1f9

/ dev/pts

/ dev/pts is the directory where the console device files created after remote login (telnet,ssh, etc.) are located. What's the use? For example, you open a terminal and get the current pts:

$tty / dev/pts/0

And then you open another one and type:

$echo "" > / dev/pts/0

You will find that the content has been printed to the previous terminal. Usually we run a program whose printf is printed on the current terminal.

The above is all the contents of the article "there are several documents under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report