The Linux Command Line 1-10章总结

原创 2016年08月28日 17:34:12

之前用ubunut大概有一个学期吧,尝试做过网站,中间遇到问题都是依靠搜索引擎,觉得还是有必要系统的学习Unix/Linux。尝试了两章Advanced Programming in the Unix Environment,感觉还是有点吃力,之前有看过《鸟叔的Linux私房菜》觉得不是我的菜。直到发现The Linux Command Line,嗯,TLCL是我的菜。

  • 一些重要的话
    Graphical user interfaces makes easy tasks easy, while command line interfaces make difficult tasks possible.

    One of the common ideas in Unix-like operating system is that “everything is a file”.

    In fact one of the most cherished goals of the command line is laziness; doing the most work with the fewest keystrokes.

  • 一些重要的事实
    When we speak of the command line, we are really referring the shell.

    Each time you type a command line and press the enter key, bash performs several processes upon the text before it carries out your command.

    When the enter key is pressed, the shell automatically expands any qulifying characters on the command line before the command is carried out.

    bash: a shell program from GNU program Bounce again shell

    when using a graphical user interface we need another program called terminal simulator to interact with shell

    virtual terminal: ctrl+alt+{F1-F6}

    User’s home directory is symbolized by the “~” character
    “./” is implied in almost all cases.

    It is possible to put more than one command on a line by separating each command with a semicolon character.

    The multi-user capability of Linux is not a recent “innovation”, but rather a feature that deeply embedded into the design of the operating system.

    We rarely want files and directories have the same permissions.

    One important difference between su and sudo is that sudo does not start a new shell, nor does it load another users environment.

  • 一些命令
    cd:change the working directory to your home directory
    cd-:change the working directory to the previous directory
    file:determine file type
    less:view file contents
    type:indicate how a command name is interpreted
    which:display which executable program will be executed
    man:display a commands manual page
    apropos:search the manual page names and descriptions
    info: display a commands info entry
    whatis:display a very brief description of a command
    alias:create an alias for a command
    cat:concatenate files
    sort:sort lines of text
    uniq:report or omit repeated lines
    wc:print newline, word, and byte counts for each line
    head:output first part of the file
    tail:output last part of the file
    tee:read from standard input to standard output and files
    echo: display a line of text
    clear: clear the screen
    history: display the content of the history list.
    id: display user identity
    chmod: change a files mode
    umask: set the default file permission
    su: run a shell as another user
    sudo: execute a command as another user
    chown: change files owner
    chgrp: change files group ownership
    passwd: change a users password

  • 一些参数
    -a:archive, copy the files and directories and all of their attributions, including ownerships and permissions. Normally, copies take on the default attributes of the user performing the copy.
    -i:interactive, if this option is not specified, command will silently overwrites files.
    -u:update
    -v:verbose, display informative messages as the copy is performed
    -f:force, ignore nonexistence files and do not prompt. This overwrite -i.

  • 符号连接和硬连接

    • ln file link
      Hard links are the original Unix way of creating links, compared to symbolic links. By default, every file has a single hard link that gives file its name. When create a hard link we create an additional directory entry for a file.
      Hard links have two important limitations. It may not reference a file that is not on the same disk partition as the link itself. And a hard link may not link a directory.
      A hard link is indistinguishable from the file itself. When a hard link is detected, the link is removed but the contents of file itself continue to exist (that is its space is not deallocated) until all links to the file are deleted.
    • ln -s file link
      Symbolic links are created to overcome the limitation of hard links. Symbolic links work by creating a special type of file that contain a text pointer to the reference file or directory.
      Using relative pathnames is more desirable because it allows a directory containing symbolic links to be renamed and/or moved without breaking the links.
      One thing to remember about symbolic links is that most file operations are carried out on the links’ target, not the link itself. rm is an exception.
  • 到底什么是命令?
    A command can be one of four things

    • An executable program like all those files we saw in /usr/bin. Within this category, programs can be compiled binaries such as programs written in C and C++, or programs written in script languages such as shell, perl, python, ruby, etc.
    • A command built into the shell itself. bash supports a number of commands internally called shell builtins. For example the cd command.
    • A shell function. These are miniature shell scripts incorporate into the environment.
    • An ailas.
  • 重定向
    When we redirect output with the “>” redirection operator, the destination file is always rewritten from the beginning. Use the “>>” we can append redirected output to a file instead of overwriting the file from the beginning.

    To redirect standard error we must refer to its file descriptor.

    Use “&>” redirects both standard output and standard error to files.

    The ability of commands to read data from standard input and send to standard output is utilized by a shell feature called pipelines. Using the pipe operator “|”, the standard output of one command can be piped into standard input of another.

  • expansion
    The mechanism by which wildcards work is called pathname expansion.

    With brace expansion, you can create multiple text strings from a pattern containing braces.{}

    Parameter expansion many of its capabilities have to do with the systems ability to store small chunks of data and to give each chunk a name. $

    Command substitution allows us to use the output of a command as expansion. $()

    The shell provides a mechanism called quoting to selectively suppress unwanted expansions.

    If you place text inside double quotes, all the special characters used by shell lose their special meaning and are treated as ordinary characters. The exceptions are $, (back-slash), `(back-quote). This means word-splitting, pathname expansion, tilde expansion and brace expansion are suppressed but parameter expansion, arithmetic expansion and command substitute are still carried out.

    Single quotes suppress all expansions.

版权声明:本文为博主原创文章,未经博主允许不得转载。

Python Shell(command line模式和GUI模式)区别

http://www.crifan.com/how_to_do_python_development_under_windows_environment/
  • u010807846
  • u010807846
  • 2014年08月07日 14:28
  • 3765

Linux各种问题解决方案

1. build linux kernel的错误 cc1: error: unrecognized command line option "-mlittle-endian" cc1: error: ...
  • tody_guo
  • tody_guo
  • 2013年06月06日 14:49
  • 9274

linux kernel的cmdline参数解析原理分析

依据我的思路(时间顺序,如何开始,如何结束),首先看kernel下2种参数的注册。 第一种是kernel通用参数,如console=ttyS0,115200 root=/rdinit/init等。这...
  • skyflying2012
  • skyflying2012
  • 2014年11月15日 09:43
  • 21396

新手学Linux(六)----安装Nginx

Nginx安装环境 编译安装 启动Nginx 停止Nginx 方式一快速停止 方式二完整停止 重启Nginx 方式一先停止再启动 方式二重新加载配置文件 开机自启动Nginx 编写shell脚本 设置...
  • u010853701
  • u010853701
  • 2016年07月29日 15:36
  • 2901

Linux内核强制使用自配置的cmdline

开发过程中遇到一些问题,需要改cmdline。cmdline在不同的平台上有不同的改法,有的单独存在于一个分区中,有的使用的是uboot,需要在启动过程中中断启动并进行手动修改,也有的平台上使用的是u...
  • kangear
  • kangear
  • 2016年07月21日 18:33
  • 4485

两种安装command line tools安装方法

退出xcode,使用命令在线安装。 打开终端,输入命令:xcode-select --install   选择“安装”,然后同意安装协议。...
  • yangpansky
  • yangpansky
  • 2013年12月03日 13:46
  • 6645

【翻译】【技术】Java入门:Command-Line Arguments

转自  http://docs.oracle.com/javase/tutorial/essential/environment/cmdLineArgs.html 有空翻译,coming soon....
  • antchen88
  • antchen88
  • 2017年02月23日 15:31
  • 1435

MAC下检查是否安装command line tools 工具

怎样判断「Command Line Tools」是否已经安装了呢? 由 Sean.Lv 发布于 2013年10月26日  无人欣赏。 升级到OS X Mavericks和Xcode5之后迷茫...
  • HK_5788
  • HK_5788
  • 2016年01月12日 17:21
  • 4385

发布sqlite在win下自动下载编译开源项目

为了维护方便,将其开源了。 代码在:http://code.google.com/p/sqlite-autobuild-win/原理比较简单:提供一下版本号,执行脚本sqlite_build.bat ...
  • iihero
  • iihero
  • 2013年12月28日 10:37
  • 2228

直接点击 MySQL Command Line Client,输入密码后窗口闪退的解决办法

一、出现的问题 打开Mysql,点击 MySQL Command Line Client,输入密码后,窗口闪了一下就退出,退出的时候隐约看到了ERROR提示。首先想到的是密码错误,但是在核对了密码之...
  • Kenny_zhang1130
  • Kenny_zhang1130
  • 2016年07月26日 10:29
  • 3737
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:The Linux Command Line 1-10章总结
举报原因:
原因补充:

(最多只允许输入30个字)