One 、Linux Operating system overview

1、 Development

1991 Linus Linux 0.0.1 edition , The code is 8K That's ok . Now the latest version is 4.1.4.Linux Joined the GNU, The whole is based on GPL agreement , Allow open source 、 Share and spread 、 modify .

2、 form

(1)keanel– kernel :

Core program , Used to manage hardware devices 、 The thread process of the system 、 Memory 、 Swap space 、 file system 、 Elvish process ( Daemon ) etc. . It mainly realizes the control and management function between system program and hardware .

(2)Shell:

Man machine interface wrapped outside the kernel , Functions for dealing with users and the kernel , Be similar to windows Of CMD.
adopt Shell Communicate the input command with the kernel , The kernel can operate correctly .Shell There are different categories , such as Bourne shell(sh),Korn shell(ksh)、C shell (csh)、Bourne-again shell(bash)、tcsh. The most commonly used of these are csh and bash, The prompt is as follows :
    sh–Bash :#root $user
    csh–:#root %user

(3)user application

 

(4)Files System– file system , Manage files and directories

 

3、Linux Characteristics of :

Multi user 、 multitasking ( process 、 threading ), Multi platform , Graphical interface (x-windows)、 Low hardware configuration 、 Communication and networking 、 Application support ( Editor 、 Editing tools 、 database 、 Office software 、 Graph processing 、Internet application 、 game )

 

Two 、Linux Operating system installation

1、Linux The choice of

red hat: Enterprise class , We've started charging ( commercial ).
ubuntu: Desktop open source , More pure Linux,android The official compiler operating system , Fast development 、 Already supported ARM framework .

2、 install Ubuntu Desktop

Preparation before installation

current PC All machines can meet the requirements .

 

Software preparation

ubuntu:16
 ubuntu Desktop : The desktop version
 ubuntu Server : Server Edition
 Cloud Infrastructure : Cloud version

 

Installation mode

windows install ,CD,USB

 

Download mirroring ISO

stay ubuntu Download it on the official website

 

install VMware

Choose a typical installation , It can be installed normally . Enter the activation code when needed , Just download it from the Internet vm10keygen.exe You can activate it

 

New virtual machine

choice ubuntu Mirror image , Configure the user name correctly 、 password . Disk settings 20G, Memory 1-2G, processor 2 Two processors

 

Turn on virtual machine

When the configuration is complete , Turn on virtual machine , After waiting for a certain time, you will see the boot login interface , The user password is the password when the virtual machine is set up .

 

Basic operation

ctrl+alt F2~  You can enter the terminal interface
ctrl+alt F7  Enter the desktop interface
ctrl+alt+t Text editing

 

3、 ... and 、Linux File system and file base

1、 File System Overview

A system used to organize computer files and data , It is a system service program encapsulated by the operating system , It's actually a software program , It is used to store and manage computer files and data .
File systems are classified as follows :

     Disk file system :NTFS,EXT3
     Flash file system :JFFS2,YAFFS
     Database file system :BFFS,WINFS
     Network file system :NFS
     Virtual file system :VFS(Proc)

File system functions : Can define how documents are organized , File structure ; Provides an environment for creating and accessing files ( Directories and files )

 

2、Linux File systems and files

(1)EXT3: It's a log file system , Every file in the system has an index , Every user action on the file is recorded in the log , Form a task queue .
(2)SWAP: It's the file system of the swap partition , Be similar to windows Virtual memory , There are two ways to realize it :
The first is to arrange memory, like a memory pool , To optimize ;
The second is to simulate the space on the hard disk as memory .
Swap yes Linux Virtual memory , Set the size when installing , It's usually set to twice the physical memory .
(3)Linux attribute :
Blue : Directory file
green : Executable file
The light blue : Link to the file
Red : Compressed files
gray : Other documents

 

  notes :ls View directory ,ls -l Look at the long list
cd Transfer Directory
pwd Always look at the current directory
(4) Directory structure
linux The structure of is made up of many file blocks , And Windows Different zones .

