LInux第四章

find 查找文件命令

--|find /dev -type d -print      将dev下面所有类型是文件夹的东西显示出来
--|find /dev -type b -print      查找块设备文件

--|find /etc -name "passwd*"        查找以passwd开头的文件

--|find /etc -name "passwd" -exec ls -l {} \;        查找文件passwd开头的,以列表详细信息形式显示出来。

--|find /etc -size +10000k -ok ls -l {} \;            查找大于1WK 的文件

实例:

[root@f102 cuser]# find /etc -size +1000k -ok ls -l {} \;
< ls ... /etc/selinux/targeted/policy/policy.24 > ? y
-rw-r--r--. 1 root root 5820086  7月 14 2011 /etc/selinux/targeted/policy/policy.24

--|find /root -perm 644 -exec ls -l {} \;         按照用户的权限查找文件

-rw-r--r--. 1 root root 129 12月  4 2004 /root/.tcsh

解释:644

读写执行

rw-   头三位,权限是110 。数字6
有权限就是1 ,没有权限的就是0,每三位转换为二进制,

r-- 代表4.。。。。。

查询指定文件拥有者文件

[root@f102 cuser]# find /home -user root              
/home
/home/cuser/100
/home/cuser/a
/home/cuser/a~

[root@f102 cuser]# find /home -user root -exec ls -l {} \;
总用量 24
drwx------. 34 cuser cuser 4096  5月 30 00:01 cuser
drwx------.  4 stu1  users 4096 10月 12 2011 stu1
drwx------.  4 stu11 stu11 4096 10月 19 2011 stu11
drwx------.  4 stu12 stu12 4096 10月 19 2011 stu12
drwx------. 27 stu13 stu13 4096 10月 19 2011 stu13
drwx------.  4 stu14 stu14 4096 10月 19 2011 stu14
-rw-r--r--. 1 root root 6 11月  2 2011 /home/cuser/100
-rw-r--r--. 1 root root 37 10月 26 2011 /home/cuser/a
-rw-r--r--. 1 root root 37 10月 26 2011 /home/cuser/a~


七天之内修改过的日志文件

[root@f102 cuser]# find /var/log -mtime 7 -exec ls -l {} \;
七天之内没有修改过的日志文件
[root@f102 cuser]# find /var/log -mtime +7 -exec ls -l {} \;
总用量 4
drwx------. 2 root root 4096  8月 24 2010 old

按照已知文件为标准,查找新的文件或者老的文件
查找比1新的文件

[root@f102 cuser]# find /home/cuser -newer /home/cuser/1
/home/cuser
/home/cuser/.xsession-errors
/home/cuser/2
/home/cuser/.local/share/gvfs-metadata
/home/cuser/.local/share/gvfs-metadata/root-30cf838a.log
/home/cuser/.local/share/gvfs-metadata/home-cedbf307.log

查看分区情况  这些信息存在在 proc /partitons 下面

[root@f102 cuser]# fdisk -l

Disk /dev/sda: 317.9 GB, 317891895808 bytes
255 heads, 63 sectors/track, 38648 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf0b1ebb0

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        7770       11979    33816793+  83  Linux
/dev/sda2           31675       35522    30909060    5  Extended
/dev/sda5           31675       32209     4297356   82  Linux swap / Solaris
/dev/sda6           32210       33483    10233373+   c  W95 FAT32 (LBA)

63个扇区。38648

sda

sd 串口,a 第一个口。b 第二个口

小于4的分区不可以让逻辑分区占用


分区调整

[root@f102 cuser]# fdisk -h

Usage:
 fdisk [options] <disk>    change partition table
 fdisk [options] -l <disk> list partition table(s)
 fdisk -s <partition>      give partition size(s) in blocks

Options:
 -b <size>                 sector size (512, 1024, 2048 or 4096)
 -c                        switch off DOS-compatible mode
 -h                        print help
 -u <size>                 give sizes in sectors instead of cylinders
 -v                        print version
 -C <number>               specify the number of cylinders
 -H <number>               specify the number of heads
 -S <number>               specify the number of sectors per track


挂载分区

[root@f102 cuser]# mount -t vfat /dev/sda6 /mnt/c 

编辑 /etc/fstab可以编辑挂在分区配置文件


/dev/sda6		/mnt/c			vfat	defaults	0 0
添加一行。可以在重启之后直接挂载上去


猜你喜欢

转载自blog.csdn.net/zhangkaixu321/article/details/8989875