The second class studied some instructions.
Basic command:
Command Format NOTE:
1. Multiple options, as well as multi-parameter and command using white space character segmentation
2. Cancel and End command execution: ctrl+c,ctrl+d
3. Multiple commands can be used; separate symbols
4. A command can be divided into multiple lines with a \
hostname: Displays and sets the host name of the system
Syntax: hostname option parameter
Options:
-V: Show more information
-A: Display host aliases
-D: Display DNS domain names
-F: Display FQDN name
-I: Display host IP
-S: Displays the short host name, truncated at the first point
-Y: Display NIS domain name
Init 3: Turn off the graphical interface
Init 5: Start graphical interface (image interface mode toggle)
startx: Start graphical interface (equivalent to running graphical interface software on the system)
Init 0: Shutting down the machine
chvt#: Switching between interfaces
PS: After many practice, found in the graphical interface of the ordinary account using CHVT switch to the command line interface will be error, prompted to find a file descriptor refers to the console, but the root user can successfully switch, temporarily did not find the reason, the follow-up found again!!!
lsb_release: LSB is the abbreviation for Linux Standard base, Sb_release is used to display the LSB and specific version of the relevant information
There is no CentOS7 on this command
Free: Displays the number of unused and used memory in the current system, and also shows the memory buffers used by the kernel
Options:
-B: Display memory usage in bytes
-K: in kilobytes (KB) ..... .....
-M: in megabytes
-V: Display version information
-T: Show memory sum column
DF: Displays the amount of disk space available on the partition, by default, in kilobytes. You can use this command to get how much space the hard disk is taking up, and how much space is left.
Options:
-A or--all: contains all file systems
--block-size=< Chunk Size: Displays the number of chunks in the specified chunk size
-H or--human-readable: Display information in a more readable way
-I or--inodes: displays inode information
-K or--kilobytes: Specifies a chunk size of 1024 bytes
-L or--local: Show only the local file system
-T file system or--type file system: Displays only disk information for the specified file system type
-T or--print-type: Displays the type of file system
-X File system or--exclude-type file system: Do not display disk information for the specified file system type
--version: Display version information
lscpu: Viewing CPU information
ifconfig: Displays network parameters for network interfaces in the Linux kernel
ID: can display the actual valid user ID (UID) and group ID (GID)
Grammar:
ID Option User Name
Options:
-G or--group: Displays the ID of the group to which the user belongs
-G or--groups: Displays the additional group ID that the user belongs to
-N or--name: Displays the name of the user, group or additional group to which they belong
-R or--real: show actual ID
-U or--user: Show user ID
Shell
command>>shell>> binary
The shell acts like a translator, converts the command into a computer-readable binary format, and then executes the command
PS1: Defining a prompt
Defined as follows
echo $PS 1
Ps1=qiuwei
Prompt changed to Qiuwei
Date: Displays and sets the system time and date
Parameters:
+ Time Date format:
%H hours, 24-hour system
%I Hours, 12-hour system
%M min
%s Display seconds
%s from January 1, 1970 00:00:00 to now experience the number of seconds
%T: Display time, 24 hours (HH:MM:SS)
%A: Show week abbreviation
%A: Show full day of the week
%c: Date and time
[Email protected] ~]# date +%c
Sat 05:09:59 PM CST
%F:
[Email protected] ~]# date +%f
2016-07-23
Time setting:
Date-s "2016-7-23 09:49:30"
date:072214442016.30
Day of the month and year. seconds
The default is 0 seconds when no more seconds are added
-D String: Displays the time date that the string refers to, and the string must be preceded by a double quotation mark
Date-d "+10 Day" +%f 10 days later
Date-d " -10 Day" +%f 10 days ago
Date-d "Ten day Ago" +%f 10 days ago
Date-d "+1 Year" +%f
Date-d "+1 Month" +%f after January
clock and Hwclock: Display and set hardware time as expected
Hwclock-w changing hardware time to System time
Hwclock-s changing the system time to hardware time
Screen command: Pop-up is a window manager or proxy that can multiplex a physical terminal between multiple processes
Common parameters:
Screen-s Help: Create a new session called Help
Screen-ls: To sort out all current sessions
Screen-x help: Added to the conversation called Help
The above requires three instructions with the use of
In order to facilitate their own understanding of memory, in the text described under
If a has difficulty in need of B help, B can be remote login to a terminal, using the screen command to realize the display sharing, and Operation synchronization
, the steps are as follows:
First, A and B are connected to the same terminal, a executes the command Screen-s help, can establish a shared screen session called "Helps", b by performing Screen-ls to see Help, then B executes the command screen-x helps, you can connect to a established "" Shared screen sessions for screen sharing, operation sharing
Disconnect shared session: Ctrl+a+d (press keyboard, not input character)
Reconnect disconnected session: Screen-x Help or Screen-x session number (process number?) )
Exit: Exit Session
Ctrl+a+s: Lock session, after locking, any input screen will not react, but although the screen does not see the reaction, in fact, the input of the command content is received in the process,
Ctrl+a+q: With the use of the previous instruction, unlock the session, the above lock when the input command content will be re-appear
Ctrl+a+x: Locked session, the difference is locked, the session by the screen belongs to the user's password protection, you need to enter a password to continue to access this session
Session Separation and Recovery:
You can temporarily disconnect a screen session without interrupting the program in the Windows window, then reconnect the session and re-control the program running in that window
For example:
Executes the screen command. A session is created and a Yes command is executed inside, and the session screen continues to output y
In screen type ctrl+a+d, temporarily exit the session,
After a while, Screen-x Pts-2 reconnect the session and find that yes is still executing, and the screen continues to output y
Installing Screen:yum Install screen
Or find the installation package installed directly in the image
Hash: Can view the used external commands, slow the presence of in-memory
hash-d Yes: Clears the Yes command from the cache
Hash-r: Clears all commands in the cache
General commands are divided into two types: internal and external commands
type: To see if the command is internal or external command
Type cd type ls
The mechanism by which the system executes external commands:
In general, after the command input, the system will be found in the following path, will take precedence of the first matching to the command
/usr/lcoal/sbin
/usr/lcoal/bin
/sbin
/bin
/usr/bin
/usr/bin
/root/bin
To view the external command path:
Echo $PATH
System execution Command Order (priority):
Internal command > External Command cache > External command path
External command caching is performed only after the outer command is executed, and external command caching is performed if the external command persists
Popular: If the Yes command in/bin, after executing this command, will generate a cache, if you want to execute the Yes command, the system will take precedence of the cache is yes, but if you delete the/bin Yes command, and then execute the Yes command, although the cache has recorded yes, but the command is not executed successfully, Because the path/bin in the cache has no yes, I understand that the cache is just the Yes shortcut,/bin is the actual content under the Yes, so the/bin under the Yes is gone, the cache of Yes can not be executed
In addition: External command lookup is left-to-right, preference is given to the first match to the instruction, but there are more than one instruction in a path, there are multiple paths can match, if you do not want to perform the first, you can use the relative path, as follows:
/bin/yes,/sbin/yes
#:/sbin/yes
The above command will directly match/sbin/yes, not/bin/yes
PS: If yes in/test/yes, the current directory is also under/tse, directly run Yes (if the external command default path no Yes command), but also cannot execute successfully, because the system execution External command is the default to the external command path under the search, under/test run Yes directly, The system looks directly at the default external command path, does not look for/test, and wants to do so:
/test/yes, or. Yes
Disable command temporarily: Enable-n CD
Enable command: Enable CD
which: Finds and displays the absolute path of a given command
[email protected] ~]# which PWD
/usr/bin/pwd
Note: Which is to search for a running file based on the directory within the path variable that the user has configured! Therefore, the commands found in different path configuration contents are not the same
alias: Used to define aliases.
Alias Cls=clear defines the CLS as a clear aliases
Unalias CLS Delete alias CLS
Command precedence: aliases > Internal commands > External Command cache > External command path
EHCO command Usage
The echo command displays the value of the shell variable in the shell, or outputs the specified string directly
Syntax: Echo option parameter
Echo:
[Email protected] ~]# echo Hahha
Hahha
Options:
-N: Output text does not wrap
-E: Enable escape character
Cases:
\ n: Line break
[Email protected] ~]# echo "000000\n00"
000000\n00
[Email protected] ~]# echo-e "000000\n00"
000000
00
"\ Letter" means the cursor
With the-e option, the string appears with the following character, which has a special meaning and is not output as a generic character
\a: Issue an alert
\b: Delete previous character >> cursor forward one cell
\c: End without line break >> no wrap, and do not display after cursor
[Email protected] ~]# echo-e "Shabi\chah"
Shabi[[email protected] ~]#
\f: NewLine But the cursor remains in its original position
Shabi[[email protected] ~]# echo-e "Shabi\fhah"
Shabi
Hah
\ n: Wrap and move the cursor to the beginning of the line
[Email protected] ~]# echo-e "Shabi\nhah"
Shabi
Hah
\ r: The cursor moves to the beginning of the line, but does not wrap >> later overwrites the previous
[Email protected] ~]# echo-e "Shabi\rhah"
Hahbi
[Email protected] ~]# echo-e "Shabi\rpingxiong"
Pingxiong
\ t: Insert tab
\v: Same as \f effect
\0NNN: Insert nnn (octal), which represents the ASCII character
\XHH: inserting ASCII characters represented by HH (hexadecimal)
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/84/8D/wKiom1eUYiLAH0fZAAHpuskv8rM235.jpg-wh_500x0-wm_3 -wmp_4-s_3638423892.jpg "title=" qq picture 20160724113756.jpg "alt=" Wkiom1euyilah0fzaahpuskv8rm235.jpg-wh_50 "/>
echo Output Color text:
Example: Echo-e "\033[47;32;5mpingxiongshishabi\033[0m"
Description
The above-e is the command echo option, enabling the escape character, "\033" to boot an unconventional character sequence (that is, "\033[" means the terminal escape character starts, "\033" is the ASCII code that exits the key <ESC>). "M" means to set the property and then end the unconventional character sequence, the real valid character in this example, the above command 47;32;5;0 is the control text color control, the other can be understood as a fixed format
The following options are available:
0 Reset properties to default settings
1 setting Bold
2 Set half brightness (simulates color of color display)
4 Set underline (simulates color of color display)
5 Set blinking
7 Set reverse image
22 Set general density
24 Turn off the underscore
25 turn off blinking
27 Close Reverse image
30 Set Black text
31 Set Red
32 set Green
& nbsp;33 Set Yellow
34 Set Blue color
35 set purple
36 Set Cyan
37 set White (gray)
40 Setting a black background
41 Setting the red background
42 Setting the green background
43 Setting the yellow background
44 Setting the blue background
45 Setting purple Background
46 Setting the Cyan background
47 Set White (gray) background
echo "": Indicates a weak reference
Echo ': Indicates a strong reference
Echo ': Indicates a command reference
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/84/8D/wKiom1eUZsCBqnbLAAAtyo2q4cw155.jpg-wh_500x0-wm_3 -wmp_4-s_1455753799.jpg "title=" echo reference. jpg "alt=" wkiom1euzscbqnblaaatyo2q4cw155.jpg-wh_50 "/>
I understand as follows:
The first "is to direct the force in the" as character reference output
Second ": Reference is the execution result of the command in"
Third "": Echo and $user are referenced separately, the structure is executed
Not fully understood here, follow-up in complement
To view the Help manual:
Whatis
Command--help
Mans
Info
Local Help document/usr/share/doc/
Official online documentation
Other sites and searches
Whatis
Show a short description of the command
Use one database update per night
Cannot be used immediately after installation
Makewhatis or MANDB production database
Whatis command
Man command:
Provide command help manuals
Manual page stored in/usr/share/man
Almost every command has a man page.
The man page is grouped into different chapters
Man Chapter:
User commands
System calls
C Library Call
Equipment files and special documents
Configuration file format
Game
Miscellaneous
Commands for managing classes
Linux Kernel API
Control paging command for man command:
Space Space bar: Page Down
Page UP and PAGE down: means to flip one line up and down one line
Enter enter key: Turn down one line
/word: Search for keywords
Home: Go to the first page
End: Go to the last page
/string: Search Down string
? String: Search up string
N,n: Using/and? Search string Yes, N to continue next search (from top down)
N to search for the previous search (from bottom to top)
Q: End Man
Man has 9 chapters the same command may be in multiple chapters,
Search for specified chapters
Man-# Command (#为章节数)
Info
Common shortcut keys
?: Display common shortcut keys for info
N: Opens the next node associated with this node
P: Opens the previous node associated with this node
U: Opens the previous node associated with this node
I: Back to the last visited node
M or G Select a menu item (node's name) Enter the name of the specified menu and press ENTER to open the node associated with the specified menu item
SPACEBAR next page (PageDown can also, the next page starts from the last two lines of the current page) the next node (if the current page is at the end of the Node document)
Del key Previous page (PageUp can also, the previous page starts at the beginning of the current page) the previous node (if the current page node document start)
The start of the B or T or Home document (b is the meaning of begining)
The end of the E or end document (b is the meaning of ending)
Ctrl-l Refresh the current page if there is a problem with the current document display
Ctrl-g to cancel the command you typed
Histoy:
The basic features of bash:
Command history: Shell daemon saves commands previously executed by the user in its session
directive: History
Histsize:shell the number of commands history that the process can retain
Histfile: A file that persists command history;
. bash_history
Histfilesize: The size of the command history file (number?) )
-C: Clears the command history;
-D Offset: Delete the specified command history
-r: Read command history from file to History list
-W: Append commands from the history list to the history file
History N: Displays the most recent n commands;
To invoke a command in the command history list:
! N: the nth command in history
!! : The most recent command
! String: Executes the most recent command in the command history list that starts with a string
STRING: Letter
Note: Repeated executions of commands sometimes need to depend on idempotent
Call the last parameter of the previous command:
Shortcut key: ESC and then.
String:! $
The way to control the history of a command:
Environment variable: Histcontrol
Ignoredups: Ignore duplicate commands:
Ignorespace: Ignore commands that start with whitespace characters
Ignoreboth: Both of these take effect at the same time
Command completion:
When the shell program receives a request from the user to execute the command, the leftmost string is treated as a command when the parsing is complete;
Command Lookup mechanism:
Find internal commands;
According to the directory set in the PATH environment variable, search the directory from left to right
The given heading string, if it can uniquely identify a command program file, directly complements the
Can not uniquely identify a command program file, then click the TAB key once, will give a list;
Path Completion:
Match each file under the starting path with the starting string under the corresponding path, based on the given start path
Otherwise, tab again, giving the list.
Bash's shortcut keys:
Ctrl+l: Clear screen, equivalent to clear command
CTRL + C: Canceling execution of commands
CTRL + A: Cursor moves to the front of the command line
Ctrl+e: Cursor moves to the last side of the command line
Ctrl+u: Delete the beginning of the line to the cursor
Ctrl+k: Delete End of line to Cursor
The above for the second class to learn the order and some related knowledge, if there are errors, please help point out, hey!!
Linux Notes 2