第二周练习与作业

第二周作业

1Linux上的文件管理类命令有哪些,其常用的使用方法及其相关示例演示

         文件管理类命令:cp,mv,rm

cp: 源文件;目标文件

         [root@localhost
~]# cp /etc/issue /tmp/test1/

         cp:是否覆盖“/tmp/test1/issue” y

         [root@localhost
~]# ls /tmp/test1

         issue

         [root@localhost
~]#

mv:  move (rename) files

         [root@localhost
~]# cd /tmp/

         [root@localhost
tmp]# ls

         hello.txt  log  mysysroot   system-release  test1  tom

         hi.txt     m    system.rel  test            test2

         [root@localhost
tmp]# ls test1

         issue

         [root@localhost
tmp]# mv /tmp/test

         test/  test1/ test2/

         [root@localhost
tmp]# mv /tmp/test1/issue /tmp/test2/

         [root@localhost
tmp]# ls /tmp/test2/

         issue

         [root@localhost
tmp]#

rm: 命令  remove        rm [OPTION]… FILE…

         [root@localhost
tmp]# ls /tmp

    hello.txt  log  mysysroot   system-release  test1  tom

         hi.txt     m    system.rel  test            test2

         [root@localhost
tmp]# rm -fr /tmp/test1

         [root@localhost
tmp]# ls

         hello.txt  log  mysysroot   system-release  test2

         hi.txt     m    system.rel  test            tom

         [root@localhost
tmp]#

2bash的工作特性之命令执行状态返回值和命令行展开所涉及的内容及其示例演示

         bash通过状态返回值来输出此结果;

        成功:0

        失败:1255

 

    命令执行完成之后,其状态的返回值保存于bash的特殊变更 $? 中;

        echo $? 来查看

         bash的命令行展开:

    ~:自动展开为用户的家目录,或指定的用户的家目录;

    {} 可承载一个以(,)逗号分隔的路径列表,并能够将其展开为多个路径

         [root@localhost
~]# cd /tmp

         [root@localhost
tmp]# ls

         hello.txt  log  mysysroot   system-release  test2

         hi.txt     m    system.rel  test            tom

         [root@localhost
tmp]# mkdir /tmp/{a,b}_{c,d}

         [root@localhost
tmp]# ls

         a_c  b_c  hello.txt  log  mysysroot   system-release  test2

         a_d  b_d  hi.txt     m    system.rel  test            tom

         [root@localhost
tmp]#

3、使用命令行展开功能来完成练习:

         [root@localhost
~]# cd /tmp

         [root@localhost
tmp]# ls

         hello.txt  log  mysysroot   system-release  test2

         hi.txt     m    system.rel  test            tom

         [root@localhost
tmp]# mkdir /tmp/{a,b}_{c,d}

         [root@localhost
tmp]# ls

         a_c  b_c  hello.txt  log  mysysroot   system-release  test2

         a_d  b_d  hi.txt     m    system.rel  test            tom

         [root@localhost
tmp]#

 

         [root@localhost
~]# mkdir -pv
/tmp/mylinux/{bin,boot/grub,dev,etc/{rc.d/init.d,sysconfig/network-scripts},lib/modules,lib64,proc,sbin,sys,tmp,usr/local/{bin,sbin},var/{local,log,run}}

mkdir: 已创建目录 “/tmp/mylinux”

mkdir: 已创建目录 “/tmp/mylinux/bin”

mkdir: 已创建目录 “/tmp/mylinux/boot”

mkdir: 已创建目录 “/tmp/mylinux/boot/grub”

mkdir: 已创建目录 “/tmp/mylinux/dev”

mkdir: 已创建目录 “/tmp/mylinux/etc”

mkdir: 已创建目录 “/tmp/mylinux/etc/rc.d”

mkdir: 已创建目录 “/tmp/mylinux/etc/rc.d/init.d”

mkdir: 已创建目录 “/tmp/mylinux/etc/sysconfig”

mkdir: 已创建目录 “/tmp/mylinux/etc/sysconfig/network-scripts”

mkdir: 已创建目录 “/tmp/mylinux/lib”

mkdir: 已创建目录 “/tmp/mylinux/lib/modules”

mkdir: 已创建目录 “/tmp/mylinux/lib64”

mkdir: 已创建目录 “/tmp/mylinux/proc”

mkdir: 已创建目录 “/tmp/mylinux/sbin”

mkdir: 已创建目录 “/tmp/mylinux/sys”

mkdir: 已创建目录 “/tmp/mylinux/tmp”

mkdir: 已创建目录 “/tmp/mylinux/usr”

mkdir: 已创建目录 “/tmp/mylinux/usr/local”

mkdir: 已创建目录 “/tmp/mylinux/usr/local/bin”

mkdir: 已创建目录 “/tmp/mylinux/usr/local/sbin”

