14.linux中设备的访问

####1.设备访问####
1.设备识别
/dev/xdxn  ##硬盘设备/dev/sda1
/dev/cdrom    ##光驱
/dev/mapper/*  ##虚拟设备
1-14. linux中设备的访问
2.设备的使用
##《设备的发现》##
fdisk -l    ##查看真实存在的设备
1-14. linux中设备的访问
cat /proc/partitions   ##系统能够识别的设备

1-14. linux中设备的访问
blkid    ##系统能够挂载使用的设备id


1-14. linux中设备的访问
df    ##查看设备被系统使用的情况

##《设备的使用》##
1.设备的挂载
mount    设备     挂载点
mount /dev/sdb1  /mnt  ##把系统中第二块硬盘的第一个分区挂载到/mnt目录上

1-14. linux中设备的访问

2.卸载设备
umout    设备|挂载点
如出现以下情况:
[[email protected] ~]# umount /dev/sdb1
umount: /home/kiosk/Desktop/photo: target is busy.
        (In some cases useful info aboutprocesses that use
         the device is found by lsof(8)or fuser(1))
解决:
fuser -kvm  设备|挂载点    ##-k kill ,-v显示详细信息,-m扫描设备

1-14. linux中设备的访问


1-14. linux中设备的访问
1-14. linux中设备的访问


####2.软硬链接###
ls -i   ##查看文件节点号

ls -l   ##查看文件信息没有节点号

ls -li file  ##查看文件节点号及其他信息1-14. linux中设备的访问

ln -s /file /file1   ##软链接

1-14. linux中设备的访问
ln /file /file1   ##硬链接

1-14. linux中设备的访问



####3.文件查找####
1.locate filename    ##在文件数据库中搜索filename信息

updatedb   ##更新文件数据库

1-14. linux中设备的访问
2.find

1-14. linux中设备的访问
1-14. linux中设备的访问
find 查找位置  -条件 条件值 -exec 动作 {} \;
     -name
     -not    条件
     -user
     -group
     -size

     -perm
     --maxdepth
     --mindepth
            -a   ##--and
            -o   ##--or
             -type   f   ##f-文件
                d   ##d-目录
                c  ##c-字符设备
                b  ##b-块设备
                s  ##s-套节字
                l  ##l-链接
例如:                
find /mnt -user student
find /mnt -group linux
find /mnt -user student -a -group linux
find /mnt -user student -o -group linux
find /mnt -user student -a -group linux
find /mnt -user student
find /mnt -user student -a -not -group linux

1-14. linux中设备的访问

1-14. linux中设备的访问

1-14. linux中设备的访问



1-14. linux中设备的访问
1-14. linux中设备的访问
dd if=/dev/zero of=/mnt/file1 bs=1024 count=10
dd if=/dev/zero of=/mnt/file2 bs=1024 count=20
dd if=/dev/zero of=/mnt/file3 bs=1024 count=30
1-14. linux中设备的访问
find /mnt -size 10k
find /mnt -size -10k
find /mnt -size +10k

1-14. linux中设备的访问