linux 软硬文件类型,linux文件属性和类型、系统链接文件、软链接和硬链接
文件屬性和類型
[[email?protected] ~]# ll -d wzh
d rwxr-xr-x. 2 root root 6 Mar 26 06:27 wzh
目錄 ,權限 硬鏈接數 屬主 屬組 文件大小 創建修改時間文件名
-:普通?件
d:?錄?件
rw- --- --- :權限
rwx r-x r-x :權限
r:讀 read
w:寫 write
x:執?權限 execute
-:普通?件
d:directory ?錄?件
c:char 字符設備?件
b:block 塊設備?件(?來存儲數據的設備)
s:socket,安全套接字?件
l:link 軟鏈接?件(快捷?式)
p:pipe 管道?件
注意:通過顏?或者后綴判斷?件類型不?定準確.
系統鏈接文件
?個?件分為兩部分:
真實數據
元數據
block:真實數據占?的空間:19G
inode:元數據占?的空間 :9G
軟鏈接和硬鏈接
軟鏈接
軟鏈接相當于windows的快捷?式,軟鏈接?件會將 inode 指向源?件的 block
1.那么當我們對?個?件創建多個軟鏈接時,其實就是多個 inode 指向同?個 block 。 2.那么當我們
刪除軟鏈接?件時,其實只是刪除了?個 inode 的指向,并不會對源?件造成影響。 3.如果我們刪除的
是源?件,那么該?件的所有軟鏈接?件都會失效。
2.軟鏈接的應?場景 1)軟件升級 2)代碼發布 3)不?便移動的?錄 4)數據回滾 5)程序讀取
硬鏈接和源文件一樣,刪除了源文件軟鏈接可以操作
#1. 創建命令不同
硬鏈接: ln
軟鏈接: ln -s
#2. ?錄?法創建硬鏈接,可以創建軟鏈接,硬鏈接不能跨系統的分區,軟鏈接可以
#3. 硬鏈接?件與源?件的inode號相同,軟鏈接不同
#4. 軟鏈接如果刪除源?件,所有軟鏈接?件失效,硬鏈接如果刪除源?件,其他硬鏈接?件均可以
硬鏈接:[[email?protected] ~]# ll -i /tmp/ys
33605428 -rw-r--r--. 2 root root 0 Mar 26 06:43 /tmp/ys
[[email?protected] ~]# ll -i 123
33605428 -rw-r--r--. 2 root root 0 Mar 26 06:43 123
軟鏈接
[[email?protected] ~]# ll -i /opt/w
17354516 lrwxrwxrwx. 1 root root 9 Mar 26 06:52 /opt/w -> /root/wyf
[[email?protected] ~]# ll -i wyf
total 0
[[email?protected] ~]# ll -hi wyf
total 0
[[email?protected] ~]# ll -d wyf
drwxr-xr-x. 2 root root 6 Mar 26 06:52 wyf
[[email?protected] ~]# ll -di wyf
793418 drwxr-xr-x. 2 root root 6 Mar 26 06:52 wyf
[[email?protected] ~]# dd if=/dev/zero of=/opt/disk bs=1K count=1024
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 0.00343602 s, 305 MB/s
[[email?protected] ~]# mkfs.ext4 -i 1024 /opt/disk
mke2fs 1.42.9 (28-Dec-2013)
/opt/disk is not a block special device.
Proceed anyway? (y,n) y
Filesystem too small for a journal
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
1024 inodes, 1024 blocks
51 blocks (4.98%) reserved for the super user
First data block=1
Maximum filesystem blocks=1048576
1 block group
8192 blocks per group, 8192 fragments per group
1024 inodes per group
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
[[email?protected] opt]# mkdir data1
[[email?protected] opt]# mount -t ext4 -o loop /opt/disk /data1
[[email?protected] data1]# touch {1000..10000}
touch: cannot touch ‘9963’: No space left on device
touch: cannot touch ‘9964’: No space left on device
touch: cannot touch ‘9965’: No space left on device
touch: cannot touch ‘9966’: No space left on device
touch: cannot touch ‘9967’: No space left on device
touch: cannot touch ‘9968’: No space left on device
touch: cannot touch ‘9969’: No space left on device
touch: cannot touch ‘9970’: No space left on device
touch: cannot touch ‘9971’: No space left on device
touch: cannot touch ‘9972’: No space left on device
touch: cannot touch ‘9973’: No space left on device
touch: cannot touch ‘9974’: No space left on device
touch: cannot touch ‘9975’: No space left on device
touch: cannot touch ‘9976’: No space left on device
touch: cannot touch ‘9977’: No space left on device
touch: cannot touch ‘9978’: No space left on device
touch: cannot touch ‘9979’: No space left on device
touch: cannot touch ‘9980’: No space left on device
touch: cannot touch ‘9981’: No space left on device
touch: cannot touch ‘9982’: No space left on device
touch: cannot touch ‘9983’: No space left on device
touch: cannot touch ‘9984’: No space left on device
touch: cannot touch ‘9985’: No space left on device
touch: cannot touch ‘9986’: No space left on device
touch: cannot touch ‘9987’: No space left on device
touch: cannot touch ‘9988’: No space left on device
touch: cannot touch ‘9989’: No space left on device
touch: cannot touch ‘9990’: No space left on device
touch: cannot touch ‘9991’: No space left on device
touch: cannot touch ‘9992’: No space left on device
touch: cannot touch ‘9993’: No space left on device
touch: cannot touch ‘9994’: No space left on device
touch: cannot touch ‘9995’: No space left on device
touch: cannot touch ‘9996’: No space left on device
touch: cannot touch ‘9997’: No space left on device
touch: cannot touch ‘9998’: No space left on device
touch: cannot touch ‘9999’: No space left on device
touch: cannot touch ‘10000’: No space left on device
出現這種情況查看磁盤
[[email?protected] data1]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 18G 1.5G 17G 8% /
devtmpfs 476M 0 476M 0% /dev
tmpfs 487M 0 487M 0% /dev/shm
tmpfs 487M 7.7M 479M 2% /run
tmpfs 487M 0 487M 0% /sys/fs/cgroup
/dev/sda1 1014M 127M 888M 13% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/loop0 891K 40K 780K 5% /data1
發現磁盤沒滿,再查看inode
[[email?protected] data1]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda3 9436672 122444 9314228 2% /
devtmpfs 121774 385 121389 1% /dev
tmpfs 124487 1 124486 1% /dev/shm
tmpfs 124487 719 123768 1% /run
tmpfs 124487 16 124471 1% /sys/fs/cgroup
/dev/sda1 524288 326 523962 1% /boot
tmpfs 124487 1 124486 1% /run/user/0
/dev/loop0 1024 1024 0 100% /data1
原來是data1的inode滿了
刪除沒用的空文件
找出占用最多的
[[email?protected] data1]# for i in /*; do echo $i; find $i | wc -l; done
/bin
1
/boot
324
/data1
1015
/dev
387
/etc
2379
/home
22
/lib
1
/lib64
1
/media
1
/mnt
1
/oldboy
42
/oldgirl
34
/opt
90004
/proc
33457
/root
9
/run
719
/sbin
1
/srv
1
/sys
48492
/tmp
19
/usr
29579
/var
4381
/wzhh
12
繼續尋找opt下的
[[email?protected] data1]# for i in /opt/*; do echo $i; find $i | wc -l; done
/opt/data1
90002
/opt/disk
1
刪除opt下大小為0的文件
[[email?protected] data1]# find /opt/* -name "*" -type f -size 0c | xargs -n 1 rm -f
[[email?protected] data1]# ll /opt
total 240
drwxr-xr-x. 2 root root 6 Mar 26 06:20 data1
-rw-r--r--. 1 root root 1048576 Mar 26 06:01 disk
再看下
[[email?protected] data1]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda3 9436672 32443 9404229 1% /
devtmpfs 121774 385 121389 1% /dev
tmpfs 124487 1 124486 1% /dev/shm
tmpfs 124487 719 123768 1% /run
tmpfs 124487 16 124471 1% /sys/fs/cgroup
/dev/sda1 524288 326 523962 1% /boot
tmpfs 124487 1 124486 1% /run/user/0
/dev/loop0 1024 1024 0 100% /data1
發現還是滿的,那就刪除data1下大小為0的文件
[[email?protected] data1]# find /data1/* -name "*" -type f -size 0c | xargs -n 1 rm -f
[[email?protected] data1]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda3 9436672 32443 9404229 1% /
devtmpfs 121774 385 121389 1% /dev
tmpfs 124487 1 124486 1% /dev/shm
tmpfs 124487 719 123768 1% /run
tmpfs 124487 16 124471 1% /sys/fs/cgroup
/dev/sda1 524288 326 523962 1% /boot
tmpfs 124487 1 124486 1% /run/user/0
/dev/loop0 1024 11 1013 2% /data1
這樣就好了
原文:https://www.cnblogs.com/zabcd/p/13289356.html
總結
以上是生活随笔為你收集整理的linux 软硬文件类型,linux文件属性和类型、系统链接文件、软链接和硬链接的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux配置apache tomcat
- 下一篇: 十句保你职场不败的名言