第二周练习与作业

第二周作业

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

相关推荐

  • 【25期】Linux第一周学习知识小结

    1:设置Linux图形界面不用输入账号和密码直接登录系统 首先在图形化界面编辑文件:vi /etc/gdm/custom.conf 编辑如下图: 在[daemon]下添加两行代码: AutomaticLoginEnable=True // 自动登陆器用 AutomaticLogin=root   //登录账号root 2:free命令 在终端输入f…

    2017-07-15
  • 相关练习

    1、请使用命令行展开功能来完成以下练习:    (1)、创建/tmp目录下的:a_c, a_d, b_c, b_d  mkdir /tmp/{a,b}_{c,d}    (2)、创建/tmp/mylinux目录下的:  mkdir -pv /tmp/mylinux/{bin,boot/grub,de…

    Linux干货 2016-11-05
  • ​源码编译安装LNMP

    源码编译安装LNMP 环境:CentOS6.6 IP: 172.16.10.10/16 GW:172.16.0.2 主机名称: lnmp.test.net 一、常规设置: 网卡: 临时 ifconfig eth0 172.16.10.10/16 up 永久 [root@www ~]# vim /etc/sysconfig/network-scripts/if…

    Linux干货 2016-11-14
  • 网络班22期+第二周作业练习

    常用的文件管理命令: ls,显示文件或目录 -l:显示文件或目录的包括权限、属主、属组大小创建日期等详细信息 [root@centos7 ~]# ls -l total 16 -rw-r–r–. 1 root root   64 Aug&nbsp…

    Linux干货 2016-09-05
  • M22 使用光盘修复Centos实验初探

    实验目的: 服务器由于文件丢失等原因造成无法启动,可以使用光盘引导启动服务器,然后对服务器进行修复。 实验环境: VMware12安装Centos6.8虚拟机 Centos6.8的光盘镜像 实验原理: 手动删除虚拟机上的rpm程序文件,使用光盘镜像恢复安装rpm程序。 实验过程: 1、     执行命令删除rpm程序,…

    2017-03-06
  • Week6 Vim编辑器使用指南及练习

    vim编辑器 vim模式: 模式转换.png 编辑–>输入: i: 在当前光标所在字符的前面,转为输入模式; a: 在当前光标所在字符的后面,转为输入模式; o: 在当前光标所在行的下方,新建一行,并转为输入模式; I:在当前光标所在行的行首,转换为输入模式 A:在当前光标所在行的行尾,转换为输入模式 O:在当前光标所在行的上方,新建一行,…

    Linux干货 2017-02-17

评论列表(1条)

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

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