inode

Link to a specific inode

家住魔仙堡 提交于 2019-12-18 04:53:07
问题 I have a file that was deleted, but is still held open my a program. I found the inode number using lsof. How can I create a hard link back to that inode? Any code helps, but Perl would be handy. 回答1: Copy from /proc/ pid /fd/ file descriptor Use lsof to find the pid and the file descriptor. 回答2: on EXT filesystem you can use debugfs command to recreate the link like : debugfs -w /dev/mapper/vg0-root -R 'link <16> myfile' Which will create a "file" named myfile and pointing to inode 16. 来源:

Get last access time of the file?

孤街醉人 提交于 2019-12-18 04:52:48
问题 I want to get when the file accessed last time, I tried following code: import os, time os.system("python test.py") print os.stat('test.py').st_atime time.sleep(60) os.system("python test.py") print os.stat('test.py').st_atime But each time the output is same as follows : 1358489344.72 1358489344.72 I was expecting a difference in output before delay and after delay. also output is same wen I run the code every time. what could be wrong? 回答1: The field st_atime is changed by file accesses,

What is there behind a symbolic link?

拈花ヽ惹草 提交于 2019-12-18 03:06:09
问题 How are symbolic links managed internally by UNIX/Linux systems. It is known that a symbolic link may exist even without an actual target file (Dangling link). So what is that which represents a symbolic link internally. In Windows, the answer is a reparse point . Questions: Is the answer an inode in UNIX/Linux? If yes, then will the inode number be same for target and links? If yes, can the link inode can have permissions different from that of target's inode (if one exists)? 回答1: It is not

Where are all my inodes being used?

北慕城南 提交于 2019-12-17 21:39:58
问题 How do I find out which directories are responsible for chewing up all my inodes? Ultimately the root directory will be responsible for the largest number of inodes, so I'm not sure exactly what sort of answer I want.. Basically, I'm running out of available inodes and need to find a unneeded directory to cull. Thanks, and sorry for the vague question. 回答1: So basically you're looking for which directories have a lot of files? Here's a first stab at it: find . -type d -print0 | xargs -0 -n1

linux ls -l 详解

大城市里の小女人 提交于 2019-12-17 21:07:07
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 转自 http://hi.baidu.com/yzzcheng/item/1a2141878447891dc31627f5 以root的家目录为例: 可以看到,用ls -l 命令查看某一个目录会得到一个7个字段的列表。 第1行:总计(total) Total后面的数字是指当前目录下所有文件所占用的空间总和。可以使用ls –lh查看,也可使用ls –alh查看。 第1字段: 文件属性字段 - rw-r--r-- 1 root root 762 07-29 18:19 exit 文件属性字段总共有10个字母组成;第一个字符代表 文件的类型 。 字母 “-” 表示该文件是一个普通文件 字母 “d” 表示该文件是一个目录,字母"d",是dirtectory(目录)的缩写 注意: 目录或者是特殊文件,这个特殊文件存放其他文件或目录的相关信息 字母 “l” 表示该文件是一个链接文件。字母"l"是link(链接)的缩写,类似于windows下的快捷方式 字母 “b” 的 表示块设备文件(block),一般置于/dev目录下,设备文件是普通文件和程序访问硬件设备的入口,是很特殊的文件。没有文件大小,只有一个主设备号 和一个辅设备号。一次传输数据为一整块的被称为块设备,如硬盘、光盘等。最小数据传输单位为一个数据块

How to Free Inode Usage?

﹥>﹥吖頭↗ 提交于 2019-12-17 06:19:29
问题 I have a disk drive where the inode usage is 100% (using df -i command). However after deleting files substantially, the usage remains 100%. What's the correct way to do it then? How is it possible that a disk drive with less disk space usage can have higher Inode usage than disk drive with higher disk space usage? Is it possible if i zip lot of files would that reduce the used inode count? 回答1: It's quite easy for a disk to have a large number of inodes used even if the disk is not very full

文件系统的简单操作

