Get along well with Linux operating system

Operating system development history

A computer system with only hardware and no software is called “ Bare pager ”, It's hard for us to use “ Bare pager ” To complete the daily work of computer ( Such as storage and computation ), So we must use specific software to control the work of hardware . The software closest to the computer hardware is the system software , The most important one is “ operating system ”.“ operating system ” It is to control and manage the whole computer hardware and software resources 、 Resource allocation and task allocation 、 A collection of programs that provide interfaces and environments for system users and other software .

No operating system ( Manual operation )

At the beginning of the computer, there was no operating system , People first take the program tape ( Or card ) Put on the computer , Then start the input machine and send the program to the computer , Then start the program through the console switch . When the program is finished , Printer output calculation results , Users remove and remove the paper tape ( Or card ). The second user is on the computer , Repeat the same steps . During the whole process, the user monopolizes the machine ,CPU Waiting for manual operation , The utilization rate of resources is very low .

Batch system

First, start a monitoring program on the computer , Under the control of the supervision procedure , The computer can automatically 、 To process one or more users' jobs in batches . After finishing a batch of homework , The degree of supervision is read from the input machine and stored in the tape drive . Follow the steps above to repeat the task . The supervision program is constantly dealing with various operations , Realize the automatic transfer of work , Reduce the establishment time and manual operation time of the job , Improve the utilization of computer resources . Batch processing system can be divided into single batch processing system 、 Multiprogrammed Batch Processing System 、 Online batch system 、 Offline batch system .

Time sharing system and real-time system

Time sharing system is to divide the running time of the processor into very short time slices , Allocate processors to online jobs in turn according to time slice . If a job cannot complete its calculation in the time slice assigned to it , Then the operation is temporarily interrupted , Give up the processor to another job , Wait for the next round of scheduling before continuing its operation . Because the computer is fast , The job rotates quickly , The feeling for each user is that he owns a computer . And each user can send all kinds of operation control commands to the system through his own terminal , In full human-computer interaction , Complete the operation of the job . In order to solve the problem that the time-sharing system cannot respond to the user's instructions in time , There is also the ability to complete event handling in a strict time frame , A real-time system that responds to random external events in a timely manner .

General operating system

  1. 1960s:IBM Of System/360 Series machines have a unified operating system OS/360.

  2. 1965 year :AT&T Bell Labs joined in GE and MIT We started to develop our cooperation plan MULTICS.

  3. 1969 year :MULTICS Project failure ,Ken Tompson Idle at home , For fun “Space Travel” The game used assembly language has been eliminated at that time PDP-7 Developed on Unics.

  4. 1970 year ~1971 year :Ken Tompson and Dennis Ritchie use B Language in PDP-11 It's rewritten on Unics, And in Brian Kernighan Under the suggestion of Unix.

  5. 1972 year ~1973 year :Dennis Ritchie Invented C Language to replace the less portable B Language , And it turns on C Language rewriting Unix The job of .

  6. 1974 year :Unix Introduced the milestone significance of the 5 edition , Almost entirely C Language to achieve .

  7. 1979 year : from Unix The first 7 version ,AT&T Release new terms of use , take Unix Privatization .

  8. 1987 year :Andrew S. Tanenbaum In order to be able to explain the details of operating system operation to students in class , Decide not to use any AT&T Under the premise of source code , Self development and Unix Compatible operating system to avoid Copyright Disputes , The system was named Minix.

  9. 1991 year :Linus Torvalds While studying at the University of Helsinki in Finland , Try to Minix Do some development work , But because Minix Just an operating system for teaching purposes , It's not powerful , For the convenience of reading, writing and downloading files in the school's newsgroup and email system ,Linus Write the disk driver and file system , These things form Linux The prototype of the system kernel .

Linux summary

Linux It's a universal operating system . An operating system is responsible for task scheduling 、 Memory allocation 、 Processing peripherals I/O Wait for the operation . The operating system is usually made up of the kernel ( Run other programs , Manage like disk 、 Printer and other hardware equipment core program ) And system programs ( Device drivers 、 The basement 、shell、 Service procedures, etc ) Two parts .

Linux The core is the Finn Linus Torvalds Developed , On 1991 year 9 Published in . and Linux The operating system serves as Internet The product of the times , It is developed by many developers all over the world , It's a free operating system ( Note that freedom and free are not the same concept , To understand the difference between the two, click here ).

Linux System advantages

  1. General operating system , Not bound to specific hardware .
  2. use C Language writing , Strong portability , There's a kernel programming interface .
  3. Support multi-user and multi task , Support secure hierarchical file systems .
  4. Lots of utilities , Perfect network function and powerful supporting documents .
  5. Reliable security and good stability , More developer friendly .

Linux System release

  1. Redhat
  2. Ubuntu
  3. CentOS
  4. Fedora
  5. Debian
  6. openSUSE

Basic commands

Linux System The command is usually in the following format :

 Command name [ Named parameters ] [ Command object ]
  1. Get login information - w / who / last/ lastb.

    [root ~]# w
    23:31:16 up 12:16, 2 users, load average: 0.00, 0.01, 0.05
    USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
    root pts/0 182.139.66.250 23:03 4.00s 0.02s 0.00s w
    jackfrue pts/1 182.139.66.250 23:26 3:56 0.00s 0.00s -bash
    [root ~]# who
    root pts/0 2018-04-12 23:03 (182.139.66.250)
    jackfrued pts/1 2018-04-12 23:26 (182.139.66.250)
    [root ~]# who am i
    root pts/0 2018-04-12 23:03 (182.139.66.250)
    [root ~]# who mom likes
    root pts/0 2018-04-12 23:03 (182.139.66.250)
    [root ~]# last
    root pts/0 117.136.63.184 Sun May 26 18:57 still logged in
    reboot system boot 3.10.0-957.10.1. Mon May 27 02:52 - 19:10 (-7:-42)
    root pts/4 117.136.63.184 Sun May 26 18:51 - crash (08:01)
    root pts/4 117.136.63.184 Sun May 26 18:49 - 18:49 (00:00)
    root pts/3 117.136.63.183 Sun May 26 18:35 - crash (08:17)
    root pts/2 117.136.63.183 Sun May 26 18:34 - crash (08:17)
    root pts/0 117.136.63.183 Sun May 26 18:10 - crash (08:42)
  2. Check what you use Shell - ps.

    Shell Also known as “ shell ” or “ Shell program ”, It's the interpreter that users communicate with the operating system kernel , In short, it is the interface and interface between human and computer . At present a lot of Linux By default Shell All are bash(Bourne Again SHell), Because it can be used tab Key for command and path completion 、 You can save history orders 、 You can easily configure environment variables and perform batch operations .

    [root ~]# ps
    PID TTY TIME CMD
    3531 pts/0 00:00:00 bash
    3553 pts/0 00:00:00 ps
  3. Check the description and location of the command - whatis / which / whereis.

    [root ~]# whatis ps
    ps (1) - report a snapshot of the current processes.
    [root ~]# whatis python
    python (1) - an interpreted, interactive, object-oriented programming language
    [root ~]# whereis ps
    ps: /usr/bin/ps /usr/share/man/man1/ps.1.gz
    [root ~]# whereis python
    python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /usr/share/man/man1/python.1.gz
    [root ~]# which ps
    /usr/bin/ps
    [root ~]# which python
    /usr/bin/python
  4. Clear what's on the screen - clear.

  5. View help documents - man / info / –help / apropos.

    [root@izwz97tbgo9lkabnat2lo8z ~]# ps --help
    Usage:
    ps [options]
    Try 'ps --help <simple|list|output|threads|misc|all>'
    or 'ps --help <s|l|o|t|m|a>'
    for additional help text.
    For more details see ps(1).
    [root@izwz97tbgo9lkabnat2lo8z ~]# man ps
    PS(1) User Commands PS(1)
    NAME
    ps - report a snapshot of the current processes.
    SYNOPSIS
    ps [options]
    DESCRIPTION
    ...
  6. Look at the system and hostname - uname / hostname.

    [root@izwz97tbgo9lkabnat2lo8z ~]# uname
    Linux
    [root@izwz97tbgo9lkabnat2lo8z ~]# hostname
    izwz97tbgo9lkabnat2lo8z
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# cat /etc/centos-release
    CentOS Linux release 7.6.1810 (Core)

    explain :cat Is a command to connect the contents of a file and print it to standard output , I'll talk about the order later ;/etc yes Linux A very important directory on the system , It saves a lot of configuration files ;centos-release It's a file in the directory , Because I used Linux The distribution is CentOS 7.6, So here's a file like this .

  7. Time and date - date / cal.

    [root@iZwz97tbgo9lkabnat2lo8Z ~]# date
    Wed Jun 20 12:53:19 CST 2018
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# cal
    June 2018
    Su Mo Tu We Th Fr Sa
    1 2
    3 4 5 6 7 8 9
    10 11 12 13 14 15 16
    17 18 19 20 21 22 23
    24 25 26 27 28 29 30
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# cal 5 2017
    May 2017
    Su Mo Tu We Th Fr Sa
    1 2 3 4 5 6
    7 8 9 10 11 12 13
    14 15 16 17 18 19 20
    21 22 23 24 25 26 27
    28 29 30 31
  8. Restart and shut down - reboot / shutdown.

    [root ~]# shutdown -h +5
    Shutdown scheduled for Sun 2019-05-26 19:34:27 CST, use 'shutdown -c' to cancel.
    [root ~]#
    Broadcast message from root (Sun 2019-05-26 19:29:27 CST): The system is going down for power-off at Sun 2019-05-26 19:34:27 CST!
    [root ~]# shutdown -c Broadcast message from root (Sun 2019-05-26 19:30:22 CST): The system shutdown has been cancelled at Sun 2019-05-26 19:31:22 CST!
    [root ~]# shutdown -r 23:58
    Shutdown scheduled for Sun 2019-05-26 23:58:00 CST, use 'shutdown -c' to cancel.
    [root ~]# shutdown -c Broadcast message from root (Sun 2019-05-26 19:31:06 CST): The system shutdown has been cancelled at Sun 2019-05-26 19:32:06 CST!

    explain : In execution shutdown When the command is given, a warning will be given to the user logging in to the system , You can replace the default warning message by following the command with a warning message , It can also be in -h Parameters passed after now To indicate immediate shutdown .

  9. Log out - exit / logout.

  10. View history command - history.

