Operating system Linux system

Linux operating system

Preliminaries (Operating System):

1, GNU Project , GNU project is a free software project aimed at establishing a fully free and open general of UNIX software platform.

2, the operating system: management computer hardware and software resources of the program, and the operating system need to be addressed such as the management and configuration memory , determine the system resource supply and demand priorities , the control input device and an output device, operating the network and manage the file system and other basic services. Operating system also allows a user to interact with the system interface .

3, the operating system basics : First, the four characteristics: Concurrent : execute multiple programs within the same period of time (note the difference between parallel and concurrent , the former is more than one event at a time, which is more than the same period of the event ); two, sharing : the system resources may be memory into a plurality of concurrently executing threads used together; three virtual : by time division multiplexing (e.g. Time-sharing system) and spatial division multiplexing (e.g., the virtual memory ) technology to a physical entity into multiple virtual ; four asynchronous : the system is in the process of execution of stop-go manner and at an unpredictable rate of advance.

4, and the process line layer: intake layer and a state of multi-layer lines (ready state, execution state, blocking state); queue (ready queue and queue blocking);

5, processes and line layers:

  First, the process is a dynamic program execution time on a data set. Process generally consists of a control program block, the data set, the process consists of three parts. Procedure is used to describe a process to accomplish what features and how to complete; data set is a program during execution of the required resources ; process control block for recording process execution changes in the external characteristics of the process described in the process , the system can use it to control and manage the process , it is the perception of the existence of the system processes only sign .

  Second, the process is a computer program run on a set of data on the activities of the system is the basic unit of resource allocation and scheduling .

  Three , thread also called lightweight processes , it is a basic CPU execution unit , but also process the minimum unit during execution sequence by the thread ID, the program counter, a register set and stack composed. The introduction of the thread reduces the overhead of concurrent execution of the program to improve the operating system of concurrent performance . Multi-line layer shared resource , comprising code segments ( code and constant), the data segment ( global and static variables ), the extended section (heap memory), but each thread has its own stack segment content, registers, stack segment called operating period, used to store all the local variables and temporary variables .

  Fourth, the thread is a physical process is CPU scheduling and dispatch of the basic unit , which is smaller than the process of the basic unit can operate independently.

6, synchronous and asynchronous: synchronization refers to a process in the implementation of a request, if the request takes a while to return information, then this process will have to wait to go until it receives return information only continue execution; is asynchronous refers to the process do not need to have been waiting for it, but to continue to perform the following operations .

