learn the shell

what is the shell?

when we speak of the command line,we are really to the shell.Actually the shell is a program that takes keyboard commands and passes them to the opreating system to carry out.

Now I start the virtualizer, I use the Ubuntu ,its version number is 14.04.2.I get in a graphical user interface,press ctrl + alt + F1(To switch from one virtual console to another, press Alt and F1-F6. To return to the graphical desktop, press Alt-F7.)

Now you can see

ubnutu login:
Password

Enter your user name,and your password. you should know that the password input will not be displayed

And you can see

user_name@ubnutu:~$

this is called a shell prompt


here are some knowledge points:

  • If we press the up-arrow key ,we can see the command history
  • we cannot use Ctrl-c and Ctrl-vto perform copy and paste inside a terminal window.But when we choose something,we can press the middle mouse button ,which will cause the text to be pasted at the cursor location
  • a few simple commands:
    • date:to display the current time and date.

      username@ubuntu:~$ date
      Tue Mar 27 21:43:03 PDT 2018

    • cal:to display a calendar of the current month.
    • df:to see the current amount of free space on your disk drives
    • free:to display the amount of free memory.
  • We can end a terminal session by either closing the terminal emulator window, or by entering the exit command at the shell prompt

文件系统中跳转

首先我们先了解几个概念

  • pwd-打印出当前工作目录名
  • cd -更改目录
  • ls - 列出目录内容

Linux,以分层目录结构来组织所有文件。 这就意味着所有文件组成了一棵树型目录(有时候在其它系统中叫做文件夹), 这个目录树可能包含文件和其它的目录。文件系统中的第一级目录称为根目录。 根目录包含文件和子目录,子目录包含更多的文件和子目录

绝对路径

绝对路径开始于根目录,紧跟着目录树的一个个分支,一直到达所期望的目录或文件。

相对路径

相对路径开始于工作目录。 为了做到这个(用相对路径表示), 我们在文件系统树中用一对特殊符号来表示相对位置。 这对特殊符号是 “.” (点) 和 “..” (点点)。

符号 “.” 指的是工作目录,”..” 指的是工作目录的父目录

在几乎所有的经情况下,我们都可以省略./ 例如:

cd /usr/bin //绝对路径
cd ./bin //相对路径
cd bin //相对路径省略./

这些的效果都是一样的


有用的快捷键

cd 更改工作目录到家目录
cd - 更改工作目录到先前的工作目录
cd ~user_name 更改工作目录到用户家目录

ls -a 显示以“.” 字符开头的隐藏文件


一些注意事项:

  1. 文件名和命令名是大小写敏感的
  2. 文件名的标点符号仅限用 .,-,_。不要在文件名中是用空格,如果想表达词语的空格,用下划线字符来替代

探究操作系统

选项和参数

大多数命令是按照以下格式

command -options arguments

命令名 + 更正命令行为的选项 + 参数

下面我们给出ls命令的选项


长格式输出

当我们在在某个目录下输入

ls -l

我们可以看到

(ls -l)

依次表达的意思是

对于文件的访问权限

文件的硬链接数目

文件所有者的用户名

文件所属用户组的名字

字节数表示文件大小

最新修改日期

文件名

这些具体的含义我们会在之后的章节中学到


确定文件类型

我们调用
file filename

命令去确定文件的类型


用 less 浏览文件内容

less 命令是一个用来浏览文本文件的程序。

通过less filename来使用

当我们查看文件系统的时候 我们可以使用一下的命令