Catalog
File content should be placed
/bin
The system has many directories where the executable files are placed , but /bin A special . because /bin Placed in the single maintenance mode can also be operated instructions . stay /bin The instructions below can be changed root It's the same as the general account , There are mainly :cat,chmod( Modify the permissions ), chown, date, mv, mkdir, cp, bash And so on .
/boot
It is mainly used to place files that will be used when the machine is turned on , Include Linux Core files and boot menu and boot required profile and so on .Linux kernel The commonly used file name is :vmlinuz , If you are using grub This boot manager , Then there will be /boot/grub/ This directory .
/dev
stay Linux On the system , All devices and peripherals exist in this directory as files . Just by accessing a file in this directory , It's like accessing a device . More important files are /dev/null, /dev/zero, /dev/tty , /dev/lp*, / dev/hd*, /dev/sd* wait
/etc
Almost all the main configuration files of the system are placed in this directory , For example, the account and password file of a person 、 Start files of various services, etc . Generally speaking , The file attributes in this directory can be consulted by ordinary users , But only root Have the right to modify . FHS It is not recommended to place executable files (binary) In this directory . The more important files are :/etc/inittab, /etc/init.d/, /etc/modprobe.conf, /etc/X11/, /etc/fstab, /etc/sysconfig/ wait . in addition , The important contents are :/etc/init.d/ : Default start of all services script It's all here , For example, to start or shut down iptables Words : /etc/init.d/iptables start、/etc/init.d/ iptables stop
/etc/xinetd.d/ : That's what's called super daemon Manage the profile directory of various services .
/etc/X11/ : And X Window All the relevant profiles are here , In especial xorg.conf or XF86Config these two items. X Server My profile .
/home
This is the default user directory of the system (home directory). When you add a general user account , The default user home directory will be standardized here . Here's the important thing , Home directory has two codes : 
~ : Represents the home directory of the current user , and ~guest: The user name is guest Home directory .
/lib
There are many function libraries in the system , and /lib The function library that will be used at startup is placed , And in /bin or /sbin The next instruction will call the library . What is a function library ? You can think of him as a plug-in , Some instructions must have these plug-ins to run the program smoothly . Especially important is /lib/modules/ This directory , Because the directory will place core related modules ( Driver ).
/media
media It's the English of the media , seeing the name of a thing one thinks of its function , This /media There's a removable device underneath . Including floppy disks 、 CD-ROM 、DVD The devices are temporarily attached here . Common file names are :/media/floppy, /media/cdrom wait .
/mnt
If you want to temporarily mount some additional devices , It is generally recommended that you place it in this directory . In ancient times , The purpose of this directory is related to /media It's the same . It's just that /media after , This directory is used for temporary mounting .
/opt
This is a directory for third party software . What is third party collaboration software ? for instance ,KDE This desktop management system is a separate project , But he can install it to Linux In the system , therefore KDE It is recommended to place the software in this directory . in addition , If you want to install additional software yourself ( Not the original distribution Provided ), Then you can also install your software here . however , Former Linux In the system , We're still used to putting it in /usr/local Under the table of contents .
/root
System administrator (root) Home directory . The reason why it's here , This is because if you enter the single person maintenance mode and only mount the root directory , The directory can have root Home directory , So we would hope root The home directory of is placed in the same partition as the root directory .
/sbin
Linux Many instructions are used to set the system environment , These instructions are just root Can be used to set the system , Other users can only query at most . Put it in /sbin The bottom is needed during startup , It includes power on 、 Repair 、 Instructions required to restore the system . As for some server software programs , It's usually placed in /usr/sbin/ among . As for the system executable file generated by the software installed on the machine itself (system binary), Then put it in /usr/local/sbin/ In the middle . Common instructions include :fdisk, fsck, ifconfig, init, mkfs wait .
/srv
srv Can be regarded as service Abbreviation , It's after some web services start up , The directory of information that these services need to access . Common services such as WWW, FTP wait . for instance ,WWW The web information required by the server can be placed in /srv/www/ Inside . ha-ha , It seems that the code we usually write should be put here .
/tmp
This is where ordinary users or running programs can temporarily put files . This directory is accessible to anyone , So you need to clean it up regularly . Of course , Important information cannot be placed in this directory . because FHS It's even suggested that when it's turned on , We should put /tmp Delete all the information below .

 

Four 、Linux Operating system command usage base