[root@iZwz97tbgo9lkabnat2lo8Z ~]# history
...
452 ls
453 cd Python-3.6.5/
454 clear
455 history
[root@iZwz97tbgo9lkabnat2lo8Z ~]# !454

explain : After looking at the historical command , It can be used ! Historical order number To re execute the order ; adopt history -c Can clear history command .

Utilities

File and folder operations

  1. establish / Delete empty directory - mkdir / rmdir.

    [root ~]# mkdir abc
    [root ~]# mkdir -p xyz/abc
    [root ~]# rmdir abc
  2. establish / Delete file - touch / rm.

    [root ~]# touch readme.txt
    [root ~]# touch error.txt
    [root ~]# rm error.txt
    rm: remove regular empty file ‘error.txt’? y
    [root ~]# rm -rf xyz
    • touch Command to create a blank file or modify the file time . stay Linux There are three times for a file in the system :

      • When to change the content - mtime.
      • Time to change permissions - ctime.
      • Last access time - atime.
    • rm Several important parameters of :
      • -i: Interactive delete , Every deleted item is asked .
      • -r: Delete directory and recursively delete files and directories in the directory .
      • -f: Mandatory deletion , Ignore nonexistent files , There's no hint .
  3. Switch and view the current working directory - cd / pwd.

    explain :cd The command can be followed by a relative path ( Take the current path as a reference ) Or absolute path ( With / start ) To switch to the specified directory , It can also be used. cd .. To return to the previous Directory . Please think about , If you want to return to the previous directory, you should give cd What parameters are added to the command ?

  4. View directory contents - ls.

    • -l: View files and directories in long format .
    • -a: Show files and directories starting with a dot ( Hidden files ).
    • -R: Recursively expand the directory ( Continue listing the files and directories under the directory ).
    • -d: List only directories , Don't list anything else .
    • -S/-t: By size / Time sequence .
  5. View file contents - cat / tac / head / tail / more / less / rev / od.

    [root ~]# wget http://www.sohu.com/ -O sohu.html
    --2018-06-20 18:42:34-- http://www.sohu.com/
    Resolving www.sohu.com (www.sohu.com)... 14.18.240.6
    Connecting to www.sohu.com (www.sohu.com)|14.18.240.6|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 212527 (208K) [text/html]
    Saving to: ‘sohu.html’
    100%[==================================================>] 212,527 --.-K/s in 0.03s
    2018-06-20 18:42:34 (7.48 MB/s) - ‘sohu.html’ saved [212527/212527]
    [root ~]# cat sohu.html
    ...
    [root ~]# head -10 sohu.html
    <!DOCTYPE html>
    <html>
    <head>
    <title> sohu </title>
    <meta name="Keywords" content=" sohu , Portal site , The new media , Network media , Journalism , Finance and economics, , sports , entertainment , fashion , automobile , Real estate , Technology , picture , Forum , Microblogging , Blog , video , The movie , TV play "/>
    <meta name="Description" content=" Sohu provides 24 Keep up to date with the latest information , And search 、 E-mail and other network services . It includes global hot events 、 Breaking news 、 Comment on current affairs 、 Popular TV series 、 Sports events 、 Industry trends 、 Life service information , And the forum 、 Blog 、 Microblogging 、 My Sohu and other interactive spaces ." />
    <meta name="shenma-site-verification" content="1237e4d02a3d8d73e96cbd97b699e9c3_1504254750">
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
    [root ~]# tail -2 sohu.html
    </body>
    </html>
    [root ~]# less sohu.html
    ...
    [root ~]# cat -n sohu.html | more
    ...

    explain : It uses a name called wget The order of , It's a network downloader program , Can be from the designated URL Download resources .

  6. Copy / Moving files - cp / mv.

    [root ~]# mkdir backup
    [root ~]# cp sohu.html backup/
    [root ~]# cd backup
    [root backup]# ls
    sohu.html
    [root backup]# mv sohu.html sohu_index.html
    [root backup]# ls
    sohu_index.html
  7. File rename - rename.

[root@iZwz97tbgo9lkabnat2lo8Z ~]# rename .htm .html *.htm
  1. Find files and find content - find / grep.

    [root@iZwz97tbgo9lkabnat2lo8Z ~]# find / -name "*.html"
    /root/sohu.html
    /root/backup/sohu_index.html
    [root@izwz97tbgo9lkabnat2lo8z ~]# find . -atime 7 -type f -print
    [root@izwz97tbgo9lkabnat2lo8z ~]# find . -type f -size +2k
    [root@izwz97tbgo9lkabnat2lo8z ~]# find . -type f -name "*.swp" -delete
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# grep "<script>" sohu.html -n
    20:<script>
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# grep -E \<\/?script.*\> sohu.html -n
    20:<script>
    22:</script>
    24:<script src="//statics.itc.cn/web/v3/static/js/es5-shim-08e41cfc3e.min.js"></script>
    25:<script src="//statics.itc.cn/web/v3/static/js/es5-sham-1d5fa1124b.min.js"></script>
    26:<script src="//statics.itc.cn/web/v3/static/js/html5shiv-21fc8c2ba6.js"></script>
    29:<script type="text/javascript">
    52:</script>
    ...

    explain :grep Regular expressions can be used when searching strings , If you need to use regular expressions, you can use grep -E Or use it directly egrep.

  2. Create links and view links - ln / readlink.

    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ls -l sohu.html
    -rw-r--r-- 1 root root 212131 Jun 20 19:15 sohu.html
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ln /root/sohu.html /root/backup/sohu_backup
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ls -l sohu.html
    -rw-r--r-- 2 root root 212131 Jun 20 19:15 sohu.html
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ln /root/sohu.html /root/backup/sohu_backup2
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ls -l sohu.html
    -rw-r--r-- 3 root root 212131 Jun 20 19:15 sohu.html
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ln -s /etc/centos-release sysinfo
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ls -l sysinfo
    lrwxrwxrwx 1 root root 19 Jun 20 19:21 sysinfo -> /etc/centos-release
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# cat sysinfo
    CentOS Linux release 7.4.1708 (Core)
    [root@iZwz97tbgo9lkabnat2lo8Z ~]# cat /etc/centos-release
    CentOS Linux release 7.4.1708 (Core)

    explain : Links can be divided into hard links and soft links ( A symbolic link ). A hard link can be thought of as a pointer to file data , It's like Python Reference count of objects in , Every time you add a hard link , The number of links corresponding to the file increases 1, Only if the number of links to a file is 0 when , The storage space corresponding to the file can be overwritten by other files . We usually delete files without deleting the data on the hard disk , What we delete is just a pointer , Or a usage record of data , So it's like “ File shredder ” Software like this is “ smash ” In addition to deleting the file pointer , Data will also be filled in the storage area corresponding to the file to ensure that the file can no longer be recovered . Soft links are similar to Windows Shortcuts under the system , When files linked by soft links are deleted , The soft link also failed .

  3. Compress / Decompress and archive / De archiving - gzip / gunzip / xz.

