zoukankan      html  css  js  c++  java
  • 《linux系统及其编程》实验课记录(四)

    实验4:组织目录和文件

    实验目标:

    熟悉几个基本的操作系统文件和目录的命令的功能、语法和用法, 整理出一个更有条理的主目录,每个文件都位于恰当的子目录。

     

    实验背景:

    你的主目录中已经积压了一些文件,你决定开始规整它们。你打算新建几个子目录,然后复制或转移文件来适应这个新方案。此外,你还有一些不需要的文件,它们必须被删除。

     

    实验要求:

    1、使用ls 查看文件及其属性

    2、使用cd 切换路径

    3、使用touchmkdir 创建相应的文件及文件夹

    4、使用rmrmdir 删除文件及文件夹

     

    实验详解:

    1、使用口令student 登录为用户student。如果你使用的是图形化环境,点击[应用程序(Applications)]->[附件(System Tools)]->[终端(Terminal)]来打开终端:

     

    2、登录到系统之后,你应该就位于你的主目录中。使用pwd”(打印工作目录)命令

    来校验:

    [student@desktopX ~]$ pwd

    /home/student

     

    3、使用一下每个命令来检查你的主目录中的文件:

    ls

    ls –a

    ls -al

    观察返回的文件数量有何不同。

     

    4、现在,你将使用touch 命令来创建该练习序列的文件,输入:

    [student@desktopX ~]$ touch {report,graph}_{jan,feb,mar}

     

    5、使用ls 命令来检查前一个命令执行的结果。你应该看到你的主目录中新建了一下六个空文件:

    [student@desktopX ~]$ ls

    graph_feb

    graph_jan

    graph_mar

    report_feb

    report_jan

    report_mar

     

    6、为了组织文件,你必须首先新建一些目录。使用mkdir 命令来新建目录。在更改目录时,请确定当前工作目录和预料中一样:

    [student@desktopX ~]$ mkdir Projects

    [student@desktopX ~]$ mkdir Projects/graphs

    [student@desktopX ~]$ cd Projects

    [student@desktopX Projects]$ cd Projects

    [student@desktopX Projects]$ mkdir reports

    [student@desktopX Projects]$ cd reports

    [student@desktopX reports]$ mkdir ../Backups

    使用ls 命令来检查你的工作结果:

    [student@desktopX reports]$ cd

    [student@desktopX ~]$ ls -l

     

     

    7、首先,把所有文件名中带有graph 的文件都转移到Projects 目录中的graphs 子目录中。分两个步骤来完成:

    第一步:转移一个文件

    第二步:转移两个文件

    [student@desktopX ~]$ mv graph_jan Projects/graphs

    [student@desktopX ~]$ mv graph_feb graph_mar Projects/graphs

    [student@desktopX ~]$ ls -l Projects/graphs

     

     

    8、下一步,把两个report”文件移动到Projects 目录中的reports 子目录中。使用这些命令来转移这些文件:

    [student@desktopX ~]$ mv report_jan report_feb Projects/reports

    [student@desktopX ~]$ ls –l Projects/reports

    totol 2

    -rw-rw-r-- 1 student student 0 Sep 30 21:08 report_feb

    -rw-rw-r-- 1 student student 0 Sep 30 21:08 report_jan

     

     

    9、删除剩下的report 文件:

    [student@desktopX ~]$ rm report_mar

    [student@desktopX ~]$ ls Projects

     

    10、转换到Backups 的目录,January 文件复制到这个目录中。一个文件使用绝对路径名复制,另一个文件使用相对路径名复制:

    [student@desktopX ~]$ cd Projects/Backups

    [student@desktopX Backups]$ pwd

    /home/student/Projects/Backups

    [student@desktopX Backups]$ cp ../reports/report_jan .

    [student@desktopX Backups]$ cp /home/student/Projects/graphs/graph .

    //’.’表示当前工作的目录

     

    11、注销,或运行exit 命令来关闭图形化终端。

     


     

     

    实验记录:

    2.

    3.

    4.

    5.

    6.

    7.

    8.

    9.

    10.

     

    Freecode : www.cnblogs.com/yym2013

  • 相关阅读:
    leetcode 350. Intersection of Two Arrays II
    leetcode 278. First Bad Version
    leetcode 34. Find First and Last Position of Element in Sorted Array
    leetcode 54. Spiral Matrix
    leetcode 59. Spiral Matrix II
    leetcode 44. Wildcard Matching
    leetcode 10. Regular Expression Matching(正则表达式匹配)
    leetcode 174. Dungeon Game (地下城游戏)
    leetcode 36. Valid Sudoku
    Angular Elements
  • 原文地址:https://www.cnblogs.com/yym2013/p/3624061.html
Copyright © 2011-2022 走看看