$:shell prompt (命令提示符)

  1. In the terminal, first you see $. This is called a shell prompt. It appears when the terminal is ready to accept a command.
  2. When you type ls, the command line looks at the folder you are in, and then "lists" the files and folders inside it. The directories 2014, 2015, and the file hardware.txt are the contents of the current directory
  3. $ pwd
    /home/ccuser/workspace/blog

    pwd stands for "print working directory". It outputs the name of the directory you are currently in, called theworking directory.

    Here the working directory is blog/. In Codecademy courses, your working directory is usually inside thehome/ccuser/workspace/ directory.

    Together with ls, the pwd command is useful to show where you are in the filesystem.

  4. $ cd 2015
    1. cd stands for "change directory". Just as you would click on a folder in Windows Explorer or Finder, cdswitches you into the directory you specify. In other words, cd changes the working directory.
    2. The directory we change into is 2015. When a file, directory or program is passed into a command, it is called an argument. Here the 2015 directory is an argument for the cd comman
      $ cd jan/memory

      To navigate directly to a directory, use cd with the directory's path as an argument. Here, cd jan/memory/command navigates directly to the jan/memorydirectory.

      $ cd ..

      To move up one directory, use cd ... Here, cd ..navigates up from jan/memory/ to jan/.

    3. $ mkdir media

      The mkdir command stands for "make directory". It takes in a directory name as an argument, and then creates a new directory in the current working directory.

      Here we used mkdir to create a new directory namedmedia/ inside the feb/ directory.

    4. touch keyboard.txt

      The touch command creates a new file inside the working directory. It takes in a filename as an argument, and then creates an empty file in the current working directory.

      Here we used touch to create a new file namedkeyboard.txt inside the 2014/dec/ directory.

    5. Congratulations! You've learned five commands commonly used to navigate the filesystem from the command line. What can we generalize so far?

      • The command line is a text interface for the computer's operating system. To access the command line, we use the terminal.
      • filesystem organizes a computer's files and directories into a tree structure. It starts with theroot directory. Each parent directory can contain more child directories and files.
      • From the command line, you can navigate through files and folders on your computer:
        • pwd outputs the name of the current working directory.
        • ls lists all files and directories in the working directory.
        • cd switches you into the directory you specify.
        • mkdir creates a new directory in the working directory.
        • touch creates a new file inside the working directory.
        • $ ls -a
          . .. .preferences action drama comedy genres.xt
          1. The ls command lists all files and directories in the working directory.
          2. The -a modifies the behavior of the ls command to also list the files and directories starting with a dot (.). Files started with a dot are hidden, and don't appear when using ls alone.

          The -a is called an option. Options modify the behavior of commands. Here we used ls -a to display the contents of the working directory in more detail.

          In addition to -a, the ls command has several more options. Here are three common options:

          • -a - lists all contents, including hidden files and directories
          • -l - lists all contents of a directory in long format
          • -t - order files and directories by the time they were last modified.
          • $ ls -l
            drwxr-xr-x 5 cc eng 4096 Jun 24 16:51 action
            drwxr-xr-x 4 cc eng 4096 Jun 24 16:51 comedy
            drwxr-xr-x 6 cc eng 4096 Jun 24 16:51 drama
            -rw-r--r-- 1 cc eng 0 Jun 24 16:51 genres.txt

            The -l option lists files and directories as a table. Here there are four rows, with seven columns separated by spaces. Here's what each column means:

            1. Access rights. These are actions that are permitted on a file or directory.
            2. Number of hard links. This number counts the number of child directories and files. This number includes the parent directory link (..) and current directory link (.).
            3. The username of the file's owner. Here the username is cc.
            4. The name of the group that owns the file. Here the group name is eng.
            5. The size of the file in bytes.
            6. The date & time that the file was last modified.
            7. The name of the file or directory.
            8. $ ls -alt
              drwxr-xr-x 4 cc eng 4096 Jun 29 12:22 .
              -rw-r--r-- 1 cc eng 0 Jun 29 12:22 .gitignore
              drwxr-xr-x 5 cc eng 4096 Jun 30 14:20 ..
              drwxr-xr-x 2 cc eng 4096 Jun 29 12:22 satire
              drwxr-xr-x 2 cc eng 4096 Jun 29 12:22 slapstick
              -rw-r--r-- 1 cc eng 14 Jun 29 12:22 the-office.txt

              The -t option orders files and directories by the time they were last modified.

              In addition to using each option separately, like ls -aor ls -l, multiple options can be used together, likels -alt.

              Here, ls -alt lists all contents, including hidden files and directories, in long format, ordered by the date and time they were last modified.

            9. cp frida.txt lincoln.txt

              The cp command copies files or directories. Here, we copy the contents of frida.txt into lincoln.txt.

            10. cp biopic/cleopatra.txt historical/

              To copy a file into a directory, use cp with the source file as the first argument and the destination directory as the second argument. Here, we copy the filebiopic/cleopatra.txt and place it in the historical/directory.

              cp biopic/ray.txt biopic/notorious.txt historical/

              To copy multiple files into a directory, use cp with a list of source files as the first arguments, and the destination directory as the last argument. Here, we copy the files biopic/ray.txt and biopic/notorious.txtinto the historical/ directory.

            11. cp * satire/

              In addition to using filenames as arguments, we can use special characters like * to select groups of files. These special characters are called wildcards. The * selects all files in the working directory, so here we use cp to copy all files into the satire/ directory.

            12. cp m*.txt scifi/

              Here, m*.txt selects all files in the working directory starting with "m" and ending with ".txt", and copies them to scifi/.

            13. The mv command moves files. It's similar to cp in its usage.

              mv superman.txt superhero/

              To move a file into a directory, use mv with the source file as the first argument and the destination directory as the second argument. Here we move superman.txtinto superhero/.

              mv wonderwoman.txt batman.txt superhero/

              To move multiple files into a directory, use mv with a list of source files as the first arguments, and the destination directory as the last argument. Here, we move wonderwoman.txt and batman.txt intosuperhero/.

              mv batman.txt spiderman.txt
            14. rm waterboy.txt

              The rm command deletes files and directories. Here we remove the file waterboy.txt from the filesystem.

              rm -r comedy

              The -r is an option that modifies the behavior of therm command. The -r stands for "recursive," and it's used to delete a directory and all of its child directories.

              Be careful when you use rm! It deletes files and directories permanently. There isn't an undelete command, so once you delete a file or directory withrm, it's gone.

              1. Congratulations! You learned how to use the command line to view and manipulate the filesystem. What can we generalize so far?

                • Options modify the behavior of commands:

                  • ls -a lists all contents of a directory, including hidden files and directories
                  • ls -l lists all contents in long format
                  • ls -t orders files and directories by the time they were last modified
                  • Multiple options can be used together, likels -alt
                • From the command line, you can also copy, move, and remove files and directories:
                  • cp copies files
                  • mv moves and renames files
                  • rm removes files
                  • rm -r removes directories
                • Wildcards are useful for selecting groups of files and directories