[root@iZwz97tbgo9lkabnat2lo8Z ~]# wget http://download.redis.io/releases/redis-4.0.10.tar.gz
--2018-06-20 19:29:59-- http://download.redis.io/releases/redis-4.0.10.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1738465 (1.7M) [application/x-gzip]
Saving to: ‘redis-4.0.10.tar.gz’
100%[==================================================>] 1,738,465 70.1KB/s in 74s
2018-06-20 19:31:14 (22.9 KB/s) - ‘redis-4.0.10.tar.gz’ saved [1738465/1738465]
[root@iZwz97tbgo9lkabnat2lo8Z ~]# ls redis*
redis-4.0.10.tar.gz
[root@iZwz97tbgo9lkabnat2lo8Z ~]# gunzip redis-4.0.10.tar.gz
[root@iZwz97tbgo9lkabnat2lo8Z ~]# ls redis*
redis-4.0.10.tar
  1. Filing, reconciliation and filing - tar.
[root@iZwz97tbgo9lkabnat2lo8Z ~]# tar -xvf redis-4.0.10.tar
redis-4.0.10/
redis-4.0.10/.gitignore
redis-4.0.10/00-RELEASENOTES
redis-4.0.10/BUGS
redis-4.0.10/CONTRIBUTING
redis-4.0.10/COPYING
redis-4.0.10/INSTALL
redis-4.0.10/MANIFESTO
redis-4.0.10/Makefile
redis-4.0.10/README.md
redis-4.0.10/deps/
redis-4.0.10/deps/Makefile
redis-4.0.10/deps/README.md
...

explain : file ( Also known as creating an archive ) Reconciliation archives all use tar command , Usually creating an archive requires -cvf Three parameters , among c Representation creation (create),v Show create archive details (verbose),f Represents a file for a specified Archive (file); To unpack an archive, you need to add -xvf Parameters , among x To draw (extract), The other two parameters are the same as creating an archive .

  1. Convert standard input to command line parameters - xargs.

The following command will find... In the current path html file , And then through xargs Pass these files as parameters to rm command , To find and delete files .

[root@iZwz97tbgo9lkabnat2lo8Z ~]# find . -type f -name "*.html" | xargs rm -f

The following order will a.txt Multiple lines of content in the file become one line output to b.txt In file , among < From a.txt Read input in ,> Indicates that the execution result of the command is output to b.txt in .

[root@iZwz97tbgo9lkabnat2lo8Z ~]# xargs < a.txt > b.txt

explain : This command is often in the pipeline as shown above ( A way to realize interprocess communication ) Redirection ( Reassign the position of input and output ) Used in operation , Later, we will talk about pipeline operation and input / output redirection operation .

  1. Show files or directories - basename / dirname.

  2. Other related tools .

  • sort - Sort the content
  • uniq - Remove adjacent duplicates
  • tr - Replace specified content with new content
  • cut / paste - shear / Paste content
  • split - Split files
  • file - Determine file type
  • wc - Count file lines 、 Number of words 、 Number of bytes
  • iconv - Encoding conversion
[root ~]# cat foo.txt
grape
apple
pitaya
[root ~]# cat bar.txt
100
200
300
400
[root ~]# paste foo.txt bar.txt
grape 100
apple 200
pitaya 300
400
[root ~]# paste foo.txt bar.txt > hello.txt
[root ~]# cut -b 4-8 hello.txt
pe 10
le 20
aya 3
0
[root ~]# cat hello.txt | tr '\t' ','
grape,100
apple,200
pitaya,300
,400
[root ~]# split -l 100 sohu.html hello
[root ~]# wget https://www.baidu.com/img/bd_logo1.png
[root ~]# file bd_logo1.png
bd_logo1.png: PNG image data, 540 x 258, 8-bit colormap, non-interlaced
[root ~]# wc sohu.html
2979 6355 212527 sohu.html
[root ~]# wc -l sohu.html
2979 sohu.html
[root ~]# wget http://www.qq.com -O qq.html
[root ~]# iconv -f gb2312 -t utf-8 qq.html

Pipes and Redirection

  1. Use of pipes - |.

    Example : Find the number of files in the current directory .

    [root ~]# find ./ | wc -l
    6152

    Example : List files and folders in the current path , Add a number to each item .

    [root ~]# ls | cat -n
    1 dump.rdb
    2 mongodb-3.6.5
    3 Python-3.6.5
    4 redis-3.2.11
    5 redis.conf

    Example : lookup record.log Contained in the AAA, But does not contain BBB The total number of records

    [root ~]# cat record.log | grep AAA | grep -v BBB | wc -l
  2. Output redirection and error redirection - > / >> / 2>.

    [root ~]# cat readme.txt
    banana
    apple
    grape
    apple
    grape
    watermelon
    pear
    pitaya
    [root ~]# cat readme.txt | sort | uniq > result.txt
    [root ~]# cat result.txt
    apple
    banana
    grape
    pear
    pitaya
    watermelon
  3. Input redirection - <.

    [root ~]# echo 'hello, world!' > hello.txt
    [root ~]# wall < hello.txt
    [root ~]#
    Broadcast message from root (Wed Jun 20 19:43:05 2018):
    hello, world!
    [root ~]# echo 'I will show you some code.' >> hello.txt
    [root ~]# wall < hello.txt
    [root ~]#
    Broadcast message from root (Wed Jun 20 19:43:55 2018):
    hello, world!
    I will show you some code.
  4. Multiple orientation - tee.

    The following commands are in addition to displaying commands on the terminal ls In addition to the result of , Also add output to ls.txt In file .

    [root ~]# ls | tee -a ls.txt

Alias

  1. alias

    [root ~]# alias ll='ls -l'
    [root ~]# alias frm='rm -rf'
    [root ~]# ll
    ...
    drwxr-xr-x 2 root root 4096 Jun 20 12:52 abc
    ...
    [root ~]# frm abc
  2. unalias

    [root ~]# unalias frm
    [root ~]# frm sohu.html
    -bash: frm: command not found

Text processing

  1. Character stream editor - sed.

    sed Is the operation 、 Tools for filtering and converting text content . Let's say I have a name fruit.txt The file of , The contents are shown below .

    [root ~]# cat -n fruit.txt
    1 banana
    2 grape
    3 apple
    4 watermelon
    5 orange

    Next , We are the first 2 Add a... After the line pitaya.

    [root ~]# sed '2a pitaya' fruit.txt
    banana
    grape
    pitaya
    apple
    watermelon
    orange

    Be careful : The order just now is the same as many of the orders we mentioned before fruit.txt file , Instead, output the content of the new line to the terminal , If you want to save it to fruit.txt in , You can use the output redirection operation .

    In the 2 Insert a... In front of the line waxberry.

    [root ~]# sed '2i waxberry' fruit.txt
    banana
    waxberry
    grape
    apple
    watermelon
    orange

    Delete the first 3 That's ok .

    [root ~]# sed '3d' fruit.txt
    banana
    grape
    watermelon
    orange

    Delete the first 2 Go to the first place 4 That's ok .

    [root ~]# sed '2,4d' fruit.txt
    banana
    orange

    Put the characters in the text a Replace with @.

    [root ~]# sed 's#a#@#' fruit.txt
    b@nana
    gr@pe
    @pple
    w@termelon
    or@nge

    Put the characters in the text a Replace with @, Use global mode .

    [root ~]# sed 's#a#@#g' fruit.txt
    b@n@n@
    gr@pe
    @pple
    w@termelon
    or@nge
  2. Pattern matching and processing language - awk.

    awk Is a programming language , It's also Linux The most powerful tool for text processing in the system , One of its authors and current maintainers is the one mentioned before Brian Kernighan(ken and dmr The closest partner ). With this command, you can extract the specified column from the text 、 Use regular expressions to extract what we want from the text 、 Display the specified rows and perform statistics and operations , All in all, it's very powerful .

    Let's say I have a name fruit2.txt The file of , The contents are shown below .

    [root ~]# cat fruit2.txt
    1 banana 120
    2 grape 500
    3 apple 1230
    4 watermelon 80
    5 orange 400

    Show the number of files 3 That's ok .

    [root ~]# awk 'NR==3' fruit2.txt
    3 apple 1230

    Show the number of files 2 Column .

    [root ~]# awk '{print $2}' fruit2.txt
    banana
    grape
    apple
    watermelon
    orange

    Show the last column of the file .

    [root ~]# awk '{print $NF}' fruit2.txt
    120
    500
    1230
    80
    400

    The number at the end of the output is greater than or equal to 300 The line of .

    [root ~]# awk '{if($3 >= 300) {print $0}}' fruit2.txt
    2 grape 500
    3 apple 1230
    5 orange 400

    It's just awk The tip of the iceberg of command , More content is left for readers to explore in practice .

