2019-2020-1 20199301 "Linux kernel principle and Analysis" in the second week of work

The second week of Linux Learning Notes

File packing and decompression


  • tar tool package
    unpack the tar and compress commands are the same, only different parameters, to use more convenient.
    When you create a package file name must follow the -f after unpack a file ( -x parameter) to specify the path of an existing directory ( -c parameter).

    Each content and codes:

  • See only puzzling package file ( -t parameter):
tar -tf shiyanlou.tar
  • Use tar backup files retain the properties (file -p parameter), the backup link to the source file rather than the link itself ( -h parameter):
tar -cphf etc.tar /etc
  • tar may just want to change a parameter to create compressed files in different formats (add a parameter on the basis of tar file created on the -z ).
    Use gzip compressed files:
tar -czf shiyanlou.tar.gz/home/shiyanlou/Desktop
  • Decompression (* .tar.gz)
tar -xzf shiyanlou.tar.gz

- ### of the parameters and formats:

to sum up

  • zip:
    • Packaging: zip something.zip something (catalog please add -r parameter)
    • Unpack: unzip something.zip
    • Specify the path: -d parameter
  • taking:
    • 打包:tar -cf something.tar something
    • 解包:tar -xf something.tar
    • Specify the path: -c parameter


      Disk management and file system operations


  • Df command using the capacity of the disk appears as shown:

    FIG / dev / sda2 a hard disk partition corresponding to the host, the number indicates the partition numbers, the numbers in front of the letter a represents a few hard drives (possibly movable disk), 1K a denotes a display capacity, corresponding to the back and available capacity to the used block size represents the size of the disk block in a manner
  • Use the du command to view the directories capacity:

    code -d parameter specifies the directory to see the depth. NOTE: du (estimate file space usage) command df (report file system disk space usage ) only one word command, easy to remember mix.
  • Disk Management: The dd command from the standard input standard output to the user's input, as shown in screenshot:

    command bs specifies the block size, COUNT is used to specify the number of blocks.
  • Mkfs command to format the disk, simply use the mkfs command to the virtual disk images formatted as ext4 file system code as follows:
sudo mkfs.ext4 virtual.img

Help command under Linux


  • What is the built-in command, external command what is it?
    • Built-in commands : shell is actually part of the program, which contains some of the more simple Linux system commands that are written in bash builtins inside source, identified by the shell program and complete the run within the shell program, usually in shell was loaded and resident in system memory to load Linux system running. And resolve internal command shell do not need to create a child process, so its implementation faster than external commands.
    • External command : utility is part of the Linux system, because the utility's usually more powerful, so it contains the amount of the program will be great, when the system is not loaded with the system is loaded into memory, but when needed to be transferred to memory. Although it is not included in the shell, but the command execution process which is controlled by a shell program. External commands are additionally installed outside the Bash, usually placed in / bin, / usr / bin, / sbin, / usr / sbin like.
  • help command: brief help shell built-in commands for display.
  • man command: is the system displays the contents of the manual pages.
  • info command: the GNU project from the Free Software Foundation, the GNU hypertext help system that can show the GNU more complete information.


    Linux Task Scheduler crontab


  • crontab command read instruction from the input device, and stored in crontab file, for later read and executed.


Computers Work Study Notes


Highlights:

  • How computers work, work involving stored program computer model, the basic assembly language, C language program compiled assembly code out how the working model step by step performed on the stored program computer.
    Key Analysis:
  • Related function call stack assembly instructions.


    1.1 working model stored program computer


  • Von Neumann architecture:
    • Von Neumann noted that programs and data are logically the same, the program may be stored in a memory.
  • Highlights von Neumann architecture include:
    • Arithmetic unit, a memory, a controller, an input device and an output device composed of computer hardware.
    • Internal binary representation using computer instructions and data.
    • The basic meaning of the stored program
      von Neumann architecture take enough of the core is stored program computer.


      1.2 x86-32 assembler basis


      x86-32CPU memory

      8086CPU total of 14 16-bit registers are:

  • General-purpose registers
    • Data register
      • AX: accumulation registers, the accumulator has become
      • BX: base address register
      • CX: Counter Register
      • DX: data register (and the characteristics can be divided into: divided into two separate 8-bit registers)
    • Pointer register
      • SP: Stack pointer register
      • BP: base pointer register
    • Index register
      • SI: Source index register
      • DI: object index register
  • Control register
    • IP: instruction pointer register
    • FLAG: Flag Register
  • Segment register
    • CS: Code segment register
    • DS: data segment register
    • SS: stack segment register
    • ES: additional segment register

      32-bit registers (more versatile):

  • Four data registers (EAX, EBX, ECX, EDX)
  • 2 and index pointer register (ESI, EDI)
  • 2 pointer register (ESP, EBP)
  • Six segment registers (ES, CS, SS, DS, FS, GS)
  • An instruction pointer register (EIP)
  • A flag register (EFLAGS): to save the current state of some of
    all of the registers beginning with E, usually 32 bits.
  • EBP is the stack base pointer, the more important
    - the ESP is also important, it is the top of the stack register stack

    64-bit registers

  • We are prefixed with a 64-bit register of "R"
  • Flags changed to RFLAGS, EIP changed to RIP

    Data Format

  • Intel specification language word ** * denotes 16-bit data types.
  • In TA32 double word indicates 32-bit data types.
  • In 86-6464 called median quadword .


    Addressing


  • Assembly instructions
    • Opcode
    • Number of operations
      • Immediate constant
      • Register number
      • Memory reference
  • The most common is the assembly instructions mov instruction, movl l refers to the 32-bit, movb the means 8 b, movw w refers to the 16-bit, movq q refers to the 64-bit.
  • Register Addressing: As not deal with memory and% eax,% of which after the opening with a register name.
  • Addressing immediately: Use the beginning of the $ followed by a number.
  • Direct addressing: direct use of a value, at the beginning there is no $ symbol.
  • Indirect Addressing: add a small register is bracketed. Add a small brackets indicate the data stored in the memory address.
  • Indexed Addressing: In the original address plus a number 4, is added to the value stored in the register 4.


    Common assembly instructions


  • All uppercase letters are generally Intel assembly, all lowercase letters are generally AT & T assembler
  • Several important commands: pushl, popl and call / ret.
pushl %eax

Is the value of the EAX register stack overwhelming stack.

popl %eax

Is removed from the stack one memory cell stack, EAX register into the top of the stack from the position of the stack, called the stack.

call 0x12345

call instruction is a function call, a call address. In terms of security reasons EIP register can not be directly used and modified.
The call corresponds ret instruction, a function return instruction ret. call instruction is a C language we call a function, ret instruction is a push to restore the value of the function call EIP EIP register to register. Instructions with a "(*)" means that these instructions are not directly used by the programmer, is directive.


Experiments problems and solutions:


  • Compiled into assembly code is performed during an instruction input errors occurred during the experiment shown in FIG question:
  • After performing the correct number of spaces and regulating corrected case is solved, according to FIG final designation operation


    to sum up

  • The details easily mistake the case of letters, a spacebar forget the middle when the input command.
  • The greatest difficulty encountered in the learning process of this chapter is compiled into the assembly code for familiarity and interpretation of stack space and stack space each line of code to generate a change in how each line of code and other issues.
  • Execution of the book explain how changes in the data register after each line of code, when to register before executing the next line of code and other issues need to be familiar repeatedly, over and over again from scratch read the code can slowly adjust to changes in the law.

Guess you like

Origin www.cnblogs.com/lsqz/p/11561419.html