(1)为了更好的传送和保存文件,需要对某些文件和目录进行压缩和解压缩操作,Linux

提供了强大的压缩、解压缩命令,常用的tar命令。

(2)在Linux中,如果要使用储存设备(硬盘、光驱、移动存储等),必须先将设备挂

载上,当设备挂载上之后,就可以把它当成一个目录来进行访问。挂载设备使用mount命

令。

在使用挂载命令mount前,首先要知道要挂载对象的文件系统类型(File System Type)、

要挂载对象的设备名称和要将设备挂载到什么目录这三种信息。

获得系统支持的文件系统类型,使用如下命令:

[root@lab root]# cat /proc/filesystems

如果系统并不支持要挂载设备的文件系统类型,那可能需要重新编译内核以使其增加对

该种文件类型支持。

常用的文件系统有:

①ext3:Linux的文件系统

②ext2:Linux的文件系统

③vfat:Windows的F AT32文件系统,也兼容F AT16的文件系统类型

④ntfs:Windows文件系统。

⑤hpfs:OS2用的文件系统。

⑥iso9660:CD-ROM光盘的标准文件系统。

(2)确定设备的名称

在Linux操作系统中,设备文件通常都在/dev 目录里。可以直接检查/var/log/messages

这个文件,在该文件中可以找到计算机开机后系统已辨认出来的设备代号。

[root@labroot]# cat /var/log/messages

(3)查找挂载点

挂载前,要决定将设备挂载到哪里。系统的/mnt目录就是专门用来当作挂载点(Mount

Point)的目录。建议在/mnt 目录里建这几个目录:/mnt/cdrom、/mnt/floppy、/mnt/mo 等来

当作目录的专用挂载点。如果有特殊要求,可根据实际情况确定挂载点。

需要注意的是:执行mount动作时先执行一下pwd看看现在的目录是不是在挂载点,

如果现在目录在挂载点的话,mount不会成功(会显示device busy)。

(1) 压缩、解压缩命令

在/root目录下建立新目录student

[root@lab root]# mkdir student

进入student目录

[root@lab root]# cd student

在student目录下建立目录stu1、stu2,文件test1、test2

[root@lab student]# mkdir stu1

[root@lab student]# mkdir stu2

[root@lab student]# touch test1

[root@lab student]# touch test2

回到/root目录下,并查看目录下文件

[root@lab student]# cd ..

[root@lab root]# ls

把/root/student目录下文件和子目录打包,打包文件名为student.tar。

[root@lab root]# tar cvf student.tar /root/student

查看student.tar 打包文件的内容。

[root@labroot]# tar tvf student.tar

把/root/student目录下的文件和子目录打包,并进行压缩,文件名为student2.tar.gz。

[root@lab root]# tar zcvf student2.tar.gz student/

查看目录下文件

[root@labroot]# ls

删除student目录

[root@labroot]# rm -fr student

把student2.tar.gz这个打包文件还原并解压缩。

[root@lab root]# tar xzvf student2.tar.gz

查看目录下文件

[root@labroot]# ls

删除文件student.tar、student2.tar.gz和解压出的目录student

[root@labroot]# rm -fr student.tar

[root@labroot]# rm -fr student2.tar.gz

[root@labroot]# rm –frstudent

(2) 挂载命令

获得系统支持的文件系统类型:

[root@lab root]# cat /proc/filesystems

确定设备的名称:

[root@labroot]# cat /var/log/messages

挂载fat32的分区:

[root@labroot]# mount -o codepage=936,iocharset=cp936 /dev/hda7 /mnt/cdrom

或者使用

[root@labroot]# mount -t vfat -o iocharset=cp936 /dev/hda7 /mnt/cdrom

挂载ntfs的分区:

[root@labroot]# mount -o iocharset=cp936 /dev/hda7 /mnt/cdrom

挂载镜像文件:

[root@labroot]# mount -o loop /abc.iso /mnt/cdrom

挂载USB闪存。

[root@labroot]# mount /dev/sda1 /mnt/cdrom

(3) 其他常用命令

显示/etc/passwd文件的前5行内容,且显示文件内容前,显示文件的文件名:

[root@lab root]# head -n 5 –v /etc/passwd

使用df命令查看磁盘的使用情况:

[root@lab root]# df

为/etc/passwd 文件建立一个软连接/tmp/passwdlink

[root@lab tmp]# ln -s /etc/passwd /root/passwdlink

列出/root目录下文件的详细信息,注意passwdlink文件:

[root@lab root]# ll /root

删除软链接passwdlink:

[root@lab root]# rm -fr/root/passwdlink

变成stu用户,执行一个命令就结束(需要系统存在stu用户):

[root@labroot]# su -c "cat anaconda-ks.cfg" stu

显示umount命令简要说明:

[root@labroot]# man -f umount

显示时间后跳行,再显示目前日期:

[root@lab root]# date +%T%n%D

显示本月月历:

[root@labroot]# cal

Linux命令—压缩及其他的更多相关文章

  1. Linux命令——压缩和解压缩

    Linux命令--压缩和解压缩 尽管文件后缀名在Linux中没什么用,但还是来看看: .gz:表示由gzip压缩工具压缩的文件 .bz2:表示由bzip2压缩工具压缩的文件 .tar:表示由tar打包 ...

  2. Linux命令-压缩解压命令:gzip、gunzip

    gzip [选项] 源文件名(压缩前) gunzip [选项] 源文件名(压缩后) cd /tmp 切换tmp目录 rm -rf * 强制删除tmp目录下面所有的文件和目录 touch beijing ...

  3. Linux命令-压缩解压命令:bzip2、bunzip2

    bzip2是gzip的升级版 bzip2 [选项] 源文件名(压缩前) -k 保留源文件,(区别gzip不支持保留源文件) bunzip2 [选项] 源文件名(压缩后) 压缩文件: bzip2 -k ...

  4. Linux命令压缩与解压缩

    zip格式的文件:zip和unzip zip 命令: # zip test.zip test.txt 它会将 test.txt 文件压缩为 test.zip ,当然也可以指定压缩包的目录,例如 /ro ...

  5. linux命令:压缩解压命令

    压缩解压命令:gzip 命令名称:gzip 命令英文原意:GNU zip 命令所在路径:/bin/gzip 执行权限:所有用户 语法:gzip 选项  [文件] 功能描述:压缩文件 压缩后文件格式:g ...

  6. Linux命令--压缩解压(简化版)

    Linux tar.gz.tar.bz2.zip 等解压缩.压缩命令详解(简化版) Linux 常用的压缩与解压缩命令有:tar.gzip.gunzip.bzip2.bunzip2.compress ...

  7. linux命令-压缩与打包

    在 Linux 中可以识别的常见压缩格式有十几种,比如".zip"" .gz"" .bz2" ".tar" " ...

  8. linux命令-压缩数据

    linux文件压缩工具:bzip2 文件扩展名 .bz2 compress 文件扩展名 .Z linux上很少看到了 uncompress解压 gzip 文件扩展名,.gz,gzip压缩文件,gzca ...

  9. Linux命令-压缩解压命令:zip、unzip

    zip [选项] [压缩后文件名] [压缩前的文件或者目录名称] -r表示压缩目录(recursion 递归) rm -rf * 删除当前目录下面的所有文件,也包括目录和子目录ls cp /etc/s ...

随机推荐

  1. operator[] 和 insert

    operator[] 和 insert: map的[]操作和其他容器和内置[]没有关系 如果我们通过[]向map中插入or更新值,需要考虑一些东西 1.键已经存在,那么直接进行修改即可 2.键不存在, ...

  2. 【模版 Floyd最小环】

    输入 输入中有多组数据.请用SeekEof判断是否到达文件结束. 对于每组数据: 第一行有两个正整数N,M,分别表示学校的景点个数和有多少对景点之间直接有边相连.(N< =100,M< = ...

  3. C++ C# python 中输入输出函数对比

    C++ cin>>"nihao";cout<<"nihao"<<endl; C# System.Console.ReadLi ...

  4. Unix系统的文件打开机构

    当打开一个文件时,建立用户与该文件的联系.其实质是将该文件在辅存中的有关目录信息.辅存i节点及相应的文件地址索引表拷贝到主存中.文件系统中管理这一方面的机构成为打开文件管理机构,简称打开文件机构. 打 ...

  5. 以太坊MetaMask钱包插件简介

    MetaMask是一个以太坊钱包插件,虽然只能在Chrome浏览器中使用,但作为以太坊钱包的metamask却很受以太坊开发者欢迎. MetaMask 评价(5★):安装设置:★★★★界面操作:★★★ ...

  6. c++ primer第15章这几个例子中的构造函数形式不太理解

    //向基类构造函数传递实参p491 class Bulk_item : public Item_base{ public: Bulk_item(,double disc_rate = 0.0): It ...

  7. SpringMVC中HandlerMapping的三种配置方式

    <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE beans PUBLIC "-/ ...

  8. 2. struct A 和 typedef struct A

    2. struct A 和 typedef struct A 2.1 struct A struct A{}定义一个名为struct A的结构体. 下例定义了struct A同时,声明了两个变量(注意 ...

  9. HTML5 唤起 APP

    <p><a href="xxx://app/question/95">点击跳转,直接回帖报名</a></p> /* global n ...

  10. centos6 安装redis-4.0.9

    从redis官网下载Linux redis4.0.9版本,我下载的redis-4.0.9.tar.gz(目前最新稳定版),下载到/usr/local/src目录,如果没有就mkdir创建一个. 下载链 ...