User management

  1. Create and delete users - useradd / userdel.

    [root home]# useradd hellokitty
    [root home]# userdel hellokitty
    • -d- When creating a user, specify the user's home directory
    • -g- When creating a user, specify the user group to which the user belongs
  2. Create and delete user groups - groupadd / groupdel.

    explain : User groups are mainly used to facilitate the management of all users in a group .

  3. Change Password - passwd.

    [root ~]# passwd hellokitty
    New password:
    Retype new password:
    passwd: all authentication tokens updated successfully.

    explain : Input password and confirm password are not echoed and must be input in one go ( You can't use backspace ), The password and the confirmation password need to be the same . If you use passwd There is no object specified for the command , To change the password of the current user . If you want to batch modify user passwords , have access to chpasswd command .

    • -l/-u- lock / Unlocking users .
    • -d- Clear user password .
    • -e- Set password to expire immediately , Users will be forced to change their password when they log in .
    • -i- Set how many days after the password expires to disable the user .
  4. View and change password expiration date - chage.

    Set up hellokitty user 100 You have to change your password in days , Before expiration 15 Days to notify the user , After expired 15 Days to disable this user .

    chage -M 100 -W 15 -I 15 hellokitty
  5. Switching users - su.

    [root ~]# su hellokitty
    [hellokitty root]$
  6. Execute commands as Administrator - sudo.

    [hellokitty ~]$ ls /root
    ls: cannot open directory /root: Permission denied
    [hellokitty ~]$ sudo ls /root
    [sudo] password for hellokitty:

    explain : If you want users to be able to execute commands as administrators , The user must appear in sudoers List ,sudoers The file in /etc Under the table of contents , If you want to edit the file directly, you can also use the following command .

  7. edit sudoers file - visudo.

    The editor used here is vi, About vi Our knowledge will be explained later . Part of the document is as follows :

    ## Allow root to run any commands anywhere
    root ALL=(ALL) ALL ## Allows members of the 'sys' group to run networking, software,
    ## service management apps and more.
    # %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
    ## Allows people in group wheel to run all commands
    %wheel ALL=(ALL) ALL ## Same thing without a password
    # %wheel ALL=(ALL) NOPASSWD: ALL ## Allows members of the users group to mount and unmount the
    ## cdrom as root
    # %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom ## Allows members of the users group to shutdown this system
    # %users localhost=/sbin/shutdown -h now
  8. Display information about users and user groups - id.

  9. Send messages to other users -write / wall.

    The sender :

    [root ~]# write hellokitty
    Dinner is on me.
    Call me at 6pm.

    The receiving party :

    [hellokitty ~]$
    Message from root on pts/0 at 17:41 ...
    Dinner is on me.
    Call me at 6pm.
    EOF
  10. see / Set whether to receive messages sent by other users - mesg.

[hellokitty ~]$ mesg
is y
[hellokitty ~]$ mesg n
[hellokitty ~]$ mesg
is n

file system

Files and paths

  1. Naming rules : The maximum length of a filename depends on the file system type , In general , The file name should not exceed 255 Characters , Although most characters can be used for filenames , But it's better to use English capital letters 、 Numbers 、 Underline 、 Point at this sign . Although you can use spaces in file names , But you should try to avoid using spaces , Otherwise, you need to put the filename in double quotation marks or through \ Escape spaces .
  2. Extension : stay Linux The extension of the file under the system is optional , But using an extension helps to understand the contents of the file . Some applications want to recognize files by extension , But more applications don't rely on file extensions , It's like file The command does not recognize a file by its extension .
  3. Hidden files : The document starting with a dot is in Linux Hidden files in the system ( Invisible files ).

Directory structure

  1. /bin - Binary file of basic command .
  2. /boot - Boot loader static file .
  3. /dev - Device file .
  4. /etc - The configuration file .
  5. /home - The parent directory of the normal user's home directory .
  6. /lib - Shared library file .
  7. /lib64 - share 64 Location files .
  8. /lost+found - Store unlinked files .
  9. /media - Automatically identify the device's Mount Directory .
  10. /mnt - Mount the mount point of the file system temporarily .
  11. /opt - Optional plug-in package installation location .
  12. /proc - Kernel and process information .
  13. /root - Super administrator user home directory .
  14. /run - Store what the system needs to run .
  15. /sbin - Super user binaries .
  16. /sys - Pseudo file system of device .
  17. /tmp - Temporary folder .
  18. /usr - User application directory .
  19. /var - Variable data directory .

Access right

  1. chmod - Change file mode bit .

    [root ~]# ls -l
    ...
    -rw-r--r-- 1 root root 211878 Jun 19 16:06 sohu.html
    ...
    [root ~]# chmod g+w,o+w sohu.html
    [root ~]# ls -l
    ...
    -rw-rw-rw- 1 root root 211878 Jun 19 16:06 sohu.html
    ...
    [root ~]# chmod 644 sohu.html
    [root ~]# ls -l
    ...
    -rw-r--r-- 1 root root 211878 Jun 19 16:06 sohu.html
    ...

    explain : As can be seen from the above example , use chmod There are two ways to change file mode bits : One is character setting , The other is number setting . except chmod outside , Can pass umask To set which permissions will be deleted in the default permissions of new files .

    When viewing a directory or file in a long format, the results and their corresponding permissions are shown in the following table .

    [ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-Rc0ma4yM-1611237558252)(./res/file-mode.png)]

  2. chown - Change file owner .

    [root ~]# ls -l
    ...
    -rw-r--r-- 1 root root 54 Jun 20 10:06 readme.txt
    ...
    [root ~]# chown hellokitty readme.txt
    [root ~]# ls -l
    ...
    -rw-r--r-- 1 hellokitty root 54 Jun 20 10:06 readme.txt
    ...
  3. chgrp - Change user groups .