Learn the shell的更多相关文章

  1. Spring Shell入门介绍

    目录 Spring Shell是什么 入门实践 基础配置 简单示例 注解@ShellMethod 注解@ShellOption 自定义参数名称 设置参数默认值 为一个参数传递多个值 对布尔参数的特殊处 ...

  2. MongDB篇,第三章:数据库知识3

    MongDB    数据库知识3 修改器 $inc 对某个域的值进行加减修改 $mul 对某个域的值进行乘法修改 $min 如果筛选的文档指定的值小于min则不修改,如果大于min 给定的值则修改为m ...

  3. learn shell

    the basic shell skills.   Bourne shell sh ksh Bash psh zsh C shell csh tcsh   [root@bogon temp]# cat ...

  4. (copy) Top Ten Reasons not to use the C shell

    http://www.grymoire.com/Unix/CshTop10.txt ========================================================== ...

  5. Shell脚本语法

      索引 1. 第一行必须是"#!/bin/sh" 2. 注释:一行开头为 # 3. 定义变量 4. 逻辑符号 5. 接收参数 6. 控制流:if/then/elif/else/f ...

  6. 提高神经网络的学习方式Improving the way neural networks learn

    When a golf player is first learning to play golf, they usually spend most of their time developing ...

  7. 终端执行python shell的方法

    假设有一个Py文件,放在下PycharmProjects/learn下,文件名是 myfile.py. 1.打开终端输入python3进入2.在shell下 输入import sys 回车3.输入 s ...

  8. Managing linux Shell Jobs

    Managing Shell Jobs   When moving jobs between the foreground and background, it may be useful to ha ...

  9. 转:linux执行shell脚本的方式及一些区别

    假设shell脚本文件为hello.sh放在/root目录下.下面介绍几种在终端执行shell脚本的方法: [root@localhost home]# cd /root/ [root@localho ...

随机推荐

  1. 递归遍历目录拷贝cdh下的lib到一个目录

    destpath='/home/hadoop/soft/hadoop-2.0.0-cdh4.5.0/cdhlib/'jarpath='/home/hadoop/soft/hadoop-2.0.0-cd ...

  2. CentOS6.5 配置IP的两种方式

    1.dhcp动态获取ip 编辑配置文件 /etc/sysconfig/network-scripts/ifcfg-eth0 ,配置如下: [root@localhost ~]# vi /etc/sys ...

  3. window环境下安装node.js

    在使用sublime text 3 过程中,node.js装了好几次都没有成功,今天终于成功了,现将安装过程整理一下. 安装过程中主要参考了以下代码: 第一,下载文件 https://nodejs.o ...

  4. BeanNameAware接口和BeanFactoryAware接口(转)

              迄今为止,所接触到的Bean都是“无知觉”的,就像黑客帝国中机械工厂里面“养殖”的人类,他们虽然能完成一定的功能,但是根本不知道自己在工厂(BeanFactory)中的代号(id) ...

  5. axios进行ajax请求得不到数据,cookie无法携带问题

    这个坑也是很早之前踩过,今天做项目的时候居然忘了,怎么都拿不到数据,果然好记性不如烂笔头,决定写篇博客来祭奠下我的猪脑子: 原因可能就是你发送请求的时候,需要设置cookie,然而你的cookie并没 ...

  6. 史上最强大的wordpress后台框架redux-framework安装及使用

    redux-framework的相关链接 Redux的官方网站:https://reduxframework.com/ Redux文档查询:https://docs.reduxframework.co ...

  7. photoshop入门笔记1:PS的快捷键

    PS部分快捷键: 1.魔棒的作用:比较快捷的抠图工具,对于一些分界线比较明显的图像,通过魔棒工具可以很快速的将图像抠出,魔棒的作用是可以知道你点击的那个地方的颜色,并自动获取附近区域相同的颜色,使它们 ...

  8. Dropping Balls(小球下落)

    紫书P148,例题6-6 Sample Input 4 2 3 4 10 1 2 2 8 128 Sample Output 12 7 512 3 255 这应该不仅仅是一棵完全二叉树,题目中说保证所 ...

  9. 17-比赛1 F - 较小元素 Weak in the Middle (set)

    Seg-El has last chance to make the final changes in order to prevent the destruction of Krypton. He ...

  10. Docker构建nginx+uwsgi+flask镜像(二)

    Dockerfile搭建环境并打包应用 在上一章Docker构建nginx+uwsgi+flask镜像(一)的学习中,我们学会用命令行一句一句在alpine环境中搭建nginx+uwsgi+flask ...