Catalog
File content should be placed
/bin
The system has many directories where the executable files are placed , but /bin A special . because /bin Placed in the single maintenance mode can also be operated instructions . stay /bin The instructions below can be changed root It's the same as the general account , There are mainly :cat,chmod( Modify the permissions ), chown, date, mv, mkdir, cp, bash And so on .
/boot
It is mainly used to place files that will be used when the machine is turned on , Include Linux Core files and boot menu and boot required profile and so on .Linux kernel The commonly used file name is :vmlinuz , If you are using grub This boot manager , Then there will be /boot/grub/ This directory .
/dev
stay Linux On the system , All devices and peripherals exist in this directory as files . Just by accessing a file in this directory , It's like accessing a device . More important files are /dev/null, /dev/zero, /dev/tty , /dev/lp*, / dev/hd*, /dev/sd* wait
/etc
Almost all the main configuration files of the system are placed in this directory , For example, the account and password file of a person 、 Start files of various services, etc . Generally speaking , The file attributes in this directory can be consulted by ordinary users , But only root Have the right to modify . FHS It is not recommended to place executable files (binary) In this directory . The more important files are :/etc/inittab, /etc/init.d/, /etc/modprobe.conf, /etc/X11/, /etc/fstab, /etc/sysconfig/ wait . in addition , The important contents are :/etc/init.d/ : Default start of all services script It's all here , For example, to start or shut down iptables Words : /etc/init.d/iptables start、/etc/init.d/ iptables stop
/etc/xinetd.d/ : That's what's called super daemon Manage the profile directory of various services .
/etc/X11/ : And X Window All the relevant profiles are here , In especial xorg.conf or XF86Config these two items. X Server My profile .
/home
This is the default user directory of the system (home directory). When you add a general user account , The default user home directory will be standardized here . Here's the important thing , Home directory has two codes : 
~ : Represents the home directory of the current user , and ~guest: The user name is guest Home directory .
/lib
There are many function libraries in the system , and /lib The function library that will be used at startup is placed , And in /bin or /sbin The next instruction will call the library . What is a function library ? You can think of him as a plug-in , Some instructions must have these plug-ins to run the program smoothly . Especially important is /lib/modules/ This directory , Because the directory will place core related modules ( Driver ).
/media
media It's the English of the media , seeing the name of a thing one thinks of its function , This /media There's a removable device underneath . Including floppy disks 、 CD-ROM 、DVD The devices are temporarily attached here . Common file names are :/media/floppy, /media/cdrom wait .
/mnt
If you want to temporarily mount some additional devices , It is generally recommended that you place it in this directory . In ancient times , The purpose of this directory is related to /media It's the same . It's just that /media after , This directory is used for temporary mounting .
/opt
This is a directory for third party software . What is third party collaboration software ? for instance ,KDE This desktop management system is a separate project , But he can install it to Linux In the system , therefore KDE It is recommended to place the software in this directory . in addition , If you want to install additional software yourself ( Not the original distribution Provided ), Then you can also install your software here . however , Former Linux In the system , We're still used to putting it in /usr/local Under the table of contents .
/root
System administrator (root) Home directory . The reason why it's here , This is because if you enter the single person maintenance mode and only mount the root directory , The directory can have root Home directory , So we would hope root The home directory of is placed in the same partition as the root directory .
/sbin
Linux Many instructions are used to set the system environment , These instructions are just root Can be used to set the system , Other users can only query at most . Put it in /sbin The bottom is needed during startup , It includes power on 、 Repair 、 Instructions required to restore the system . As for some server software programs , It's usually placed in /usr/sbin/ among . As for the system executable file generated by the software installed on the machine itself (system binary), Then put it in /usr/local/sbin/ In the middle . Common instructions include :fdisk, fsck, ifconfig, init, mkfs wait .
/srv
srv Can be regarded as service Abbreviation , It's after some web services start up , The directory of information that these services need to access . Common services such as WWW, FTP wait . for instance ,WWW The web information required by the server can be placed in /srv/www/ Inside . ha-ha , It seems that the code we usually write should be put here .
/tmp
This is where ordinary users or running programs can temporarily put files . This directory is accessible to anyone , So you need to clean it up regularly . Of course , Important information cannot be placed in this directory . because FHS It's even suggested that when it's turned on , We should put /tmp Delete all the information below .
Be careful :
a) Reference to the directory structure http://www.jb51.net/LINUXjishu/151820.html
b) Directory names are case sensitive

 

Four 、Linux Operating system command usage base

1、 Command line editing and alias use

 

(1) Command format

$command [option(s)] [argument(s)]
Command name Space       Options   Space      Parameters
Be careful :


On the command line , There is a space between each two parts
The most command characters that can be used on each command line are 256 individual
Commands are case sensitive
Different command prompts use separator symbols “/”
Parameters in the command / The options can be multiple , And the parameter is actually to pass in the main function of the command program main Parameters of .
More orders can be Baidu 《Linux The command of 》 The introduction is very detailed .

 