Disk management

  1. List disk usage for the file system - df.

    [root ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/vda1 40G 5.0G 33G 14% /
    devtmpfs 486M 0 486M 0% /dev
    tmpfs 497M 0 497M 0% /dev/shm
    tmpfs 497M 356K 496M 1% /run
    tmpfs 497M 0 497M 0% /sys/fs/cgroup
    tmpfs 100M 0 100M 0% /run/user/0
  2. Partition table operation - fdisk.

    [root ~]# fdisk -l
    Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x000a42f4
    Device Boot Start End Blocks Id System
    /dev/vda1 * 2048 83884031 41940992 83 Linux
    Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
  3. Partition tool - parted.

  4. Format file system - mkfs.

    [root ~]# mkfs -t ext4 -v /dev/sdb
    • -t- Specify the type of file system .
    • -c- Check for disk corruption when creating a file system .
    • -v- Show details .
  5. File system check - fsck.

  6. Convert or copy files - dd.

  7. mount / uninstall - mount / umount.

  8. establish / Activate / Turn off swap partition - mkswap / swapon / swapoff.

explain : There is a risk in executing these commands , If you don't know how to use these commands , It's better not to use it at will , In use , It's best to operate with reference , And confirm whether to do so before operation .

Editor - vim

  1. start-up vim. Can pass vi or vim Command to start vim, You can specify a filename to open a file at startup , If no filename is specified , You can also specify a filename when saving .

    [root ~]# vim guess.py
  2. Command mode 、 Edit mode and last line mode : start-up vim Enter command mode ( Also known as Normal Pattern ), Enter English letters in command mode i Will enter edit mode (Insert Pattern ), At the bottom of the screen -- INSERT -- Tips ; Press... In edit mode Esc Will return to command mode , At this time, if you input English : Will enter the last line mode , Enter... In last line mode q! You can exit without saving your current work vim; Enter... In command mode v Will go into visual mode (Visual Pattern ), You can use the cursor to select an area and complete the corresponding operation .

  3. Save and exit vim: Enter... In command mode : Enter last line mode , Input wq Save exit can be realized ; If you want to give up editing content input q! To force out of , This point has just been mentioned ; In command mode, you can also directly input ZZ Implement save exit . If you just want to save the file without exiting , Then you can enter... In the last line mode w; Can be in w After that, enter a space to specify the file name to save .

  4. Cursor operation .

    • In command mode, you can use hjkl To control the cursor to the left 、 Next 、 On 、 Move in the right direction , You can enter numbers in front of letters to indicate the distance of movement , for example :10h Move left 10 Characters .
    • In command mode, you can use Ctrl+y and Ctrl+e To achieve upward 、 Scroll down one line of text , Can pass Ctrl+f and Ctrl+b To achieve forward and backward page operations .
    • In command mode, you can input English letters G Move the cursor to the end of the file , Can pass gg Move the cursor to the beginning of the file , It can also be done through G Enter a number to move the cursor to the specified line .
  5. Text operation .

    • Delete : You can use... In command mode dd To delete the entire line ; Can be in dd Add a number before it to specify the number of lines to delete ; It can be used d$ To delete from the cursor to the end of the line , It can also be done through d0 To delete from the cursor to the beginning of the line ; If you want to delete a word , have access to dw; If you want to delete the full text , You can type :%d( among : Used to enter the last line mode from the command mode ).
    • Copy and paste : You can use... In command mode yy To copy the whole line ; Can be in yy Add a number before it to specify the number of copied lines ; Can pass p Paste the copied content where the cursor is .
    • Revocation and reinstatement : Enter... In command mode u You can undo the previous operation ; adopt Ctrl+r Can resume the revoked operation .
    • Sort content : Enter... In command mode %!sort.
  6. Find and replace .

    • Input required for find operation / Enter the last line pattern and provide a regular expression to match the corresponding content , for example :/doc.*\., Input n To search forward , You can also type N To search backward .
    • The replacement operation requires input : Enter the last line mode and specify the scope of the search 、 Regular expressions and their replacement and matching options , for example ::1,$s/doc.*/hello/gice, among :
      • g- global: The global matching .
      • i- ignore case: Ignore case matching .
      • c- confirm: Replacement needs to be confirmed .
      • e- error: Ignore mistakes .
  7. Parameter setting : In the input : After entering the last line mode, you can set vim To set .

    • Set up Tab The number of spaces in the key :set ts=4

    • Set display / Don't show line numbers :set nu/set nonu

    • Set enable / Turn off highlighting Syntax :syntax on/syntax off

    • Set the display scale ( The row and column where the cursor is located ):set ruler

    • Set enable / Turn off search results highlighting :set hls/set nohls

      explain : If you want the above settings to be on every boot vim It works automatically when , You need to write these settings to the .vimrc In file .

  8. Advanced skills

    • Compare multiple files .

      [root ~]# vim -d foo.txt bar.txt

      [ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-gSQ8zSxR-1611237558253)(./res/vim-diff.png)]

    • Open multiple files .

      [root ~]# vim foo.txt bar.txt hello.txt

      start-up vim There is only one window that shows foo.txt, You can enter... In the last line mode ls See the three open files , You can also type b <num> To display another file , For example, you can use :b 2 take bar.txt Show it , It can be used :b 3 take hello.txt Show it .

    • Split and switch windows .

      You can enter... In the last line mode sp or vs To split the window horizontally or vertically , So we can open multiple editing windows at the same time , By pressing twice Ctrl+w You can switch the editing window , Performing an exit operation in a window will only close the corresponding window , Other windows remain .

      [ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-zrjOYT8V-1611237558253)(./res/vim-multi-window.png)]

    • Map shortcuts : stay vim You can map some common operations to shortcut keys to improve work efficiency .

      • Example 1: Enter... In command mode F4 Execute delete from first line 10000 Line code operation .

        :map <F4> gg10000dd.

        Example 2: Enter... In edit mode __main The direct complement is if __name__ == '__main__':.

        :inoremap __main if __name__ == '__main__':

      explain : The above example 2 Of inoremap Medium i The key representing the mapping is used in edit mode ,nore Don't recurse , This is very important , Otherwise, the key itself will appear in the content corresponding to the key , It causes recursion ( It's like entering a dead cycle ). If you want the mapped shortcut to start every time vim It will take effect at all times , You need to write the map to the .vimrc In file .

    • Record macro .

      • Enter... In command mode qa Start recording macros ( among a It's the name of the register , It can also be other English letters or 0-9 The number of ).

      • Do what you do ( Cursor operation 、 Editing operations, etc ), These operations will be recorded .

      • If the recording is done , Press q The end of the recording .

      • adopt @aa Is the name of the register just used ) Play macro , If you want to run a macro more than once, you can prefix it with numbers , for example 100@a Show macro play 100 Time .

      • Try the following example to experience the operation of recording macro , The example comes from Harttle Land Website , There are a lot of information about vim Use skills , Those who are interested can learn about it .

        [ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-Mjtvd84m-1611237558254)(./res/vim-macro.png)]

Software installation and configuration

Use package management tools

  1. yum - Yellowdog Updater Modified.

    • yum search: Search package , for example yum search nginx.
    • yum list installed: List installed packages , for example yum list installed | grep zlib.
    • yum install: Install package , for example yum install nginx.
    • yum remove: Remove package , for example yum remove nginx.
    • yum update: Update package , for example yum update All packages can be updated , and yum update tar Only updated tar.
    • yum check-update: Check for any packages that can be updated .
    • yum info: Display information about the package , for example yum info nginx.
  2. rpm - Redhat Package Manager.
    • Install package :rpm -ivh <packagename>.rpm.
    • Remove package :rpm -e <packagename>.
    • Query package :rpm -qa, For example, you can use rpm -qa | grep mysql To check if you have installed MySQL Related packages .

Let's say Nginx For example , Show me how to use yum Install the software .

[root ~]# yum -y install nginx
...
Installed:
nginx.x86_64 1:1.12.2-2.el7
Dependency Installed:
nginx-all-modules.noarch 1:1.12.2-2.el7
nginx-mod-http-geoip.x86_64 1:1.12.2-2.el7
nginx-mod-http-image-filter.x86_64 1:1.12.2-2.el7
nginx-mod-http-perl.x86_64 1:1.12.2-2.el7
nginx-mod-http-xslt-filter.x86_64 1:1.12.2-2.el7
nginx-mod-mail.x86_64 1:1.12.2-2.el7
nginx-mod-stream.x86_64 1:1.12.2-2.el7
Complete!
[root ~]# yum info nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
Name : nginx
Arch : x86_64
Epoch : 1
Version : 1.12.2
Release : 2.el7
Size : 1.5 M
Repo : installed
From repo : epel
Summary : A high performance web server and reverse proxy server
URL : http://nginx.org/
License : BSD
Description : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and
: IMAP protocols, with a strong focus on high concurrency, performance and low
: memory usage.
[root ~]# nginx -v
nginx version: nginx/1.12.2

remove Nginx.

[root ~]# yum -y remove nginx

Let's say MySQL For example , Show me how to use rpm Install the software . To install MySQL We need to arrive first. MySQL Download the corresponding RPM file , Of course, choose what you use Linux The corresponding version of the system .MySQL Now it is Oracle Products of the company , stay MySQL After being acquired ,MySQL The author of remake a MySQL The branch of MariaDB, Can pass yum Installation .

[root mysql]# ls
mysql-community-client-5.7.22-1.el7.x86_64.rpm
mysql-community-common-5.7.22-1.el7.x86_64.rpm
mysql-community-libs-5.7.22-1.el7.x86_64.rpm
mysql-community-server-5.7.22-1.el7.x86_64.rpm
[root mysql]# yum -y remove mariadb-libs
[root mysql]# yum -y install libaio
[root mysql]#rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
...
[root mysql]#rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
...
[root mysql]#rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
...
[root mysql]#rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
...

explain : because MySQL and MariaDB The underlying dependency Library of is in conflict , So first we use yum Removed the name mariadb-libs And installed a dependency library called libaio Asynchronous Support I/O Operational dependency Library . About MySQL and MariaDB The relationship between , You can read Wikipedia about MariaDB Introduction to .

Remove the installed MySQL.

[root ~]# rpm -qa | grep mysql | xargs rpm -e

Download and decompress the configuration environment variables

Below to install MongoDB For example , Demonstrate how this type of software should be installed .

[root ~]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.5.tgz
--2018-06-21 18:32:53-- https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.5.tgz
Resolving fastdl.mongodb.org (fastdl.mongodb.org)... 52.85.83.16, 52.85.83.228, 52.85.83.186, ...
Connecting to fastdl.mongodb.org (fastdl.mongodb.org)|52.85.83.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 100564462 (96M) [application/x-gzip]
Saving to: ‘mongodb-linux-x86_64-rhel70-3.6.5.tgz’
100%[==================================================>] 100,564,462 630KB/s in 2m 9s
2018-06-21 18:35:04 (760 KB/s) - ‘mongodb-linux-x86_64-rhel70-3.6.5.tgz’ saved [100564462/100564462]
[root ~]# gunzip mongodb-linux-x86_64-rhel70-3.6.5.tgz
[root ~]# tar -xvf mongodb-linux-x86_64-rhel70-3.6.5.tar
mongodb-linux-x86_64-rhel70-3.6.5/README
mongodb-linux-x86_64-rhel70-3.6.5/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-rhel70-3.6.5/MPL-2
mongodb-linux-x86_64-rhel70-3.6.5/GNU-AGPL-3.0
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongodump
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongorestore
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoexport
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoimport
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongostat
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongotop
mongodb-linux-x86_64-rhel70-3.6.5/bin/bsondump
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongofiles
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoreplay
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoperf
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongod
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongos
mongodb-linux-x86_64-rhel70-3.6.5/bin/mongo
mongodb-linux-x86_64-rhel70-3.6.5/bin/install_compass
[root ~]# vim .bash_profile
...
PATH=$PATH:$HOME/bin:$HOME/mongodb-linux-x86_64-rhel70-3.6.5/bin
export PATH
...
[root ~]# source .bash_profile
[root ~]# mongod --version
db version v3.6.5
git version: a20ecd3e3a174162052ff99913bc2ca9a839d618
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
distmod: rhel70
distarch: x86_64
target_arch: x86_64
[root ~]# mongo --version
MongoDB shell version v3.6.5
git version: a20ecd3e3a174162052ff99913bc2ca9a839d618
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
distmod: rhel70
distarch: x86_64
target_arch: x86_64

