第二周练习与作业

第二周作业

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

相关推荐

  • CentOS7内核编译

    一.centos7内核编译(支持ntfs文件系统) 1.下载内核源代码内核文件(https://www.kernel.org/) 2.解压缩源代码文件到指定目录 tar xvf linux-4.8.10.tar.xz -C /usr/src 3.创建软链接解压后的文件 cd /usr/src ln -s linux-4.8.10/ linux 4.复制当前系…

    Linux干货 2016-11-28
  • linux发行版介绍及其哲学思想

    Linux是一种自由和开源的unix-like操作系统。目前运用领域最广泛、使用人数最多的操作系统。该操作系统的内核是Linus Torvalds在1991年10月5日首次发布。是一个多任务,多用户的操作系统,广泛应用在服务器,手机,平板电脑,电视,电子游戏等领域,我们生活中随处都可以见到linux身影。 Linux诞生 1991 年,在芬兰,赫尔辛基大学的…

    2017-09-16
  • Linux的用户组和权限(一)

    导读:本章主要内容如下       1.解释Linux的安全模型      2.解释用户账号和组群账号的目的      3.用户和组管理命令      4.理解并设置文件权限 &n…

    Linux干货 2016-08-04
  • 8.网络基础知识

    1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。 网桥:网桥就是把2个不同的网段桥接起来;可隔离冲突域。 集线器:集线器就是把多根以太网线或光纤集合连接在同一段物理介质下的装置;工作在物理层;不能隔离冲突域。 二层交换机:工作于OSI模型的第2层(数据链路层),故而称为二层交换机。二层交换技术的发展已经比较成熟,二层交换机属数据…

    Linux干货 2017-08-21
  • centos启动流程

    linux系统启动流程 内核的设计结构单内核:linux(线程–lwp轻量级进程)微内核:windows(支持真正意义上的多线程) 单内核:很多功能驱动都集成在一起 微内核:内核很小,功能单一。模块化 linux为了适应众多用户的不同硬件需求,linux内核在设计上采用模块化设计。可以动态加载模块。核心模块:ko 内核所独有的。共享对象:so 红…

    Linux干货 2016-09-09
  • 马哥教育网络班21期+第9周课程练习

    1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; #!/bin/bash # declare -i nologuser=0 declare -i loguser=0 while read&…

    Linux干货 2016-09-05

评论列表(1条)

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

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