1. File types
| - |
Normal file |
| D |
Catalog files |
| L |
Link file |
| B |
Block device files |
| C |
Character-type device files |
| S |
Socket file |
| P |
Pipe type File |
Block device files mainly refers to slow devices, such as HD hard disk, the data is mainly block storage, so is a block device, in Linux, the device will be abstracted into a file, such as hard disk:
BRW-RW----1Root disk8,0January - -: -SDABRW-RW----1Root disk8,1January - -: -SDA1BRW-RW----1Root disk8,2January - -: -SDA2BRW-RW----1Root disk8,5January - -: -SDA5BRW-RW----+1Root CDROM One,0January - -: -Sr0
SDA refers to the entire hard drive, my computer has only one hard disk, if there is a second hard disk, it will be abstracted as SDB
SDA1 refers to a partition of a hard disk
So since the hard disk is a file, can I write to the file? Must be possible, but do not try, this will damage the entire hard disk data, do not believe you try, I dare not:
cat /etc/passwd >/dev/sda #千万别执行
That in Windows can use Ghost to mirror the hard disk, that in Linux do not need to use other tools, first hanging on a hard disk to the/MNT directory
#DDif=/dev/sda of=/mnt/sda.img
You can mirror the entire hard drive with just one command. If I only wanted to mirror one of the partitions, that IF=/DEV/SDA1 would be fine.
2. Permissions
# ll Total dosage -drwx------2Root root4096February - A: A./drwxr-xr-x atRoot root4096January - -: -.. /-rw-r--r--1Root root3106February - the. BASHRC-rw-r--r--1Root root $February - the. profile-RW-------1Root root626February - A: A. viminfo
When we use the LL name to view the file directory, the previous rwx------These are the permissions to represent the file, so what does it mean?
|
corresponding numbers |
Permissions |
| R |
4 |
Read |
| W |
2 |
Write |
| X |
1 |
Perform |
The first one is D, some--what does that mean?
D indicates that this is a directory file
-Indicates that this is an ordinary file, do you remember the type of file that was first mentioned?
The next nine characters represent the permissions for the file or directory:
Top three: Permissions for file owners
Intermediate three-bit: file has permissions for group
Post three: Other people's permissions
The 1 after the permission represents the number of links, then the owner, owning group, file size, modification time, file name
In general, Linux file Permissions 644, folder permissions 755
3. Permissions Modification
chmod u+x file name #u表示拥有者 G means that the owning group O means that other User a represents all
CHOMD g-x file name
chmod a=rw File name # +,-, =
chmod 644 filename #使用数字方式修改权限, most commonly used, most flexible
If you want to set permissions for all files in the directory and directory, use the-R parameter
Chomd–r 644 Catalogue
Chown Modify owner, can also add-r parameter
CHGRP Modify the owning group, you can also add the-R parameter
So here's the problem: chmod 046 A modifies permissions for file A, what permissions does the owner have on a?
A look at the top three, no permissions, then there is no permission. Permissions are not superimposed.
4. Number of connections
The number of connections is what a ghost. This starts with how the data is stored on the hard disk:
First, the directory file is stored with the a.jpg and inode number, and then through the inode to find the corresponding block, the file content is found. On the figure a.jpg and B.jpg point to the same inode, that a.jpg and b.jpg are actually the same file, only occupy a portion of storage space, so the number of connections should be 2.
If A.jpg is an empty file, does it still have an inode? Do you still occupy block?
Empty files also have file information, such as permissions Ah, create time AH what, this information is stored in the inode, so empty files still have inode, but no content, so do not occupy block.
So if I delete a.jpg, is that b.jpg still there? Still, deleting a.jpg actually deletes the correspondence between the a.jpg and the inode, but b.jpg can still access it. This is the hard connection, ln a.jpg b.jpg If this picture is beautiful pictures, very good-looking, do not want to be deleted by others, then you can do a hard connection, in other places do an entrance, others delete one, there are other entrances can be accessed. However, it is important to note that hard connections cannot span partitions.
If you want to cross-partition, you can use a soft connection, which is a completely new file, equivalent to a shortcut in Windows.
Stat file name to see what's in the inode.
Linux file properties