(2) Command alias

alias alias-name=’value’  // Create an alias
 unalias [-a][ Alias ]   To delete an alias
 alias You can list aliases

 

  Be careful : The above method is only limited to temporary renaming , It doesn't work when you restart the machine

2、shell Special characters for

(1) wildcard * ?

* : Pass through 0 Characters or more ? : Match any single character [s] : Match any character in a certain range such as : cd Desktop cd [A-D]es*

(2) Multiple commands on one line

Multiple commands on one line : Use... Between commands “;” separate

cd ; ls

(3) I / O redirection

a) Output redirection :>,>>

>  : Put the output of a command into a file
>> : Output redirection does not override the source file , Add... At the end of the original file 

take ls The output of is output to sss.txt

 

  use “>” The output is as follows

 

  And then use “>>” The test results are as follows

 

b) Input redirection :<

Next, implement the following input redirection :

 

c) Pipe, :|

Pipe, “|”: Take the output of one process as the input of another

   Enter the command  :
      ls -l /etc | cat

 

 

 

The results are shown in the figure above .

c) other :%,$,~

% : Operation control , And so on
$ : Take the value of a column , Take variable values, etc

3、 Online help 、 Clear screen and history order

(1) Online help

    man name
    man -k keyword

(2) Clear the screen clear

(3) History history(history -n)

history : Check out recent commands , most 500 strip
history n : It's been used recently n Bar command
!n    : Carry out the latest n Bar command
!!    : Execute the first command recently used
Up key : Execute the last order
Key down : Execute next command 

4、 file management

(1) Check the file directory

a. pwd: Show current working directory
b. cd [ The directory to change ] : Change the directory

cd  // Back to the home directory of the current user
cd ~// Back to the home directory of the current user
cd ~[ user name ]  // Enter the home directory of the specified user 

c. ls : Lists the files and subdirectories of the current directory

 

d. file

Functional specifications : Identify document type .

language Law :file [-beLvz][-f < Name file >][-m < Magic digital files >…][ File or directory …] 

Additional explanation : adopt file Instructions , We were able to identify the type of the file .

ginseng Count :
-b When listing the identification results , Do not show file name . 
-c Detailed display of instruction execution process , A situation that facilitates troubleshooting or analysis of program execution . 
-f< Name file > Specify name file , Its content has one or more file names , Give Way file Identify these documents in order , The format is one file name per column .
-L Directly display the category of the file that the symbolic connection points to . 
-m< Magic digital files > Specify magic digital file . 
-v Display version information . 
-z Try to read the contents of the compressed file .

 

(2) Create and delete file directories

 

1、 create a file

touch filename // create a file
/*
The file name does not exist , Then create a new empty file
If the filename exists , Update the modified access time of the file , The content remains the same
*/

Functional specifications : Change the file or directory time .

language Law :touch [-acfm][-d < Date time >][-r < A reference document or catalogue >][-t < Date time >][–help] [–version][ File or directory …] or touch [-acfm][–help][–version][ Date time ][ File or directory …]

Additional explanation : Use touch Command to change the date and time of a file or directory , Including access time and change time .

ginseng Count :
-a or –time=atime or –time=access or –time=use Only change access time . 
-c or –no-create No files are created . 
-d< Time date > Use the specified date and time , Not now . 
-f This argument ignores not be processed , Only responsible for solving BSD edition touch Compatibility of instructions . 
-m or –time=mtime or –time=modify Only change the change time . 
-r< A reference document or catalogue > The date and time of the specified file or directory , All set to the same date and time as the reference file or directory . 
-t< Date time > Use the specified date and time , Not now . 
–help Online Help . 
–version Display version information .

 

2、 Create directory

Functional specifications : Build directory

language Law :mkdir [-p][–help][–version][-m < Directory attribute >][ Directory name ]

Additional explanation :mkdir You can create a directory and set the permissions of the directory at the same time .

ginseng Count :
  -m< Directory attribute > or –mode< Directory attribute >   When creating a directory, set the permissions of the directory at the same time .
  -p or –parents   If the upper directory of the directory to be created has not been created yet , Then the upper directory will be created .
  –help   Display help .
  –verbose   Display detailed information when executing .
  –version   Display version information .

 

3、 Delete file

rm(remove)

Functional specifications : Delete files or directories .

language Law :rm [-dfirv][–help][–version][ File or directory …]