隐身守侯 提交于 2019-12-16 13:16:35
(整理自《鸟哥的Linux私房菜》书籍) 1. 磁盘与目录的容量 • df:列出文件系统的整体磁盘使用量; • du:评估文件系统的磁盘使用量(常用在推估目录所占容量) 2. 实体链接与符号链接: ln 在 Linux 底下的链接文件有两种,一种是类似 Windows 的快捷方式功能的文件,可以让你快速的链接到目标文件(或目录); 另一种则是透过文件系统的 inode 连结来产生新档名,而不是产生新文件!这种称为实体链接 (hard link)。 § Hard Link ( 硬链接) 硬链接只是在某个目录下新增一个文件链接到某 inode 号码的关连记录而已。 举个例子来说,假设我系统有个 /root/crontab 他是 /etc/crontab 的实体链接,也就是说这两个档名连结到同一个 inode , 自然这两个文件名的所有相关信息都会一模一样(除了文件名之外)。实际的情况可以如下所示: 你可以发现两个档名都连结到 34474855 这个 inode 号码,是否文件的权限/属性完全一样呢? 一样的,因为这两个文件名其实指向的是一模一样的文件。而且你也会发现第二个字段由原本的 1 变成 2 了! 那个字段称为链接,这个字段的意义为:『有多少个档名链接到这个 inode 号码』的意思。 如果将读取到正确数据的方式画成示意图,就类似如下画面: 上图的意思是,你可以透过 1 或 2

Linux的文件系统

旧街凉风 提交于 2019-12-16 10:57:38
  linux文件系统支持多种不同的文件系统。如ext,ext2,ext3,ext4之类的文件系统.   linux引入了虚拟文件系统VFS,屏蔽了各种文件系统的差别,为处理各种不同的文件系统提供了 统一的接口。 一 Linux的文件系统的结构   linux的文件系统是树形结构的。   /表示根目录,.当前目录,..上级目录,../..上上级这些就不用说了    需要注意的是   linux文件系统区分大小写,而且linux的文件没有扩展名的概念,也就是说 扩展名和文件类型无关。   目录大致就这样 2 Linux的inode   显然linux的目录也是一个文件。    linux对于文件的管理方法和Unix相同,文件名和文件控制信息分开管理。    inode实质上是系统管理的目录项,每个文件对应一个inode,每个inode有唯一的编号,叫做 inode号。    故而Linux的目录项由文件名和inode号两部分组成。    3 linux的文件类型    使用file命令识别文件类型 4 linux的文件访问权限 5 Linux的虚拟文件系统 来源: https://www.cnblogs.com/theda/p/12044172.html

20175202 Mypwd的学习和实现

痞子三分冷 提交于 2019-12-15 21:16:21
一、学习 pwd 命令: 1. pwd 命令的功能: Linux pwd 命令用于显示工作目录。 执行 pwd 指令可立刻得知您目前所在的工作目录的绝对路径名称。 2.参数: -L:--logical,显示当前的路径,有连接文件时,直接显示连接文件的路径,(不加参数时默认此方式),参考示例1。 -p:--physical,显示当前的路径,有连接文件时,不使用连接路径,直接显示连接文件所指向的文件,参考示例2。 当包含多层连接文件时,显示连接文件最终指向的文件,参考示例3。 --help:显示帮助信息。 --version:显示版本信息。 3.通过 man -k pwd 命令查找; 4.通过 man -k directory | grep 3 命令查找库函数; 发现 readdir , opendir 以及 getcwd 。 5.通过 man 3 readdir 查找相应结构体; 6.通过 man 2 readlink 命令查看帮助文档; 如图可以找到例子,下面我们根据例子编写代码,来实现 pwd 。 二、实现和测试 pwd : 1.实现 pwd 的代码: #include<stdio.h> #include<sys/stat.h> #include<dirent.h> #include<stdlib.h> #include<string.h> #include<sys/types

Linux文件管理

家住魔仙堡 提交于 2019-12-15 19:59:25
           1 文件系统目录结构 1.1 文件系统的目录结构   文件和目录被组织成一个单根倒置树结构   文件系统从根目录下开始,用“/”表示   根文件系统(rootfs):root filesystem   标准Linux文件系统(如ext4),文件名称大小写敏感,例如:MAIL, Mail, mail, mAiL   以.开头的文件为隐藏文件   路径分隔的 /   文件名最长255个字节   包括路径在内文件名称最长4095个字节   蓝色-->目录 绿色-->可执行文件 红色-->压缩文件 浅蓝色-->链接文件 灰色-->其他文件   除了斜杠和NUL,所有字符都有效.但使用特殊字符的目录名和文件不推荐使用,有些字符需要用引号来引用   每个文件都有两类相关数据:     元数据:metadata     数据:data Linux的文件系统分层结构:FHS Filesystem Hierarchy Standard 参考文档:http://www.pathname.com/fhs/ 1.2 常见的文件系统目录功能   /boot:引导文件存放目录,内核文件(vmlinuz)、引导加载器(bootloader, grub)都存放于此目录   /bin:所有用户使用的基本命令;不能关联至独立分区,OS启动即会用到的程序   /sbin:管理类的基本命令