codecademy-command line_filesystem的更多相关文章

  1. Linux Command Line learning

    https://www.codecademy.com/en/courses/learn-the-command-line Background The command line is a text i ...

  2. ifconfig: command not found(CentOS专版,其他的可以参考)

    ifconfig: command not found 查看path配置(echo相当于c中的printf,C#中的Console.WriteLine) echo $PATH 解决方案1:先看看是不是 ...

  3. scp报错 -bash: scp: command not found

    环境:RHEL6.5 使用scp命令报错: [root@oradb23 media]# scp /etc/hosts oradb24:/etc/ -bash: scp: command not fou ...

  4. ENode框架单台机器在处理Command时的设计思路

    设计目标 尽量快的处理命令和事件,保证吞吐量: 处理完一个命令后不需要等待命令产生的事件持久化完成就能处理下一个命令,从而保证领域内的业务逻辑处理不依赖于持久化IO,实现真正的in-memory: 保 ...

  5. 设计模式(六):控制台中的“命令模式”(Command Pattern)

    今天的博客中就来系统的整理一下“命令模式”.说到命令模式,我就想起了控制台(Console)中的命令.无论是Windows操作系统(cmd.exe)还是Linux操作系统(命令行式shell(Comm ...

  6. GET command找不到

    谷歌的: On running a cronjob with get command, I was getting the following error. /bin/sh: GET: command ...

  7. source /etc/profile报错-bash: id:command is not found

    由于误操作导致 source /etc/profile 报错 -bash: id:command is not found 此时,linux下很多命令到不能能用,包括vi ls 等... 可以使用 e ...

  8. Webform(七)——内置对象(Session、Application)和Repeater的Command操作

    内置对象:用于页面之间的数据交互 为什么要使用这么内置对象?因为HTTP的无状态性. 一.内置对象 (一)Session 跟Cookies一样用来存储用户数据 1.Session.Cookies对比 ...

  9. MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL

    MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL   是因为目标板的芯片处于休眠 ...

随机推荐

  1. oarcle数据库导入导出,创建表空间

    oracle导入导出(前提,本机已经安装oracle和oracle客户端)导出命令: exp username/password@192.168.1.138/ORCL file=c:\test.dmp ...

  2. Eclipse里项目名有红叉,但是底下的每一个文件都没有红叉

    如果是因为java compiler level does not match the version of the installed java, 那么我们打开项目的properties,有一个选项 ...

  3. smarty string_format用法 取小数点后2位

    <{if $d.ul_pv}> <{$d.sum/$d.ul_pv|string_format:'%.2f'}> <{else}> 0.00 <{/if}&g ...

  4. 江湖救急:webbrowser中js文件丢失问题~

    页面中,有一个按钮,点击按钮通过js create 了一个 script标签 ,链接加载一个外部js文件,执行该js文件 $("#a").click(function(){ $.g ...

  5. 密码学初级教程(一)基本概念及DES加密算法

    密码技术在网络通信中广泛使用,本节是初步接触密码学技术的笔记. 第1章 加密-解密 破译 明文-密文 密钥 密码算法 对称密码-公钥密码(非对称密码) 单向散列函数-散列值 消息认证码 数字签名 伪随 ...

  6. Android中实现圆角矩形及半透明效果。

    注:本文由Colin撰写,版权所有!转载请注明原文地址,谢谢合作! 在做Android开发时,我们为了美观,有时候需要使用圆角矩形,或半透明之类的效果,在网页设计中很容易实现.但在Android开发中 ...

  7. C#3.0 特性

    C#3.0特性 隐式类型的本地变量和数组 对象初始值设定项 集合初始值设定项 扩展方法 匿名类型 lambda表达式 查询关键字 自动实现的属性 分布方法定义 lambda表达式与表达式树 https ...

  8. C++中的内联成员函数与非内联成员函数

    在C++中内联成员函数与非内联成员函数的可以分为两种情况: 1.如果成员函数的声明和定义是在一起的,那么无论有没有写inline这个成员函数都是内联的,如下: using namespace std; ...

  9. tomcat JNDI 设置

    一.在Spring配置文件中的配置   <bean id="dataSource" class="org.springframework.jndi.JndiObje ...

  10. CSU 1120 病毒(DP)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1120 解题报告:dp,用一个串去更新另一个串,递推方程是: if(b[i] > a ...