美洲

  • 雷竞技比分

Unixstat命令给你比Is多

分析
9212014 6分钟
雷竞技电脑网站 IT领导 开源

厌倦命令并想查看更多有趣资料试stat

s命令可能是使用Unix学习的第一个命令之一,但它只显示小部分可用 stat命令的信息

stat命令从文件编解码提取信息如你所知 系统存取文件时 实际存有三组日期和时间包括文件上次修改日期(即使用Is-l命令时看到日期和时间)、文件最后一次修改时间(包括重命名文件)和文件最后一次访问时间

查看长列表文件后会看到类似的东西 :

$s-I tryth-rwx-

Stat命令使用后,你可以看到所有这一切:

Stat试文件: 109块块: 8IO块: 262144正则文件设备: 18h/24d Inode: 12731691链接:1存取:(0700/rwx------------)Uid:(263/sss)Gid:(100/unixdwebs)存取: 2014-09-0919:27:580000-0400

文件修改日期/时间相同,访问时间相当近可以看到文件使用8块,我们看到两种格式-八进制格式(0700格式)和rwx格式-均权限inode数显示输出第三行为12731681无附加硬链接(链路:1)。文件为正则文件

重命名文件并显示修改时间将更新Ctime信息原意保持文件创建日期和时间,但字段转成变换时间字段

$mv试试用$Stat试用文件:`Trys'大小: 109块: 8IO块: 262144正则文件设备: 18h/24d Inode: 12731691链接: 1存取:(0700/rwx---------)Uid:(263/shs)Gid:(100/unixdwebs): 2014-09-0919:27:580000-0400修改: 2013-1108:40:100000-0500

修改文件权限也将注册到ctime域

可同时使用 wilcard命令并分组列出文件stats

$ stat myfile*   File: `myfile'   Size: 20              Blocks: 8          IO Block: 262144 regular file Device: 18h/24d Inode: 12731803    Links: 1 Access: (0640/-rw-r-----)  Uid: (  263/     shs)   Gid: (  100/ unixdweebs) Access: 2014-08-23 03:00:36.000000000 -0400 Modify: 2014-08-22 12:02:12.000000000 -0400 Change: 2014-08-22 12:02:12.000000000 -0400   File: `myfile2'   Size: 20              Blocks: 8          IO Block: 262144 regular file Device: 18h/24d Inode: 12731806    Links: 1 Access: (0640/-rw-r-----)  Uid: (  263/     shs)   Gid: (  100/ unixdweebs) Access: 2014-08-23 03:00:36.000000000 -0400 Modify: 2014-08-22 12:03:30.000000000 -0400 Change: 2014-08-22 12:03:30.000000000 -0400   File: `myfile3'   Size: 40              Blocks: 8          IO Block: 262144 regular file Device: 18h/24d Inode: 12730533    Links: 1 Access: (0640/-rw-r-----)  Uid: (  263/     shs)   Gid: (  100/ unixdweebs) Access: 2014-08-23 03:00:36.000000000 -0400 Modify: 2014-08-22 12:03:59.000000000 -0400 Change: 2014-08-22 12:03:59.000000000 -0400

we can获取部分信息 并使用其他命令

长列表中添加u选项后,你就会看到类似的东西通知显示最后存取时间并加C显示更改时间

Unixdwebs 109919:27

stat命令也可以对目录工作在本案中,我们看到有数个链路

statbin文件: 12288块块: 24IO块: 262144目录设备: 18h/24dinode: 15089714链接9存取: (0700/drwx----------)

取文件系统

stat-f/dev/css/c0d0p2文件

注意Natelen(命名长度)域好运,如果你心置文件名超过255个字符

stat命令同时显示部分信息字段, 即您唯一想看到的时, 下示例中, 我们只想看到文件类型和硬链接数 。

$stat-formatQF试正则文件$stat-formQh试

下例中,我们查看权限-两种可用格式-并取文件Selinux安全上下文最后,我们查看文件存取时间表示自Epoch后秒

stat-format-a试700stat-form-A试-rwx-

可用选项包括所有下列内容:

%a     Access rights in octal %A     Access rights in human readable form %b     Number of blocks allocated (see %B) %B     The size in bytes of each block reported by %b %d     Device number in decimal %D     Device number in hex %f     Raw mode in hex %F     File type %g     Group ID of owner %G     Group name of owner %h     Number of hard links %i     Inode number %n     File name %N     Quoted file name with dereference if symbolic link %o     I/O block size %s     Total size, in bytes %t     Major device type in hex %T     Minor device type in hex %u     User ID of owner %U     User name of owner %x     Time of last access %X     Time of last access as seconds since Epoch %y     Time of last modification %Y     Time of last modification as seconds since Epoch %z     Time of last change %Z     Time of last change as seconds since Epoch

文件系统有效格式序列包括:

%a     Free blocks available to non-superuser %b     Total data blocks in file system %c     Total file nodes in file system %d     Free file nodes in file system %f     Free blocks in file system %C     Security context in SELinux %i     File System ID in hex %l     Maximum length of filenames %n     File name %s     Block size (for faster transfers) %S     Fundamental block size (for block counts) %t     Type in hex %T     Type in human readable form

有了所有这些信息, stat命令可能帮助你思考您的文件稍有不同

sandra_henrystocker

雷竞技投注下载Sandra Henry-Stocker管理Unix系统已有30多年Unix为第二语言), 并记得足够的英语写书并买菜住在弗吉尼亚山上 不和Unix合作或写Unix时

雷竞技投注下载Sandra Henry-Stocker表示的意见不一定代表IDG通信公司、其母子子公司或附属公司的意见