explain : Of course, it can also be yum To install MongoDB, For details, please refer to the instructions given on the official website .

Source code build installation

  1. install Python 3.6.

    [root ~]# yum install gcc
    [root ~]# wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
    [root ~]# gunzip Python-3.6.5.tgz
    [root ~]# tar -xvf Python-3.6.5.tar
    [root ~]# cd Python-3.6.5
    [root ~]# ./configure --prefix=/usr/local/python36 --enable-optimizations
    [root ~]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
    [root ~]# make && make install
    ...
    [root ~]# ln -s /usr/local/python36/bin/python3.6 /usr/bin/python3
    [root ~]# python3 --version
    Python 3.6.5
    [root ~]# python3 -m pip install -U pip
    [root ~]# pip3 --version

    explain : It's being installed Python Then you need to register PATH environment variable , take Python Under installation path bin The absolute path of the folder is registered to PATH In the environment variables . The registration environment variable can modify the .bash_profile perhaps /etc In the catalog profile file , The difference between the two is that the former is equivalent to the user environment variable , The latter is equivalent to the system environment variable .

  2. install Redis-3.2.12.

    [root ~]# wget http://download.redis.io/releases/redis-3.2.12.tar.gz
    [root ~]# gunzip redis-3.2.12.tar.gz
    [root ~]# tar -xvf redis-3.2.12.tar
    [root ~]# cd redis-3.2.12
    [root ~]# make && make install
    [root ~]# redis-server --version
    Redis server v=3.2.12 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=5bc5cd3c03d6ceb6
    [root ~]# redis-cli --version
    redis-cli 3.2.12

Configure the service

