codecademy-command line_filesystem-程序员宅基地

技术标签: shell  

$: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

转载于:https://www.cnblogs.com/xuezhi/p/4745185.html

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_30788619/article/details/99089669

智能推荐

使用nginx解决浏览器跨域问题_nginx不停的xhr-程序员宅基地

文章浏览阅读1k次。通过使用ajax方法跨域请求是浏览器所不允许的,浏览器出于安全考虑是禁止的。警告信息如下:不过jQuery对跨域问题也有解决方案,使用jsonp的方式解决,方法如下:$.ajax({ async:false, url: 'http://www.mysite.com/demo.do', // 跨域URL ty..._nginx不停的xhr

在 Oracle 中配置 extproc 以访问 ST_Geometry-程序员宅基地

文章浏览阅读2k次。关于在 Oracle 中配置 extproc 以访问 ST_Geometry,也就是我们所说的 使用空间SQL 的方法,官方文档链接如下。http://desktop.arcgis.com/zh-cn/arcmap/latest/manage-data/gdbs-in-oracle/configure-oracle-extproc.htm其实简单总结一下,主要就分为以下几个步骤。..._extproc

Linux C++ gbk转为utf-8_linux c++ gbk->utf8-程序员宅基地

文章浏览阅读1.5w次。linux下没有上面的两个函数,需要使用函数 mbstowcs和wcstombsmbstowcs将多字节编码转换为宽字节编码wcstombs将宽字节编码转换为多字节编码这两个函数,转换过程中受到系统编码类型的影响,需要通过设置来设定转换前和转换后的编码类型。通过函数setlocale进行系统编码的设置。linux下输入命名locale -a查看系统支持的编码_linux c++ gbk->utf8

IMP-00009: 导出文件异常结束-程序员宅基地

文章浏览阅读750次。今天准备从生产库向测试库进行数据导入,结果在imp导入的时候遇到“ IMP-00009:导出文件异常结束” 错误,google一下,发现可能有如下原因导致imp的数据太大,没有写buffer和commit两个数据库字符集不同从低版本exp的dmp文件,向高版本imp导出的dmp文件出错传输dmp文件时,文件损坏解决办法:imp时指定..._imp-00009导出文件异常结束

python程序员需要深入掌握的技能_Python用数据说明程序员需要掌握的技能-程序员宅基地

文章浏览阅读143次。当下是一个大数据的时代,各个行业都离不开数据的支持。因此,网络爬虫就应运而生。网络爬虫当下最为火热的是Python,Python开发爬虫相对简单,而且功能库相当完善,力压众多开发语言。本次教程我们爬取前程无忧的招聘信息来分析Python程序员需要掌握那些编程技术。首先在谷歌浏览器打开前程无忧的首页,按F12打开浏览器的开发者工具。浏览器开发者工具是用于捕捉网站的请求信息,通过分析请求信息可以了解请..._初级python程序员能力要求

Spring @Service生成bean名称的规则(当类的名字是以两个或以上的大写字母开头的话,bean的名字会与类名保持一致)_@service beanname-程序员宅基地

文章浏览阅读7.6k次,点赞2次,收藏6次。@Service标注的bean,类名:ABDemoService查看源码后发现,原来是经过一个特殊处理:当类的名字是以两个或以上的大写字母开头的话,bean的名字会与类名保持一致public class AnnotationBeanNameGenerator implements BeanNameGenerator { private static final String C..._@service beanname

随便推点

二叉树的各种创建方法_二叉树的建立-程序员宅基地

文章浏览阅读6.9w次,点赞73次,收藏463次。1.前序创建#include<stdio.h>#include<string.h>#include<stdlib.h>#include<malloc.h>#include<iostream>#include<stack>#include<queue>using namespace std;typed_二叉树的建立

解决asp.net导出excel时中文文件名乱码_asp.net utf8 导出中文字符乱码-程序员宅基地

文章浏览阅读7.1k次。在Asp.net上使用Excel导出功能,如果文件名出现中文,便会以乱码视之。 解决方法: fileName = HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8);_asp.net utf8 导出中文字符乱码

笔记-编译原理-实验一-词法分析器设计_对pl/0作以下修改扩充。增加单词-程序员宅基地

文章浏览阅读2.1k次,点赞4次,收藏23次。第一次实验 词法分析实验报告设计思想词法分析的主要任务是根据文法的词汇表以及对应约定的编码进行一定的识别,找出文件中所有的合法的单词,并给出一定的信息作为最后的结果,用于后续语法分析程序的使用;本实验针对 PL/0 语言 的文法、词汇表编写一个词法分析程序,对于每个单词根据词汇表输出: (单词种类, 单词的值) 二元对。词汇表:种别编码单词符号助记符0beginb..._对pl/0作以下修改扩充。增加单词

android adb shell 权限,android adb shell权限被拒绝-程序员宅基地

文章浏览阅读773次。我在使用adb.exe时遇到了麻烦.我想使用与bash相同的adb.exe shell提示符,所以我决定更改默认的bash二进制文件(当然二进制文件是交叉编译的,一切都很完美)更改bash二进制文件遵循以下顺序> adb remount> adb push bash / system / bin /> adb shell> cd / system / bin> chm..._adb shell mv 权限

投影仪-相机标定_相机-投影仪标定-程序员宅基地

文章浏览阅读6.8k次,点赞12次,收藏125次。1. 单目相机标定引言相机标定已经研究多年,标定的算法可以分为基于摄影测量的标定和自标定。其中,应用最为广泛的还是张正友标定法。这是一种简单灵活、高鲁棒性、低成本的相机标定算法。仅需要一台相机和一块平面标定板构建相机标定系统,在标定过程中,相机拍摄多个角度下(至少两个角度,推荐10~20个角度)的标定板图像(相机和标定板都可以移动),即可对相机的内外参数进行标定。下面介绍张氏标定法(以下也这么称呼)的原理。原理相机模型和单应矩阵相机标定,就是对相机的内外参数进行计算的过程,从而得到物体到图像的投影_相机-投影仪标定

Wayland架构、渲染、硬件支持-程序员宅基地

文章浏览阅读2.2k次。文章目录Wayland 架构Wayland 渲染Wayland的 硬件支持简 述: 翻译一篇关于和 wayland 有关的技术文章, 其英文标题为Wayland Architecture .Wayland 架构若是想要更好的理解 Wayland 架构及其与 X (X11 or X Window System) 结构;一种很好的方法是将事件从输入设备就开始跟踪, 查看期间所有的屏幕上出现的变化。这就是我们现在对 X 的理解。 内核是从一个输入设备中获取一个事件,并通过 evdev 输入_wayland

推荐文章

热门文章

相关标签