Abstract
Quote
Linux Kernel is file based but Windows is API based.
This just means that in Linux which follows POSIX, we can use the same file Library Call on Block Special Files, Character Special Files, Socket, Pipe (管道), File System Link & File Directory besides the regular files, where Windows has an separate Windowa API for each of them.
-
Hide the nitty gritty of IO Device, so users can focus on manipulating the content inside the IO Device
-
Present programmer a clean Abstraction of device-independent file
-
Files are stored in the form of blocks of bytes
-
2 parts - Filename & Inode Number, doesn’t have any metadata associated
Create a dummy file with a specified size
This could be useful for testing the Network Throughput.
File Descriptor
- A small Integer (整数) associated with File
File Permission
- In POSIX, file permissions are handled by rwx bits
Special File
- An Linux Kernel concept - make IO Device look like File, so we can reuse the same set of file System Call (系统调用) on IO Devices
- By convention, kept in the
/dev
Block Special Files
- Model IO Device that has a collection of randomly addressable blocks like like Flash Memory
Character Special Files
- Model IO Device that accept or output a character stream like keyboard
Line Break in File
- POSIX systems uses a single character called Line Feed
\n
- While Windows uses carriage return and Line Feed, so 2 characters
\r\n
. This is because during typewriter times, you needed to mov the carriage to restart typing on the beginning of a line first, then turn the wheel to move the paper to change the line
Hands-On!
Useful CLi Tools
bat
- A cat clone with wings.
dua
- Manage files fast, powered by rust!
xcp
- cp on tren!
xxd
- Generate a hexdump from a binary file and display the output