第二周练习与作业

第二周作业

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

相关推荐

  • 7.22_Linux入门和帮助文件的使用

    Linux系统登录的两种方式 GUI:图形界面 Graphic User Interface 默认在Linux下面有三种可用的图形界面程序可选,分别为 1.gnome(c,图形库gtk) 2.kde(c++,图形库qt) 3.xface(轻量级桌面) 每一种图形界面下面开发的软件并不兼容,因为它们开发时候所用的开发语言也各不相同 启动方式:cli模…

    Linux干货 2016-08-04
  • python分支循环和列表

    if语句 if condition: 代码块 condition必须是一个bool类型,这个地方有一个隐式转换bool(condition) if 1<2: print(‘1 less than 2’)   循环——while语句 while condition: block 当条件满足即condition为True,…

    2018-03-27
  • 我的学习宣言,不忘初心

    Dear 马哥: 我相信选择马哥教育是正确的。 我将用洪荒之力的努力来成为一名合格的马帮门徒! 一定不学中国足球。 敬礼 自学生 朱宏

    Linux干货 2016-10-30
  • Linux基础 文件权限

    概述 从接触linux第一天开始,Linux一切皆文件的哲学思想就深植于每个linuxer的心中,因此,实现Linux的系统安全必然绕不开文件权限。文件的权限是建立在用户的基础上的,脱离了用户,文件权限也就变得毫无意义了。用户、组和文件权限一起铸就了linux的系统安全模型。本文主要从文件权限方面了解Linux的安全模型。 文中主要讲解了: 1. 文件权限r…

    Linux干货 2016-08-05
  • Zabbix 新版微信告警 [2017]

    Zabbix 新版微信告警 Zabbix 新版微信告警 date 2017-06-14zabbix Zabbix可以通过多种方式把告警信息发送到指定人,常用的有邮件,短信报警方式,但是越来越多的企业开始使用zabbix结合微信作为主要的告警方式,这样可以及时有效的把告警信息推送到接收人,方便告警的及时处理。 关于邮件报警可以参考: Zabbix 使用脚本发送…

    2017-06-17

评论列表(1条)

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

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