mkdir: 已创建目录 “/tmp/mylinux/var”

mkdir: 已创建目录 “/tmp/mylinux/var/local”

mkdir: 已创建目录 “/tmp/mylinux/var/log”

mkdir: 已创建目录 “/tmp/mylinux/var/run”

[root@localhost ~]# tree /tmp/mylinux

/tmp/mylinux

├── bin

├── boot

   └── grub

├── dev

├── etc

   ├── rc.d

      └── init.d

   └── sysconfig

       └── network-scripts

├── lib

   └── modules

├── lib64

├── proc

├── sbin

├── sys

├── tmp

├── usr

   └── local

       ├── bin

       └── sbin

└── var

    ├── local

    ├── log

    └── run

 

24 directories, 0 files

[root@localhost ~]#

4、文件的元数据信息有哪些,分别表示什么含义,如何查看?如何修改文件的时间戳信息

         文件的数据分两种:一种元数据,既属性数据;一种就是数据本身;可使用stat命令查看文件的元数据:

         [root@localhost
~]# stat /tmp/functions

  文件:“/tmp/functions”

  大小:13948          块:32         IO 块:4096   普通文件

设备:803h/2051d Inode2842        硬链接:1

权限:(0644/-rw-r–r–)  Uid(    0/    root)   Gid(    0/    root)

环境:unconfined_u:object_r:user_tmp_t:s0

最近访问:2017-08-07 16:34:48.718955739 +0800

最近更改:2017-08-07 16:34:48.718955739 +0800

最近改动:2017-08-07 16:34:48.718955739 +0800

创建时间:

[root@localhost ~]#

修改文件的时间戳信息:

可以使用touch命令更改文件的时间戳:

语法:

touch [OPTION]… FILE…

常用选项:

-c: 指定的文件路径不存在时不予创建;

-a: 仅修改access time

-m:仅修改modify time

-t:使用指定的日期时间,而非现在的时间;[[CC]YY]MMDDhhmm[.ss];

原创文章,作者:N27_yangjifeng,如若转载,请注明出处:http://www.178linux.com/84288

(0)
N27_yangjifengN27_yangjifeng
上一篇 2017-08-09 09:20
下一篇 2017-08-09 21:03

相关推荐

  • Linux启动之GRUB详解

    GRUB 在BIOS读取先关信息之后,接下来就是去第一个可以启动的设备当中的MBR中读取Boot loader信息,bootloader具有菜单功能、直接加载内核信息,以及相关控制权限转交功能。所以说系统的启动必须有bootloader,然后才能去加载内核 grub:GRand Unified Bootloader  …

    Linux干货 2016-09-15
  • Linux第四周总结

    1、复制/etc/skel目录为/home/tuser1, 要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。 2、编辑/etc/group文件,添加组hadoop。 3、手动编辑/etc/passwd文件新增一行,添加用户hadoop, 其基本组ID为hadoop组的id号;其家目录为/home/hadoop。 4、复制/etc/…

    2017-07-24
  • Linux基础知识之文本处理三剑客sed

    处理文本的工具sed     1.sed是一种流编辑器,它一次处理一行内容。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”。接着用sed命令处理缓冲区中的内容,完成处理后,把缓冲区中的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有改变,除非你使用重定向存储输出。sed主要用来自动编…

    Linux干货 2016-08-11
  • 计算机操作系统与简单命令

    计算机系统的组成 硬件:主机(cpu、内存等),外部设备(输入设备键盘鼠标、输出设备显示屏;硬软盘   等等)。 软件:主要由操作系统和应用程序构成。 计算机硬件的组成部分及工作流程图 输入设备——存储器——CPU运算——输出设备   服务器主要分类有: 塔式服务器:立式PC相像 机架式服务器:统一标准宽度19英寸(48.26c…

    Linux干货 2017-02-14
  • Linux发展史

    Linux发展史 Linux的简单介绍 Linux操作系统诞生于1991 年,是一套免费使用和自由传播的类Unix操作系统。Linux存在着许多不同的Linux发行版本。严格意义上的Linux系统应该是GUN/Linux(kernel+Application)而Linux本身只表示Linux系统内核,但实际上人们已经习惯了用Linux称呼GUN/Linux系…

    Linux干货 2016-10-13
  • linux基础之lvm操作流程

    linux基础之lvm基本操作流程    LVM是 Logical Volume Manager(逻辑卷管理)的简写,它是Linux环境下对磁盘分区进行管理的一种机制,它由Heinz Mauelshagen在Linux 2.4内核上实现,目前最新版本为:稳定版1.0.5,开发版 1.1.0-rc2,以及LVM2开发版。Linux用户安装L…

    2017-03-19

评论列表(1条)

  • 马哥教育
    马哥教育 2017-08-20 19:09

    理论性的知识和实操一样重要,再接再励。