文件属性和类型

[[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文件属性和类型、系统链接文件、软链接和硬链接相关推荐

  1. Linux链接(软链接与硬链接)

    1.概述 软链接:softlink 软链接,symlink符号链接,类似于windows快捷方式,方便我们快速访问某个文件或目录,应用很广泛. 硬链接:hardlink , 在同一个磁盘分区中,ino ...

  2. centos7删除符号链接_面试 | Linux 下软链接和硬链接的区别

    在 Linux 系统中,一切都是文件,然而为了区分不同类型的事物,我们有了: 普通文件 目录文件 链接文件 设备文件 在之前的文章<阿里面试题 | Nginx 所使用的 epoll 模型是什么? ...

  3. linux 软链接_面试 | Linux 下软链接和硬链接的区别

    在 Linux 系统中,一切都是文件,然而为了区分不同类型的事物,我们有了: 普通文件 目录文件 链接文件 设备文件 在之前的文章<阿里面试题 | Nginx 所使用的 epoll 模型是什么? ...

  4. linux不允许将硬链接指向目录,linux 文件(目录)之软链接,硬链接 -

    前提必须清楚一点,当指向数据的文件个数为0 时,数据块就会被释放掉,硬链接相当于硬盘上一块数据的多个指针,而软链接相当于指向数据指针的指针.个人理解成下面的图例 左边的是硬链接,右边的是软链接,无论对 ...

  5. linux目录创立文件硬链接,在Linux中创建文件目录软链接、硬链接的方法

    1. 使用方式:ln [option] source_file dist_file -f 建立时,将同档案名删除 -i 删除前进行询问 -s 软链接,否则默认为硬链接 n -s abc cde 建立a ...

  6. cp 硬连接 linux,软链接、硬链接和引用链接,以及如何实现文件快速拷贝(cp --reflink)...

    Linux系统(包括Unix系统)有三种类型的链接文件:symlinks(符号链接.软连接),hardlinks(硬链接),reflinks(引用链接),其中软链接和硬链接比较常见. 首先来查看一个普 ...

  7. Linux 基础I/O :文件描述符,重定向,文件系统,软链接和硬链接,动态库和静态库

    文件描述符 重定向 文件系统 软链接和硬链接 动态库和静态库 文件描述符 上面两个接口分别是c语言的fread接口和linux的read接口,当我们在使用的时,可能会有疑问,为什么linux的io接口 ...

  8. linux文件软链接与硬链接

    1.命令格式: ln [参数][源文件或目录][目标文件或目录] 软链接只会在你选定的位置上生成一个文件的镜像,不会占用磁盘空间. 2.命令功能: Linux文件系统中,有所谓的链接(link),我们 ...

  9. linux给文件添加链接,Linux给文件或目录创建软链接或硬链接的方法

    有时linux用户们为了使用方便,会想给电脑中的文件或目录创建软链接或硬链接.不过有些用户不清楚该怎么给这些文件或目录创建软链接或硬链接该怎么办呢?别急,现在小编就来教你解决的方法. 解决方法: 当我 ...

最新文章

  1. vs添加码云远程_项目git步骤,将项目托管到码云。git本地分支推送到远程分支...
  2. hdu 1788 Chinese remainder theorem again 【crt的具体过程】
  3. 教小学妹学算法:诺基亚引出的动态规划问题
  4. leetcode 寻找两个有序数组的中位数
  5. Vue深入学习—虚拟DOM和Diff算法
  6. (笔记)学习C语言经典书籍推荐
  7. Python学习之==线程进程
  8. Error: Your project contains C++ files but it is not using a supported native build system
  9. facade(外观)模式
  10. Flask入门学习---进一步了解模板
  11. 乐高创意机器人moc_乐高MOC佳作欣赏丨机械之美机器人乐高作品集15
  12. MATLAB机器人工具箱2-机器人模型建立
  13. 我的世界租服务器怎么加组件,我的世界租赁服怎么加自己的mod
  14. python+adb游戏辅助脚本
  15. VB如何自动保存_发酵鱼饵与果酸、VB小药的搭配,这才是夏季钓大鱼的必杀配方!...
  16. jzoj. 1285. 奶酪厂
  17. springboot远程心电诊断系统毕业设计源码091759
  18. 物联网卡传感器赋能零售商品感应机制 开启智能零售新风尚
  19. C# MessageBox.Show 用法
  20. linux在终端安装软件包失败,使用Apt-get和Synaptic包管理器来纠正Debian上的依赖错误...

热门文章

  1. win7专业版64位,台式机睡眠和休眠后立即被唤醒
  2. The 'Microsoft Jet OLEDB 4.0 Provider' is not registered on the local machine
  3. struts文件异常Included file cannot be found
  4. 知乎专栏应用客户端源码项目
  5. Android中控件移动的实现
  6. Perl、PHP、Python、Java和Ruby的比较(来自知乎)
  7. 8工具来优化你的图像
  8. linux系统时区设置
  9. 交换机端口镜像(锐捷)
  10. nyoj99(欧拉路)