第二周练习与作业

第二周作业

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
下一篇 2017-08-09

相关推荐

  • bash基础特性(一)之命令历史,命令补存,路劲补存,命令行展开,命令执行状态结果和引用

    bash是Unix shell的一种,在1987年由布莱恩·福克斯为了GNU计划而编写。1989年发布第一个正式版本,原先是计划用在GNU操作系统上,但能运行于大多数类Unix系统的操作系统之上,包括Linux与Mac OS X v10.4都将它作为默认shell。 Bourne shell是一个早期的重要shell,由史蒂夫·伯恩在1978年前后编写,并同…

    2017-09-20
  • N25-第七周博客作业

    1、创建一个10G分区,并格式为ext4文件系统; (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl;(2) 挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳; 查看当前分区情况 [root@han ~]# fdisk -l Disk /dev/sda: 42…

    Linux干货 2017-02-23
  • 用户 组

    用户 组    在linux系统中,用户管理是基于用户名和密码的方式进行资源的分配,linux上用户Username/UID分为以下类别:    管理员: root,0    普通用户: 1-65535 普通用户分为:系统用户和登录用户两种 系统用户:1-499(cen…

    系统运维 2016-08-04
  • shell中测试命令

    shell中测试命令        test命令提供了if–than语句中测试不同条件的途径。如果test命令中列出的条件成立,test命令就会退出并返回退出状态吗0 。这样if–than语句就与其他编程语言中的if–than语句类似的方式工作了。如果条件不成立,…

    Linux干货 2017-04-16
  • n25第二周

    linux文件管理类命令     mkdir,rmdir,cp,mv,rm,chwon,chmod     1.mkdir->make directories(创建目录)     用法:    &nbsp…

    Linux干货 2016-12-11

评论列表(1条)

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

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