Note: 1, the parent and child processes using interprocess communication mechanisms ( https://www.cnblogs.com/xdyixia/p/9257668.html ) , the same process thread through reading and writing data to process variables for communication. More convenient communication between threads.
  2, process synchronization: producer - consumer issues; Dining Philosophers; readers - write the problem; synchronization program to solve: the tube, semaphores.

7, IO model:

  Synchronous IO, Synchronous IO do "IO operation" when the process will be blocked , thus blocking IO, non-blocking IO, IO multiplexing belong to synchronous IO. Non-blocking IOIO recvfrom in the implementation of this system call, if the kernel data is not ready, this time will not block the process. However, when the data are ready kernel, the data from the kernel will recvfrom copied to the user memory , this time process is the block.

  After asynchronous IO, user process initiates read operations, you can immediately start to do other things. On the other hand, from the kernel's point of view, when it is subjected to a asynchronous read, first of all it will return immediately , so do not be any block for user processes. kernel will wait for data preparation is complete, and then copy the data to the user memory, when it's all complete, the kernel will give the user process sends a Signal .

  Blocking IO, in linux, by default, all socket is blocking , blocking IO feature is executed in two stages IO are block. recvfrom system call, Kernel (Real Time Operating System) to prepare the data. The data also did not arrive at the beginning (for example, has not yet received a complete UDP packet ), kernel to wait for complete data. User process here, the whole process will be blocked . When the kernel wait until the data is ready, it will copy the data from the kernel to user memory , and then returns the result kernel, the user process before lifting the state of the block, up and running again.

  Non-blocking IO: non-blocking will block the entire piece big time into N number of small blockage , so the process continue to have the opportunity to 'be' CPU patronize. " That is, each recvform system call (blocking IO) between , cpu's permissions are still in the hands of the process, this time can do other things .

  IO multiplexing: the benefits of select / epoll is that a single process can handle multiple network connections simultaneously IO, the basic principle is to select / epoll this function will all continue socket polling is responsible ( Kernel will "watch" select all responsible for the socket, so the advantage of IO multiplexing can handle multiple connection at the same time ) , when a socket has data ready, notifies the user process calls read, copy data from kernel to user processes .

8, the virtual address: the process of creating load time, their perception gained a continuous memory address space , but in fact the core of the allocated a virtual memory space on logical , and virtual memory and disk via mmap do mapping relations, mapping between virtual memory and physical memory; wait until the program actually run, you need some data, not in the virtual memory page fault will trigger an exception, to copy data.

2, Linux system advantages:

 

Linux operating system:

A, Linux directory system:

 

1, / ~ and:

  / Is the root directory, Linux system has only one / directory; ~ is the home directory, each user has a home directory. If the root user (root, root), - it is represented by: / root; if A is a normal user, ~ represents the: / home / a

2、文件基本属性: 

  一、在Linux中第一个字符代表这个文件是目录、文件或链接文件等。

  • 当为[ d ]则是目录
  • 当为[ - ]则是文件;
  • 若是[ l ]则表示为链接文档(link file);
  • 若是[ b ]则表示为装置文件里面的可供储存的接口设备(可随机存取装置);
  • 若是[ c ]则表示为装置文件里面的串行端口设备,例如键盘、鼠标(一次性读取装置)

  二、文件权限,前10个字符表示文件类型和权限,读r(4),写w(2),执行x(1),没有权限-。(注:可用三位二进制数表示权限

3、绝对路径和相对路径:

  绝对路径:路径的写法,由根目录 / 写起,例如: /usr/share/doc 这个目录;相对路径:不是由 / 写起,例如由 /usr/share/doc 要到 /usr/share/man 底下时,可以写成: cd ../man

 

二、Linux操作系统常用命令操作:

1、文件操作:ls/file、cp、mv、ln、rm、tar、chmod/chowm/charp/touch

2、目录操作:mkdir、rmdir、cd、pwd

3、用户切换:su、sudo、login;passwd;exit/reboot、init0/shutdown、halt/poweroff

4、获取帮助:[命令]+:-h、-?、--help;man、info+[命令]

 

三、Linux操作系统,shell编程:

1、变量、流、管道;

变量是一种临时记录字符串的方式,export(变量的赋值);$(提取变量的值)export name=$(pwd)/tar.tar

是打开文件的一种形式,cat、echo、sort、uniq、head、tail、wc;>(文件内容删除)、>>(在文件的尾部增加输出的内容)格式:命令>(>>) 文件,如 cat greptest >liutest

管道(|是一种进程的通信方式,将前一个命令的输出发送给后一个命令。grep "grep" greptest | tail -n 3

2、进程操作:

进程查看,ps 

进程控制,kill;语法:kill { [{ -信号 | -s 信号}]  进程号 | -l [信号]  } -s 信号 或者 -信号 :发送信号到指定进程;-l 信号:将信号数值翻译成信号的名称

进程切换,bg和fg

3、网络操作

网络配置:ifconfig

ping:ping [参数] 目标地址

ARP:将IP数据报转换为以太网的帧,并发送给临近的网络接口

FTP:FTP服务器主要提供远程文件下载服务

4、系统变量(表示特殊含义的系统变量):$+n/#/0/?/*/@/$/!

5、shell编程设计:

  变量、条件测试>>文件状态测试、逻辑操作(-a、-o、!)、字符串测试(-z、n;=、!=、<、>)、数值测试(-eq、-ne;(-lt、-le)、(-gt、-ge))

  流程控制语句:if;case(字符串str所匹配的情况,执行相应的程序分支);while、until;for

  常用命令:

    read;

    select;

    大括号{  }(将一个非整体的字符串强制解释成一个整体如:[$1 = '-n'] && { echo hello" ls });

    "(单引号),取消所有的转义符号、通配符和分隔符、""(双引号),取消通配符和分隔符的转义,但是对于变量依然进行转义。'12 $a'"12 $a"中的a=12两者表达的意思不同!

    funname(){...}函数

 

 

四、Linux操作系统 vi/vim编辑器:

1、三种操作模式:命令模式、底行模式、文本输入模式

  默认模式是命令模式,在命令模式下模式切换为底行模式;按i、a、o等,命令模式切换为文本输入模式;两种模式按ESC可以切换为命令模式。

  底行模式用于处理带有参数的命令

2、可视模式:命令模式下按v,模式切换为可视模式,按v退出可视模式。

3、取代模式(Replace mode-按键r和R):r 只会取代光标所在的那一个字符一次;R会一直取代光标所在的文字,直到按下 ESC 为止。

4、vi键盘图

 

五、Linux操作系统 linux yum 命令:

1、yum 语法:yum [options] [command] [package ...]

2、yum常用命令:

  1.列出所有可更新的软件清单命令:yum check-update

  2.更新所有软件命令:yum update

  3.仅安装指定的软件命令:yum install <package_name>

  4.仅更新指定的软件命令:yum update <package_name>

  5.列出所有可安裝的软件清单命令:yum list

  6.删除软件包命令:yum remove <package_name>

  7.查找软件包 命令:yum search <keyword>

  8.清除缓存命令:

    yum clean packages: 清除缓存目录下的软件包

    yum clean headers: 清除缓存目录下的 headers

    yum clean oldheaders: 清除缓存目录下旧的 headers

    yum clean, yum clean all (= yum clean packages; yum clean oldheaders) :清除缓存目录下的软件包及旧的headers

 

Guess you like

Origin www.cnblogs.com/yinminbo/p/11723783.html