当前位置:首页 > linux
fsck -C -t ext3 /dev/hdb5
8)新建/mnt/hdb5目录,挂载/dev/hdb5分区 mkdir /mnt/hdb5
mount -t ext3 /dev/hdb5 /mnt/hdb5 9)将/dev/hdb5重新挂载,并加入ro mount -o remount,ro /dev/hdb5 10)将/mnt/hdb5卸载 umount /mnt/hdb5
11)将label为logical的分区挂载到/mnt/hdb5 mount -t ext3 -L \12)将/home目录挂载到/tmp/home上去 mkdir /tmp/home
mount --bind /home /tmp/home
13)将/dev/hdb6格式化为swap,并用swapon激活,用free查看,最后关闭/dev/hdb6的swap mkswap /dev/hdb6 free
swapon /dev/hdb6 free
swapoff /dev/hdb6 free
14)用dd建立交换文件,用swapon激活
dd if=/dev/zero of=/tmp/swap bs=4k count=16382 mkswap /tmp/swap swapon /tmp/swap
实验七 文件的压缩与打包
上机实验内容:
打开终端后在[root@localhost ~]#后面输入自己名字 1、把操作目录转到/tmp下
cd /tmp
复制/ect目录下的的/passwd文件到当前工作目录
cp /etc/passwd .
使用compress对其进压缩 如果提示有问题,找出问题所在
2、用gzip压缩/tmp中的/passwd文件,并设定压缩等级为1
gzip -1 passwd
解压缩该文件
gzip –d passwd.gz
用gzip压缩/tmp中的/passwd文件,并设定压缩等级为9
gzip -9 compress
查看压缩后的文件内容
zcat passwd.gz
解压缩该文件,并定向输出为passwd
gzip –cd passwd.gz>passwd
3、用bzip2压缩/tmp中的/passwd文件,并设定压缩等级为1
bzip2 -1 passwd
解压缩该文件
bzip2 –d passwd.bz2
用bzip2压缩/tmp中的/passwd文件,并设定压缩等级为9
bzip2 -9 passwd
查看压缩后的文件内容
bzcat passwd.bz2
解压缩该文件,并定向输出为passwd
bzip2 –cd passwd.bz2>passwd
4、把/etc内的文件打包之后存储到/tmp下
tar –cvf ./etc.tar /etc
把/etc内的文件打包并且用bzip2的方式压缩,之后存储到/tmp下
tar –jcvf ./etc.tar.bz2 /etc
把/etc内的文件打包并且用gzip的方式压缩,之后存储到/tmp下
tar –zcvf ./etc.tar.gz /etc 分别查看压缩后的文件中都包含哪些文 tar –tf etc.tar tar –tf etc.tar.bz2 tar –tf etc.tar.gz 解压缩第一个压缩文件
tar –xvf etc.tar
把第二个压缩文件解压缩到/tmp/etc1中
mkdir etc1
tar –jxvf etc.tar.bz2 –C ./etc1
把第三个压缩文件中的/passwd文件解压缩
tar –zxvf etc.tar.gz etc/passwd
备份/etc中的所有文件到/tmp中,并且保证权限不变 tar –cvpf ./etc.tar /etc
把/home中比2010.8.15新的文件备份到/tmp下面
tar -N ‘2010/08/15’ –cvf home.tar /home
把/etc和/root中的数据备份到/tmp下面,但是不备份/root下的install.log文件 tar --exclude /root/install.log -cvf myfile.tar /home/* /etc 5、使用dd指令备份硬盘had的mbr到/tmp中
dd if=/dev/hda of=/tmp/mbr.back bs=512 count=1
使用dd指令备份硬盘分区hda1到/tmp中
dd if=/dev/hda1 of=/tmp/hda1.back 6、综合指令练习:
i)在本机某个普通用户根目录下新建文件夹testdir
cd /home/user mkdir testdir
ii)进入testdir,创建文本文件firstfile,并在其中输入姓名和学号的全拼
cd testdir touch firstfile vi firstfile i
20087760206 杜秋野
iii)在testdir中创建文件firstfile的副本
cp firstfile firstfile2
iv)在testdir中创建文件firstfile的软硬链接文件
ln –s firstfile firstfile_s ln firstfile firstfile_h
v)进入testdir,将目录/home中所有在2010年10月1日后修改过的文件打包为mytar.tar.gz
共分享92篇相关文档