Additional explanation : perform rm Command to delete a file or directory , If you want to delete a directory, you must add the parameter ”-r”, Otherwise, the default will only delete the file . 
ginseng Count :
-d or –directory Directly delete the hard connection data of the directory to be deleted into 0, Delete this directory . 
-f or –force Force deletion of files or directories . 
-i or –interactive Ask the user before deleting an existing file or directory . 
-r or -R or –recursive Recursive processing , Handle all files and subdirectories under the specified directory together . 
-v or –verbose Display during execution of instructions . 
–help Online Help . 
–version Display version information .

 

4、 Delete directory

rmdir(remove directory)

Functional specifications : Delete directory .

language Law :rmdir [-p][–help][–ignore-fail-on-non-empty][–verbose][–version][ Catalog …]

Additional explanation : When there is an empty directory to delete , You can use rmdir Instructions .

ginseng Count :
  -p or –parents   After deleting the specified directory , If the upper directory of the directory has become an empty directory , Then delete them .
  –help   Online Help .
  –ignore-fail-on-non-empty   Ignore error messages for non empty directories .
  –verbose   Display during execution of instructions .
  –version   Display version information .

 

(3) Display file contents

cat
Permission to use : All users  
Usage mode :cat [-AbeEnstTuv] [–help] [–version] fileName 
explain : Connect the file string to the basic output ( Screen or add > fileName To another file )
Parameters :
-n or –number from 1 Starting number for the number of lines for all outputs
-b or –number-nonblank and -n be similar , But not for the blank line number
-s or –squeeze-blank When the above encounter with a continuous two lines of blank lines , Substitution with a blank line on line
-v or –show-nonprinting
Example :
cat -n textfile1 > textfile2 hold textfile1 After adding the line number to the file content, enter textfile2 In this file
cat -b textfile1 textfile2 >> textfile3 hold textfile1 and textfile2 The contents of the file plus the line number ( Blank lines do not add ) Then attach the content to textfile3 in .

 

cat < /dev/stdin > 1.txt // Using input redirection  CRTL+D  End input
cat /dev/null > 1.txt   // Output redirection to clear 

head: Find the first few lines of the file

head [-n] filename

tail : How many lines to find the file

tail [-n] filename

more: Split screen display

more filename

(4) Copy and move file directories

cp  Source file   Target file 

cp(copy)

Functional specifications : Copy files or directories .

language Law :cp [-abdfilpPrRsuvx][-S < Backup suffix string >][-V < Backup >][–help][–spares=< Use time >][–version][ Source file or directory ][ Target file or directory ] [ Destination directory ]

Additional explanation :cp Instructions are used to copy files or directories , If more than two files or directories are specified at the same time , And the final destination is an existing directory , Then it will copy all the files or directories previously specified to the directory . If multiple files or directories are specified at the same time , And the final destination is not an existing directory , Then an error message will appear .

mv [ Source file 、 Catalog ] [ The destination file 、 Catalog ]

Functional specifications : Move or rename an existing file or directory .

language Law :mv [-bfiuv][–help][–version][-S < Attach suffix >][-V < Method >][ Source file or directory ][ Target file or directory ]

Additional explanation :mv Removable files or directories , Or change the name of a file or directory .

ginseng Count :
-b or –backup If you need to overwrite the file , Backup before overwriting . 
-f or –force If the target file or directory is a duplicate of an existing file or directory , Then it directly covers the existing text Document or catalog . 
-i or –interactive Ask the user before covering . 
-S< Attach suffix > or
–suffix=< Attach suffix > And -b Parameters are used together , You can specify the suffix to be attached to the backup file . 
-u or –update When moving or changing file names , If the target file already exists , And its file date is newer than the source file , Do not overwrite the target file . 
-v or –verbose Display detailed information when executing . 
-V=< Method > or
–version-control=< Method > And -b Parameters are used together , You can specify the backup method . 
–help Display help . 
–version Display version information

 

(5) File directory permissions

 

1. jurisdiction

Linux Every file and Mulan road in the system has access permission , Use it to determine how you can access and manipulate files and directories .
Authority classification :
r  Read permission : You can open the file 、 Directory read view ;
w Write permissions : The file 、 Directory can be written to change ;
x Executable : Executable for files ( Executable file )、 For a directory, you can find the contents of the directory
 1. No authority
  Such as
Ls -l
-rwxr( owner ) -xr( Group ) -x( others )
Read write operations correspond to

 

 