We can Linux Install and configure various services under the system , That is to say, we can put Linux The system is built into a database server 、Web The server 、 Cache server 、 File server 、 Message queue servers and so on .Linux Most of the services under are set as daemons ( Resides in the background of the system , But not because the service is still running Linux Can't stop running ), So the service we install usually has a letter after the name d, It's an English word daemon Abbreviation , for example : The firewall service is firewalld, We installed before MySQL The service is mysqld,Apache The server name httpd etc. . After the service is installed , have access to systemctl Order or service Command to complete the start of the service 、 Stop and wait operation , The specific operation is shown below .

  1. Start firewall service .

    [root ~]# systemctl start firewalld
  2. Stop firewall service .

    [root ~]# systemctl stop firewalld
  3. Restart firewall service .

    [root ~]# systemctl restart firewalld
  4. View firewall service status .

    [root ~]# systemctl status firewalld
  5. Set up / Disable the firewall service to start automatically .

    [root ~]# systemctl enable firewalld
    Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
    Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
    [root ~]# systemctl disable firewalld
    Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
    Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

Planning tasks

  1. To execute a command at a specified time .

    • at - Line up tasks , To execute at a specified time .
    • atq - View the queue of tasks to be performed .
    • atrm - Delete pending tasks from the queue .

    Appoint 3 In the afternoon 5 Point to the task to be performed .

    [root ~]# at 5pm+3days
    at> rm -f /root/*.html
    at> <EOT>
    job 9 at Wed Jun 5 17:00:00 2019

    View the queue of tasks to be performed .

    [root ~]# atq
    9 Wed Jun 5 17:00:00 2019 a root

    Remove the specified task from the queue .

    [root ~]$ atrm 9
  2. Schedule a task - crontab.

    [root ~]# crontab -e
    * * * * * echo "hello, world!" >> /root/hello.txt
    59 23 * * * rm -f /root/*.log

    explain : Input crontab -e The command will open vim To edit Cron Expression and specify the triggered task , Above we have customized two planning tasks , One is every minute to /root In the catalog hello.txt Add output to hello, world!; The other is every day 23 when 59 Sub execution delete /root Directory to log A file with a suffix name . If you don't know Cron How to write expressions , You can refer to /etc/crontab Tips in the document ( I'll talk about it later ) Or search for “Cron Expression online generator ” To generate Cron expression .

    and crontab The relevant documents are in /etc Under the table of contents , By modifying the /etc In the catalog crontab Files can also be customized to plan tasks .

    [root ~]# cd /etc
    [root etc]# ls -l | grep cron
    -rw-------. 1 root root 541 Aug 3 2017 anacrontab
    drwxr-xr-x. 2 root root 4096 Mar 27 11:56 cron.d
    drwxr-xr-x. 2 root root 4096 Mar 27 11:51 cron.daily
    -rw-------. 1 root root 0 Aug 3 2017 cron.deny
    drwxr-xr-x. 2 root root 4096 Mar 27 11:50 cron.hourly
    drwxr-xr-x. 2 root root 4096 Jun 10 2014 cron.monthly
    -rw-r--r-- 1 root root 493 Jun 23 15:09 crontab
    drwxr-xr-x. 2 root root 4096 Jun 10 2014 cron.weekly
    [root etc]# vim crontab
    1 SHELL=/bin/bash
    2 PATH=/sbin:/bin:/usr/sbin:/usr/bin
    3 MAILTO=root
    4
    5 # For details see man 4 crontabs
    6
    7 # Example of job definition:
    8 # .---------------- minute (0 - 59)
    9 # | .------------- hour (0 - 23)
    10 # | | .---------- day of month (1 - 31)
    11 # | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
    12 # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
    13 # | | | | |
    14 # * * * * * user-name command to be executed

Network access and management

  1. Secure remote connection - ssh.

    [root ~]$ ssh root@120.77.222.217
    The authenticity of host '120.77.222.217 (120.77.222.217)' can't be established.
    ECDSA key fingerprint is SHA256:BhUhykv+FvnIL03I9cLRpWpaCxI91m9n7zBWrcXRa8w.
    ECDSA key fingerprint is MD5:cc:85:e9:f0:d7:07:1a:26:41:92:77:6b:7f:a0:92:65.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '120.77.222.217' (ECDSA) to the list of known hosts.
    root@120.77.222.217's password:
  2. Get resources through the Internet - wget.

    • -b Background download mode
    • -O Download to the specified directory
    • -r Recursive download
  3. Send and receive mail - mail.

  4. Network configuration tools ( used ) - ifconfig.

    [root ~]# ifconfig eth0
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 172.18.61.250 netmask 255.255.240.0 broadcast 172.18.63.255
    ether 00:16:3e:02:b6:46 txqueuelen 1000 (Ethernet)
    RX packets 1067841 bytes 1296732947 (1.2 GiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 409912 bytes 43569163 (41.5 MiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions
  5. Network configuration tools ( new ) - ip.

    [root ~]# ip address
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:16:3e:02:b6:46 brd ff:ff:ff:ff:ff:ff
    inet 172.18.61.250/20 brd 172.18.63.255 scope global eth0
    valid_lft forever preferred_lft forever
  6. Network accessibility check - ping.

    [root ~]# ping www.baidu.com -c 3
    PING www.a.shifen.com (220.181.111.188) 56(84) bytes of data.
    64 bytes from 220.181.111.188 (220.181.111.188): icmp_seq=1 ttl=51 time=36.3 ms
    64 bytes from 220.181.111.188 (220.181.111.188): icmp_seq=2 ttl=51 time=36.4 ms
    64 bytes from 220.181.111.188 (220.181.111.188): icmp_seq=3 ttl=51 time=36.4 ms
    --- www.a.shifen.com ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2002ms
    rtt min/avg/max/mdev = 36.392/36.406/36.427/0.156 ms
  7. Show or manage routing tables - route.

  8. View network services and ports - netstat / ss.

    [root ~]# netstat -nap | grep nginx
  9. Network monitoring and packet capturing - tcpdump.

  10. Copy of security files - scp.

[root ~]# scp root@1.2.3.4:/root/guido.jpg hellokitty@4.3.2.1:/home/hellokitty/pic.jpg
  1. File synchronization tool - rsync.

    explain : Use rsync It can realize the automatic synchronization of files , This is very important for file servers . About the use of this command , We will explain in detail when we talk about the project deployment later .

  2. Secure file transfer - sftp.

    [root ~]# sftp root@1.2.3.4
    root@1.2.3.4's password:
    Connected to 1.2.3.4.
    sftp>
    • help: Display help information .

    • ls/lls: Show far end / Local directory list .

    • cd/lcd: Switch remote / The local path .

    • mkdir/lmkdir: Create remote / Local directory .

    • pwd/lpwd: Show far end / Local current working directory .

    • get: Download the file .

    • put: Upload files .

    • rm: Delete remote files .

    • bye/exit/quit: sign out sftp.

Process management

  1. Check the process - ps.

    [root ~]# ps -ef
    UID PID PPID C STIME TTY TIME CMD
    root 1 0 0 Jun23 ? 00:00:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
    root 2 0 0 Jun23 ? 00:00:00 [kthreadd]
    ...
    [root ~]# ps -ef | grep mysqld
    root 4943 4581 0 22:45 pts/0 00:00:00 grep --color=auto mysqld
    mysql 25257 1 0 Jun25 ? 00:00:39 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
  2. Show process status tree - pstree.

    [root ~]# pstree
    systemd─┬─AliYunDun───18*[{AliYunDun}]
    ├─AliYunDunUpdate───3*[{AliYunDunUpdate}]
    ├─2*[agetty]
    ├─aliyun-service───2*[{aliyun-service}]
    ├─atd
    ├─auditd───{auditd}
    ├─dbus-daemon
    ├─dhclient
    ├─irqbalance
    ├─lvmetad
    ├─mysqld───28*[{mysqld}]
    ├─nginx───2*[nginx]
    ├─ntpd
    ├─polkitd───6*[{polkitd}]
    ├─rsyslogd───2*[{rsyslogd}]
    ├─sshd───sshd───bash───pstree
    ├─systemd-journal
    ├─systemd-logind
    ├─systemd-udevd
    └─tuned───4*[{tuned}]
  3. Find processes that match the specified criteria - pgrep.

    [root ~]$ pgrep mysqld
    3584
  4. Terminate the process by process number - kill.

    [root ~]$ kill -l
    1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
    6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
    11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
    16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
    21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
    26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
    31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3
    38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
    43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
    48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
    53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
    58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
    63) SIGRTMAX-1 64) SIGRTMAX
    [root ~]# kill 1234
    [root ~]# kill -9 1234

    Example : Force the termination of a running Redis process .

    ps -ef | grep redis | grep -v grep | awk '{print $2}' | xargs kill
  5. Terminate the process by process name - killall / pkill.

    The end is called mysqld The process of .

    [root ~]# pkill mysqld

    end hellokitty All processes of the user .

    [root ~]# pkill -u hellokitty

    explain : This kind of operation will make hellokitty The user is disconnected from the server .

  6. Put the process in the background .

    • Ctrl+Z- Shortcut key , Used to stop a process and put it in the background .
    • &- Put the process in the background .
    [root ~]# mongod &
    [root ~]# redis-server
    ...
    ^Z
    [4]+ Stopped redis-server
  7. Query background process - jobs.

    [root ~]# jobs
    [2] Running mongod &
    [3]- Stopped cat
    [4]+ Stopped redis-server
  8. Keep the process running in the background - bg.

    [root ~]# bg %4
    [4]+ redis-server &
    [root ~]# jobs
    [2] Running mongod &
    [3]+ Stopped cat
    [4]- Running redis-server &
  9. Put the background process in the foreground - fg.

    [root ~]# fg %4
    redis-server

    explain : Processes placed in the foreground can use Ctrl+C To stop it .

  10. Adjustment procedure / Process runtime priority - nice / renice.

  11. The process continues to work after the user logs out - nohup.

    [root ~]# nohup ping www.baidu.com > result.txt &
  12. Track process system calls - strace.

    [root ~]# pgrep mysqld
    8803
    [root ~]# strace -c -p 8803
    strace: Process 8803 attached
    ^Cstrace: Process 8803 detached
    % time seconds usecs/call calls errors syscall
    ------ ----------- ----------- --------- --------- ----------------
    99.18 0.005719 5719 1 restart_syscall
    0.49 0.000028 28 1 mprotect
    0.24 0.000014 14 1 clone
    0.05 0.000003 3 1 mmap
    0.03 0.000002 2 1 accept
    ------ ----------- ----------- --------- --------- ----------------
    100.00 0.005766 5 total

    explain : The usage and parameters of this command are complex , It is suggested that when you really use this command, you can understand it according to the actual needs .

  13. View current run level - runlevel.

    [root ~]# runlevel
    N 3
  14. Real time monitoring of resource usage of processes - top.

    [root ~]# top
    top - 23:04:23 up 3 days, 14:10, 1 user, load average: 0.00, 0.01, 0.05
    Tasks: 65 total, 1 running, 64 sleeping, 0 stopped, 0 zombie
    %Cpu(s): 0.3 us, 0.3 sy, 0.0 ni, 99.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
    KiB Mem : 1016168 total, 191060 free, 324700 used, 500408 buff/cache
    KiB Swap: 0 total, 0 free, 0 used. 530944 avail Mem
    ...
    • -c- Show the entire path of the process .
    • -d- Specify the interval between two screen swipes ( Seconds per unit ).
    • -i- Don't show idle or zombie processes .
    • -p- Displays information about the specified process .

System diagnosis

  1. System start abnormal diagnosis - dmesg.

  2. View system activity information - sar.

    [root ~]# sar -u -r 5 10
    Linux 3.10.0-957.10.1.el7.x86_64 (izwz97tbgo9lkabnat2lo8z) 06/02/2019 _x86_64_ (2 CPU) 06:48:30 PM CPU %user %nice %system %iowait %steal %idle
    06:48:35 PM all 0.10 0.00 0.10 0.00 0.00 99.80 06:48:30 PM kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty
    06:48:35 PM 1772012 2108392 54.33 102816 1634528 784940 20.23 793328 1164704 0
    • -A- Show all devices (CPU、 Memory 、 disk ) Health of .
    • -u- Show all CPU The load of .
    • -d- Show usage of all disks .
    • -r- Display memory usage .
    • -n- Display network operation status .
  3. View memory usage - free.

    [root ~]# free
    total used free shared buff/cache available
    Mem: 1016168 323924 190452 356 501792 531800
    Swap: 0 0 0
  4. Virtual memory statistics - vmstat.

    [root ~]# vmstat
    procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
    r b swpd free buff cache si so bi bo in cs us sy id wa st
    2 0 0 204020 79036 667532 0 0 5 18 101 58 1 0 99 0 0
  5. CPU Information Statistics - mpstat.

    [root ~]# mpstat
    Linux 3.10.0-957.5.1.el7.x86_64 (iZ8vba0s66jjlfmo601w4xZ) 05/30/2019 _x86_64_ (1 CPU) 01:51:54 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
    01:51:54 AM all 0.71 0.00 0.17 0.04 0.00 0.00 0.00 0.00 0.00 99.07
  6. Check the memory usage of the process - pmap.

    [root ~]# ps
    PID TTY TIME CMD
    4581 pts/0 00:00:00 bash
    5664 pts/0 00:00:00 ps
    [root ~]# pmap 4581
    4581: -bash
    0000000000400000 884K r-x-- bash
    00000000006dc000 4K r---- bash
    00000000006dd000 36K rw--- bash
    00000000006e6000 24K rw--- [ anon ]
    0000000001de0000 400K rw--- [ anon ]
    00007f82fe805000 48K r-x-- libnss_files-2.17.so
    00007f82fe811000 2044K ----- libnss_files-2.17.so
    ...
  7. Reporting equipment CPU and I/O Statistics - iostat.

    [root ~]# iostat
    Linux 3.10.0-693.11.1.el7.x86_64 (iZwz97tbgo9lkabnat2lo8Z) 06/26/2018 _x86_64_ (1 CPU)
    avg-cpu: %user %nice %system %iowait %steal %idle
    0.79 0.00 0.20 0.04 0.00 98.97
    Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
    vda 0.85 6.78 21.32 2106565 6623024
    vdb 0.00 0.01 0.00 2088 0
  8. Show all PCI equipment - lspci.

    [root ~]# lspci
    00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
    00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
    00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
    00:01.2 USB controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01)
    00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
    00:02.0 VGA compatible controller: Cirrus Logic GD 5446
    00:03.0 Ethernet controller: Red Hat, Inc. Virtio network device
    00:04.0 Communication controller: Red Hat, Inc. Virtio console
    00:05.0 SCSI storage controller: Red Hat, Inc. Virtio block device
    00:06.0 SCSI storage controller: Red Hat, Inc. Virtio block device
    00:07.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon
  9. Displays the status of the interprocess communication facility - ipcs.

    [root ~]# ipcs
    ------ Message Queues --------
    key msqid owner perms used-bytes messages ------ Shared Memory Segments --------
    key shmid owner perms bytes nattch status ------ Semaphore Arrays --------
    key semid owner perms nsems

Shell Programming

We mentioned that before ,Shell It's an application that connects users to the operating system , It provides a human-computer interface ( Interface ), Users access the services of the operating system kernel through this interface .Shell The script is one for Shell Write the script , We can go through Shell Script for system management , It can also be used for file operation . All in all , To write Shell Script for use Linux For a systematic person , It should be a standard skill .

There's a lot about Shell Knowledge of scripts , I'm not going to do that again Shell Script to do a comprehensive system of explanation , We use the following code to get a perceptual understanding of Shell Script will do .

Example 1: Enter two integers m and n, Calculate from m To n The sum of the integers of .

#!/usr/bin/bash
printf 'm = '
read m
printf 'n = '
read n
a=$m
sum=0
while [ $a -le $n ]
do
sum=$[ sum + a ]
a=$[ a + 1 ]
done
echo ' result : '$sum

Example 2: Automatically create folders and a specified number of files .

#!/usr/bin/bash
printf ' Enter folder name : '
read dir
printf ' Input file name : '
read file
printf ' Enter the number of files (<1000): '
read num
if [ $num -ge 1000 ]
then
echo ' The number of documents cannot exceed 1000'
else
if [ -e $dir -a -d $dir ]
then
rm -rf $dir
else
if [ -e $dir -a -f $dir ]
then
rm -f $dir
fi
fi
mkdir -p $dir
index=1
while [ $index -le $num ]
do
if [ $index -lt 10 ]
then
pre='00'
elif [ $index -lt 100 ]
then
pre='0'
else
pre=''
fi
touch $dir'/'$file'_'$pre$index
index=$[ index + 1 ]
done
fi

Example 3: Automatically install the specified version of Redis.

#!/usr/bin/bash
install_redis() {
if ! which redis-server > /dev/null
then
cd /root
wget $1$2'.tar.gz' >> install.log
gunzip /root/$2'.tar.gz'
tar -xf /root/$2'.tar'
cd /root/$2
make >> install.log
make install >> install.log
echo ' installation is complete '
else
echo ' It has been installed Redis'
fi
} install_redis 'http://download.redis.io/releases/' $1

Related resources

  1. Linux Command line shortcuts are often used

    Shortcut key Functional specifications
    tab Autocomplete command or path
    Ctrl+a Move the cursor to the beginning of the command line
    Ctrl+e Move the cursor to the end of the command line
    Ctrl+f Move the cursor one character to the right
    Ctrl+b Move the cursor one character to the left
    Ctrl+k Cut characters from cursor to end of line
    Ctrl+u Cut the character from the cursor to the beginning of the line
    Ctrl+w Cut a word in front of the cursor
    Ctrl+y Copy the contents of the named cut
    Ctrl+c Interrupt the task being performed
    Ctrl+h Delete a character before the cursor
    Ctrl+d Exit the current command line
    Ctrl+r Search history command
    Ctrl+g Exit history command search
    Ctrl+l Clear everything on the screen open a new line at the top of the screen
    Ctrl+s Lock the terminal so that it is temporarily unable to input content
    Ctrl+q Exit terminal lock
    Ctrl+z Stop the task being performed by the terminal and put it in the background
    !! Execute the last order
    ! Numbers Execute the history command corresponding to the number
    ! Letter Execute the most recent command that begins with a letter
    !$ / Esc+. Get the last parameter of the previous command
    Esc+b Move to the beginning of the current word
    Esc+f Move to the end of the current word
  2. man Refer to the instruction manual

    The title of the manual Functional specifications
    NAME Description and introduction of the order
    SYNOPSIS Use the basic syntax of this command
    DESCRIPTION Use the detailed description of the command , The function of each parameter , Sometimes this information appears in OPTIONS in
    OPTIONS Description of command related parameter options
    EXAMPLES Use the reference example of this command
    EXIT STATUS Exit status code at the end of the command , Usually 0 Indicates successful execution
    SEE ALSO Other commands or information related to commands
    BUGS Description of the defects associated with the command
    AUTHOR The author of the order introduces

Linux More articles on operating system related information

  1. linux File system related information

             linux The next file system is usually through a virtual file system (VFS) The differences in specific file system operations , Provide a unified interface for the operation of the upper layer . The bottom layer of the file system is the system IO Block read / write interface provided by cache layer , Implement logical block to physical block ...

  2. Linux Operating system related

    In the course of work , If you are exposed to more operating systems , Will find aix,hpux,CentOS,Redhat There's a difference in orders , It's actually referenced within the operating system bash(Bourne-Again SHell) Dissimilarity , present ...

  3. 《 Interesting talk Linux operating system 》 Learning notes ( One ): Why learn Linux And learning path

    Preface : The course of study comes from the geek time column < Interesting talk Linux operating system >, The author uses vivid metaphors and rich pictures to make the course easier to understand , In order to avoid forgetting the knowledge , I plan to record my learning process by taking notes . Li ...

  4. Linux Summary of command learning rmdir For information about the command, please refer to

    This article mainly introduces Linux Summary of command learning rmdir Information about the command , Friends in need can refer to (http://www.nanke0834.com) Command profile : rmdir The command is used to delete an empty directory , If the directory is not empty , ...

  5. linux Next, check the port according to the process number 、 Check the process number according to the port number , as well as netstat Related information ( Lack of knowledge at work )

    Check the process according to the port : lsof -i:port netstat -nap | grep port Check the port according to the process number : lsof -i|grep pid netstat -nap | grep pid according to ...

  6. Linux Operating system foundation ( The end )

    Abstract One .Linux Operating system overview   Two .Linux Operating system installation   3、 ... and .Linux File system and file base   Four .Linux Operating system command usage base   5、 ... and .Linux The foundation for installing and uninstalling applications   5、 ... and . Users and processes   6、 ... and . Related information ...

  7. linux Under the operating system c Introduction to language programming

    2)Linux Introduction to programming -- Process introduction  3)Linux Introduction to programming -- File operations  4)Linux Introduction to programming -- The concept of time  5)Linux Introduction to programming -- signal processing  6)Linux Introduction to programming -- Message management   ...

  8. Use C Language acquisition linux System related information

    I've been writing about shell When , It involves obtaining environment variable parameters and local computer related information , Including the computer device name , User name information , Here's a brief summary . Get the parameters of environment variables , You can use it directly getenv function .man About China getenv ...

  9. utilize python Data analysis and mining related information summary

    Xiaosheng is a sophomore this year , At present mainly engaged in software engineering data mining and analysis . I've been struggling to find a data preprocessor before . Data analysis . A unified platform for data visualization and software modeling . therefore , Xiaosheng has been studying in the opposite way java,R Language ,python,scala wait . ...

  10. linux operating system 1 Linux introduction

    Knowledge content : 1. Introduction to operating system 2.Linux Introduction to operating system 3.Linux install 4.Linux Introduction to major releases One . Operating system introduction 1. Why do I need an operating system Modern computer systems are made up of processors , Main memory , Hard disk , keyboard , mouse ...

Random recommendation

  1. sqlserver in BCP Command import and export

    Personal use export text file command : bcp [xxDB].[dbo].[xx_tb_name] out d:\temp\xxx.txt -c -t "\t" -T bcp yes SQL Serv ...

  2. nodejs Use in RabbitMq Message center system

    Mode one : adopt npm install amqp library Mode two : adopt rabbit.js library http://www.squaremobius.net/rabbit.js/ AMQP: Advanced message queue protocol , Is an open standard for application layer protocols , ...

  3. Compilation and installation apache

    1. Install dependency library :“Development  Tools”  “Server Platform Development”  pcre-devel 2. install apr,apr-util from yum Source install or go ap ...

  4. Android UiAutomator Quick debug

    Add the main function to the test class public static void main(String[] args){ String jarName,testClass, testName,androidId; jar ...

  5. flex_ Width completion

    Width 40px, The completion width of the other : <!DOCTYPE html> <html lang="en"> <head> <meta charse ...

  6. xgboost How to customize metric(python in )

    Just taking part in the competition of Ctrip , With xgboost The algorithm of , But the evaluation function of Ctrip competition is strange , Not the traditional ones , It's about taking precision≥0.97 Under the circumstances ,recall The maximum of . There is no doubt that this evaluation function is to be written by ourselves ( The official didn't give ...

  7. Mysql The basic command diagram of

    If you can't see clearly , Right click on the picture to open in the new tab ! This is the result of my work ! If there is something important to add -..

  8. 10_30_unittest

    1. Assertion 1).self.assertEqual(2,res)# Expectations qian. Result value hou2)TextTestRunner Source code Necessary parameters 3) test result Context manager with open(" ...

  9. 【BZOJ4946】[NOI2017] vegetables ( greedy )

    [BZOJ4946][NOI2017] vegetables ( greedy ) Topic BZOJ Luogu UOJ Answer key Suddenly found this year \(NOI\) Before the time cut to previous years \(NOI\) The subject of , Just \(2017\) I don't know how to start ( It must be ...

  10. asp.net core 2.0 Configuration in (1)---Configuration

    Configuration is a process of assembling data dictionary , A dictionary is a key value pair , So configuration is a key value pair . stay asp.net core Configuration is supported by four basic types , yes ①IConfigurationSource②ICon ...