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

智能推荐

Cocos2d-x 窗口大小调整_cocos2dx设置窗口大小-程序员宅基地

文章浏览阅读4.2k次。打开src目录下的AppDelegate.cpp文件,若无修改则在第45行处找到全局声明的Size变量,修改`designResolutionSize`中的大小即可。_cocos2dx设置窗口大小

springboot接收枚举值的默认方式_springboot get请求怎么接收前端传递的枚举数字-程序员宅基地

文章浏览阅读1.6k次。测试代码:@PostMapping() public void test(@RequestBody Student student){ System.out.println(student.getLover().name()); }class Student{ private Lover lover; public Lover getLover() { return lover; } public void setLover_springboot get请求怎么接收前端传递的枚举数字

【数学建模笔记】【第七讲】多元线性回归分析(二):虚拟变量的设置以及交互项的解释,以及基于Stata的普通回归与标准化回归分析实例_stata两个虚拟变量的交互项-程序员宅基地

文章浏览阅读1.5w次,点赞24次,收藏120次。简单来说就是去量纲后的回归(因为你要比较不同变量之间的显著性的大小,那么带着量纲怎么比,所以先把量纲去掉,然后再比较)官话:为了更为精准的研究影响评价量的重要因素(去除量纲的影响),我们可考虑使用标准化回归系数。_stata两个虚拟变量的交互项

mysql-程序员宅基地

文章浏览阅读203次。有时候安装mysql后使用mysql命令时报错 Can't connect to MySQL server on localhost (10061),或者用net start mysql 时报服务名无效,一般是因为mysql服务没有启动。这时候可以用管理身份运行cmd.exe(注意必须是管理..._c:\program files\mysql\mysql server 5.6\bin>mysqld --install install/remove

亚信科技java笔试题答案_亚信笔试题卷以及答案.docx-程序员宅基地

文章浏览阅读6.2k次,点赞3次,收藏44次。亚信联创科技校园招聘B 卷考试时间60_分钟 _考试方式(闭)卷(本试卷满分 100 分,答案请写在答题卡上)请不要在问卷上答题或涂改,笔试结束后请务必交回试卷部分内容分值备注一、计算机基础40分C/C++语言基础40分技能部分二、二选一JAVA 语言基础40分三、数据库20分总分100 分第一部分——计算机基础一、选择题(每题 2 分,总分 40分)1.CPU 状态分为目态和管态两种..._亚信科技java实习笔试题

三线城市程序员的薪资待遇怎么样?我分享提高java技术水平的几个方法_三线城市学java-程序员宅基地

文章浏览阅读1.3k次。3年对一个程序员来说是非常重要的。像我自己本身就是做程序员的,目前的薪资待遇是13K左右,虽然在我所在的公司不是最高的,但在所在的这个城市的消费水平来说,除了日常的开支,包括房租、水电、伙食、人际交往等费用之外,还能留下一部分闲钱自己存起来。不同城市的薪资待遇是不一样的,这主要是由于当地的消费水平和经济发展水平不同,所以如果你想要更高的薪资待遇,就要考虑在一线城市或者经济发达的城市工作。一个有着丰富工作经验的程序员,他的技能水平、经验和能力都比没有经验的程序员更加出色,所以他们的薪资待遇也会更高一些。_三线城市学java

随便推点

恭迎万亿级营销(圈人)潇洒的迈入毫秒时代 - 万亿user_tags级实时推荐系统数据库设计...-程序员宅基地

文章浏览阅读418次。标签PostgreSQL , 标签 , 推荐系统 , 实时圈人 , 数组 , gin , gist , 索引 , rum , tsvector , tsquery , 万亿 , user , tag , 淘宝背景我们仅用了PostgreSQL的两个小特性,却解决了业务困扰已久的大问题。推荐系统是广告营销平台的奶牛,其核心是精准、实时、..._实时圈人

软件测试风险追踪表_软件测试风险管理表格-程序员宅基地

文章浏览阅读430次。软件测试风险追踪表风险追踪表 项目名称: 填制人: 编号 风险描述 影响 风险等级 发生的可能性 应对策略 状态 责任人 备注 ..._软件测试风险管理表格

AAC ADTS封装实现-程序员宅基地

文章浏览阅读1.2k次。一、AAC音频格式种类有哪些AAC音频格式是一种由MPEG-4标准定义的有损音频压缩格式。AAC包含两种格式 ADIF(Audio Data Interchange Format音频数据交换格式)和ADTS(Audio Data transport Stream音频数据传输流)。ADIF特点:可以确定的找到音视频数据的开始,不需要进行在音视频数据流中间开始的解码,它的解码必须在明确的定义开始。应用场景:常用在磁盘文件中。ADTS特点:具有同步字的比特流,解码可以在这个流中任何位置开始。类似于mp_aac adts

Unity基础概念_unity基本概念-程序员宅基地

文章浏览阅读213次。像要使用Resouce类,必须创建一个 Resouce 文件夹,然后把需要的资源放进去,才可以在代码中设置路径进行访问_unity基本概念

在gitlab中指定自定义 CI/CD 配置文件_gitlab配置cicd-程序员宅基地

文章浏览阅读2.4k次。指定自定义 CI/CD 配置文件,顾名思义就是在项目中指定文件来代替默认的.gitlab-ci.yml文件的方式来运行流水线。以往我们在使用流水线的时候,都是默认将.gitlab-ci.yml文件存在在项目的跟路径下,但是我们也可以指定备用文件名路径,或者不想在每个项目中来维护这个yml文件,那么通过自定义 CI/CD 配置文件便可以实现。_gitlab配置cicd

mysql出现#1063 - Incorrect column specifier for column 'id'的解决方法_sql 错误 [1063] [42000]: incorrect column specifier -程序员宅基地

文章浏览阅读1w次。出现这个表示如果设置了自动增长,字段类型应该设置为int整型。_sql 错误 [1063] [42000]: incorrect column specifier for column 'id' incorrec