2. The object to which the permission belongs

File owner : The current person who generated the file or directory , The highest authority , use u Express .
The user group to which the file belongs : One or more people in the same group assigned by the system administrator , use g Express .
Other people's rights to this file : Except for the owner 、 People outside the user group , use o Express .
All the people : Including the owner , User group 、 Other users , use a Express

 

3. List content

(1)chmod: Modify access to the file directory , The precondition of modifying permissions is to have operational permissions when modifying permissions .
(a) Use letters for permissions
Who(u、g、o、a)+cp(“=” Set the permissions “+” Add permissions “-” Delete permission )+permission(“r” Read permission “w” Write permissions “x” Operating authority )
for example :
chmod  g=wr  1.c;
chmod  u+w,g-w,o=wr 1.c
(b) Use octal numbers to represent permissions
 r      w   x
 0      0       0   No authority
 1      1       1   Have permission
R:4,w;2,x:1
for example  
Chmod 777 build  take build The authority to become everyone rwx
Be careful : stay Ubuntu The default permissions for files created in are 664
(2) Chown Change the owner and group of the file  
Chown [ Options ] User groups or
(3)chgroup Change the group to which the file or directory belongs    

 

(6) Find files

1、Find: Find files
find path expression [action] 
find The path found by the usage condition of must have read permission .
The search option finds... Through the file properties
-name Search by name
-user According to the user ( Owner of document )
-size According to the size of the file
-mtime According to the last modification time
-atime According to the last visit time
-type By file type f:file  d:directory
-perm : According to the authority of the file
for example :
find . -user root
 177  find / -name b*
  178  find / -name b* -print
  179  ls
  180  ls;find . -name 1* -type f: -print
  181  ls;find . -name 1* -type f -print
  182  ls;find ../ -name 1* -type f -print
  183  ls;find ../ -name 1* -type f -print 
2、Locate
locate
Functional specifications : Find files .

language Law :locate [-d < Database files >][–help][–version][ Template Styles …]

Additional explanation :locate The command is used to find the eligible files , It will go to save the file and directory name in the database , Find a file or directory that matches the template style criteria .

ginseng Count :
-d< Database files > or –database=< Database files >  Set up locate The database used by the command .locate The default database of the command is located in /var/lib/slocate Directory , The file named slocate.db, You can use this parameter to specify . 
–help Online Help . 
–version Display version information .
Be careful : You need to follow the new database to view the new directory ,updatedb

 

(7) Filtering and Statistics

grep

Find out the results that contain some strings , Filter files or output results , There is a certain degree of respect for case requirement .

grep [option] string filename

Additional explanation :grep Command is used to find a file whose content contains the specified template style , If the content of a file is found to conform to the specified template style , Preset grep The command displays the column containing the template style . If not specify any file name , Or file name is given “-”, be grep Instruction data from the standard input device .
-i   Ignore case
-v Reverse matching ( Find results that do not contain strings )

 

  example 1 stay 1.c Find in the file that contains in The sentence of
Write a statement to implement the file directory containing “root” The statement is stored in ls_root.txt In the document
The implementation is shown in the figure below :

 

  example 2 Create... In the current directory test1.txt and test2.txt file , Separate deposit “hello world (test1);” and “hello world from test 2”.
List the contents in the current directory test The file of , And then put it in the content “test2” Output to result In file .

 touch result.txt
    ls test*.txt | xargs grep test2 \
    >  > result.txt  ; cat result.txt

 

 

Be careful : xargs : The output of the previous pipeline is two , As the input parameter of the next pipeline

wc

wc: Statistics file or output results

wc [ Options ]  file name
- l  Count how many lines
- w  Count how many words
- c  Count how many characters 

example :

 

  example : Show how many of the current directory first test The opening document

 

 

5、 ... and 、 Users and processes


1、 Date time process view

a)date: Show date time
b)cal : Show calendar
cal year month

2、 Process query

ps List the processes running in the current system

process : A program that can accomplish a task .

 ps [ Options ]
ps : List the related processes under your current terminal

 

 

 ps -e : List the currently running processes

 

 ps -f : List a list of completed processes

 

 

ps -U : Find a user's process

-auwx : List a list of completed processes , And -f It's in different forms

 

3、 User management

a) su

su user name   : Switch accounts

b)sudo

sudo : Run with administrator privileges

4、 Power management

a)shutdown

