Linux 架构与基本命令学习笔记

I. The UNIX operating systemUnix

系统包括三部分:kernel, shell, programs

Kernel

Kernel负责给programs分配时间和内存,并负责文件储存和系统呼叫的通讯响应。

比如:当用户键入rm myfile,shell在filestore(我的理解是存储所有program的地方)中搜寻包含着rm程序(program)的文件(file),然后shell通过系统呼叫(system call)请求kernel,来对myfile执行程序rm。当移除过程结束,shell返回UNIX一个提示符%给用户,表明等待下一个命令。

Shell

shell作为用户与kernel之间的界面。当用户登录后,程序shell就可以使用。shell是一个命令行解释器。(command line interpreter (CLI))它解释用户所输入的命令并安排它们执行。这些命令就是其程序本身,当他们结束后,shell返回% 。

II.  Files and processes                                    

在UNIX中所有东西无非是文件或者是进程(file or process)

A process is an executing program identified by a unique PID (process identifier).

进程指的是执行中的程序,并有独特的ID。

A file is a collection of data. They are created by users using text editors, running compilers etc.

文件指的是数据存储。这些可以被用户利用文本编辑器和编译器创造。

III. The Directory Structure

路径根节点被称为root(被表示为  / )

IV.常用命令

括号数目代表 http://www.ee.surrey.ac.uk/Teaching/Unix/unix8.html/ 的课数

一、路径命令(2)

1. ls (list)

2. mkdir (make directory)

3. cd (change directory)

4. (..) means the parent of the current directory,

5. (.) means the current directory, so typing

6. pwd (print working directory)

7. ~ (your home directory)

8. grep 根据制定文字或模式来寻找文件

二、改变输入输出方向(redirection)(3)

通常,UNIX的标准输出命令是写到终端,标准输入命令是由键盘写入。

 可用cat(catenate连接,使连续)和sort(排序)命令加上符号<和>表示字符的流向。

三、(4)

四、(5)

1. 文件使用权

2. 使程序挂在终端或挂在后台,列出所、悬挂、结束程序

五、(6)

df :查看filesystem的余量

du:没啥用

gzip:压缩文件

gunzip:解压缩

zcar :直接读取解压文件,而不解压

file:查看文件类型

diff:查看两个文件之间的差别

find:可按照日期、文件大小或类型、文件名来搜寻文件

history:查看历史输入命令

六、安装软件所需操作(7)

  • Locate and download the source code (which is usually compressed)
  • Unpack the source code
  • Compile the code
  • Install the resulting executable
  • Set paths to the installation directory

1 编译源码

将高级语言(源码source code)转为汇编语言(assembly language code),然后再转为电脑能识别的目标代码(object code),最后把已有函数库(library)连接(link)到目标代码上,就产生了可执行程序(编译完成)。

2 make指令

make可以用来管理大型程序,其检查程序中改变的部分,并只编译这些改变过的部分。

make从一个叫makefile的文本中获得如何编译软件的信息,比如在可执行文件中加入debug,安装在哪里,还包括一些信息文件manual pages, data files, dependent library files, configuration files

3 configure指令

configure通过判断环境变量来创建makefile。(由于UNIX的衍生系统繁多,导致这版本之间可能不能很好的互相利用文件

  • cd to the directory containing the package's source code.
  • Type ./configure to configure the package for your system.
  • Type make to compile the package.
  • Optionally, type make check to run any self-tests that come with the package.
  • Type make install to install the programs and any data files and documentation.
  • Optionally, type make clean to remove the program binaries and object files from the source code directory 

路径带有--prefix的选项会保存计算机的独立性文件,比如documentation, data and configuration files

路径带有--exec-prefix的选项会保存计算机的依赖性文件,比如executables (可执行文件)。

4 strip命令

可以减少编译degub部分,加快编译速度:make install-strip。

七、变量

(本人的理解是变量等同于系统信息,如显示当前路径等。)

当运行program时,信息以变量的方式从shell传递到program。

标准UNIX变量有两类,环境变量(大写)和shell变量(小写)。后者仅是用于shell的当前实例和短时间的工作。前者登录时设置的环境变量在会话期间有效。

shell和environment的变量操作命令区别在于后者加多env。

猜你喜欢

转载自blog.csdn.net/linyijiong/article/details/81367635