Safely shut down or restart Linux System , It prompts a warning message to all login users on the system before the system is shut down . The command also allows the user to specify a time parameter 、 It can be a precise time 、 It can also be a period of time from now on .
The exact time format : hh:mm Represents hours and minutes , The time period is determined by + And minutes . The system will automatically synchronize the data after executing the command
Functional specifications : System shutdown command .

language Law :shutdown [-efFhknr][-t Number of seconds ][ Time ][ Warning message ]

Additional explanation :shutdown Command to close all programs , And according to the needs of users , To restart or shut down .

ginseng Count :
-c When executed ”shutdown -h 11:50” When the command , Just press + Key can interrupt the shutdown command . 
-f Do not execute on restart fsck. 
-F Execute on restart fsck. 
-h Shut down the system . 
-k Just sending information to all users , But it doesn't actually shut down . 
-n Do not call init Program shutdown , And by the shutdown Do it yourself . 
-r shutdown Then restart . 
-t< Number of seconds > How many seconds is the delay between sending a warning message and deleting a message . 
[ Time ] Set how long to run shutdown Instructions . 
[ Warning message ] Information to be sent to all logged in users .

b)reboot

Functional specifications : Reboot .

language Law :dreboot [-dfinw]

Additional explanation : perform reboot The command stops the system , And reboot .

ginseng Count :
  -d Do not write data to log file when rebooting /var/tmp/wtmp. This parameter has ”-n” Parameter effect . 
  -f Force a reboot , Do not call shutdown Function of instruction . 
  -i Before restarting , Shut down all network interfaces first . 
  -n Do not check whether there are unfinished programs before restarting . 
  -w Just test , It's not really rebooting the system , It will only write the data of rebooting to /var/log In the catalog wtmp Log files .

 

c)halt

Functional specifications : Shutdown system .

language Law :halt [-dfinpw]

Additional explanation :halt We'll test the system first runlevel. if runlevel by 0 or 6, Then shut down the system , Otherwise, call shutdown To shut down the system .

ginseng Count :
  -d Not in wtmp It's recorded in . 
  -f Regardless of the current runlevel why , Do not call shutdown That is to force the system to shut down . 
  -i stay halt Before , Shut down all network interfaces . 
  -n halt front , You don't have to do it first sync. 
  -p halt after , perform poweroff. 
  -w Only in wtmp It's recorded in , Instead of actually ending the system .

 

4、 User management supplement

(1) User password requirements

The user's password requirements are 6~8 Characters , It should at least include 2 Letters 、1 A number or special character , And it can't be the same as the user name , And different from the old password , There must be at least three characters different from the previous password .

(2) Change password command

passwd
Enter the command passwd
Enter the original password ****
Enter the new password
Confirm the new password

Be careful : In the process of entering the password, the machine doesn't do anything

 

(3) Find user

id

To view the user ID( user name ) And its group ID( Group name )

user

View the users who have logged into the current system , Only the user name is displayed .

who

View user details

who am i

View the current user's own information

whoanmi

View the current user's own user name

 

 

6、 ... and 、 Related information query

Look at the disk information

du

Display disk usage summary information
du With Block Display in unit mode
-k  With k Byte mode display
-m With m Byte mode display
-s Displays the total disk size occupied by the contents in the current directory , With Block In units of
With Block The unit number is shown in k The number displayed in byte mode 2 times ,1k byte =2 individual Block

df

Displays the disk space usage of the entire file system
-k With k Byte mode display

 

7、 ... and 、 The network configuration


1、ping

Check the connection between the current machine and another machine
ping The name of the host or the name of the host IP: towards ping Later hosts send packets , If ping If the host has a reply, it means it is connected .

 

 Functional specifications : Detection host .
language Law :ping [-dfnqrRv][-c< Number of completions >][-i< Seconds apart >][-I< Network interface >][-l< Load ahead >][-p< Template Styles >][-s< Packet size >][-t< Survival value >][ Host name or IP Address ]
Additional explanation : perform ping Command will use ICMP Transfer protocol , Send a message asking for a response , If there is no problem with the network function of the remote host , They'll respond to the message , So we know that the host is working normally .
ginseng Count :
  -d    Use Socket Of SO_DEBUG function .
  -c< Number of completions >    Set the number of times to complete a request response .
  -f    Limit detection .
  -i< Seconds apart >    Specify the time interval between sending and receiving information .
  -I< Network interface >    Use the specified network interface to send out packets .
  -l< Load ahead >    Set before sending the required information , Packets sent first .
  -n    Output only values .
  -p< Template Styles >    Set the template style to fill the packet .
  -q    Do not show instruction execution , Except for information about the beginning and the end .
  -r    Ignore the ordinary Routing Table, Send the packet directly to the remote host .
  -R    Record the routing process .
  -s< Packet size >    Set packet size .
  -t< Survival value >    Set the survival value TTL Size .
  -v    Display the execution process of the instruction in detail .

 

 

2、ifconfig

View and configure the network parameter information of the current machine

ifconfig -a //  The display output depends on the current machine IP、Netmask、Gateway Wait for network information
ifconfig eth0 up(down) // Activate and disable a network adapter
ifconfig eth0 [ip address] netmask [address] // Set up IP And subnet mask 

 

 Functional specifications : Display or set up network devices .
language Law :ifconfig [ Network devices ][down up -allmulti -arp -promisc][add< Address >][del< Address >][<hw< Network device type >< Hardware address >][io_addr<I/O Address >][irq<IRQ Address >][media< Types of Internet media >][mem_start< Memory address >][metric< number >][mtu< byte >][netmask< Subnet mask >][tunnel< Address >][-broadcast< Address >][-pointopoint< Address >][IP Address ]
Additional explanation :ifconfig You can set the status of network devices , Or display the current settings .
ginseng Count :
  add< Address >    Set up network devices IPv6 Of IP Address .
  del< Address >    Delete network device IPv6 Of IP Address .
  down    Turn off the specified network device .
  <hw< Network device type >< Hardware address >    Set the type of network device and hardware address .
  io_addr<I/O Address >    Set up the I/O Address .
  irq<IRQ Address >    Set up the IRQ.
  media< Types of Internet media >    Set the media type of the network device .
  mem_start< Memory address >    Set the starting address of the network device in the main memory .
  metric< number >    Specifies when calculating the number of transfers of packets , The number to be added .
  mtu< byte >    Set up the MTU.
  netmask< Subnet mask >    Set the subnet mask of the network device .
  tunnel< Address >    establish IPv4 And IPv6 The tunnel communication address between .
  up    Start the specified network device .
  -broadcast< Address >    Treat the packets to be sent to the specified address as broadcast packets .
  -pointopoint< Address >    Establish a direct connection with the network device at the specified address , This mode has the function of confidentiality .
  -promisc    Turn off or start the... Of the specified network device promiscuous Pattern .
  [IP Address ]    Specify the... Of the network device IP Address .
  [ Network devices ]    Specify the name of the network device .

 

 

8、 ... and 、Linux The foundation for installing and uninstalling applications

1、Linux Installation package

Linux Installation packages are usually tar The format of , At the same time, it also supports self-defined formats .
stay redhat The format of the software installation package in is usually rpm
stay Ubuntu The format of the software installation package in is usually deb

2、 General rules for naming packages

stay Linux The common naming format in is :
Software name, version number - Revision number Architecture . Extension

3、 Offline installation and uninstall of installation package

dpkg
dpkg  -i   install
dpkg     -p   uninstall
Source file installation process : To configure configure  >>  compile make  >>  install make  install

4、 Install and uninstall online

install :apt-get install 
uninstall :apt-get remove -purge  

Nine 、Linux System VI The use of basic chapter

1、vim advantage :

a) all Unix Like The system will be built in vi Text editor , Other text editors don't necessarily exist ;
b) Many editing interfaces of software will call on their own initiative vi
c)vi Have the ability of program editing , Can take the initiative to distinguish the correctness of grammar by font color , Convenient programming ;
d) The program is simple and the editing speed is fast .

2、vi The pattern of :

a) General pattern

The general mode is the default mode , You can use the up, down, left and right keys to move the cursor , You can delete characters or entire lines , You can also copy 、 Paste file data .

b) Edit mode

You can delete lines in edit mode 、 Copy 、 Paste, etc . But you can't edit the contents of the file , Need to press “i I o O a A r R” Wait for any letter before entering edit mode , At the bottom of the screen there will be “INSERT” perhaps “REPLACE”, Press “ESC” Key to exit edit mode

 

c) Command mode

In general mode , Press “:”“/”“?” Any one of the three buttons , You can move the cursor to the bottom line , In this mode, the operation of finding data can be provided 、 Read 、 preservation 、 Wait for the order .
Exit save “:wq”
Forced exit “:q!”