/** 5.4 Shell Basics (bash) */
1.bash Introduction
2.bash command
Format: [Shell commands] [options] [parameters]
Example: [[email protected] ~]#
Root: User identity
Server: Host Name
~: Where the file is located
#: Prompt
Only root (super user) prompt is #
The user's prompt for other identities is $
Example 2:[[email protected] ~]# ls-l/root
LS: Displays the contents of the directory;-l: long list table; root is the parameter
3. Common Control key combinations
Ctrl+d: Enter end or log off current user identity
"Add new user identity: [[email protected] ~]# useradd user name (USE1)
"Toggle New user identity: [[email protected] ~]$ Su-user name (USE1)
"Log off the new user identity: [[email protected] ~]$ logout or direct ctrl+d
CTRL + C: Terminate command (that is, the command terminates the run)
Ctrl+l: Clear Screen
4. Common cursor operation
CTRL + A: Move the cursor to the beginning of the command
Ctrl+e: Move cursor to end of command line
5. Special characters
~: Household Directory
$: Variable Value
|: Piping
&: Background process work
<: Input redirection
: Output redirection
>>: Append redirect
/: Path delimiter
;: Command delimiter
6. Wildcard characters
?: Represents any single character (a?: Only the first bit is a, after?) Represents only one arbitrary character)
*: Represents any character (A *: As long as the first bit is a, the back is any one or more characters are OK)
[Character combination]: characters in brackets match
[! Character combination]: characters that are not in brackets match
/** 5.5 Shell Use function */
1. Command line Auto-complete
1>. command name (file name) The first letter +tab key, you can complete the command name (file name)
If you have a command name (file name) that repeats the first letter, you can press the TAB key 2 times to find the desired command name (file name)
2> To complement a path (always press the TAB key)
3>. To the variable itself, "variable prefix is uppercase"
2. Historical command record
Files that begin with • are hidden files
[Email protected] ~]# echo $HISTFILE
3. Command arrangement
4. Command replacement
5. Command aliases
Example: Creating an ls-l/boot alias as OK
[[email protected] ~]# alias ok= ' Ls-l/boot '
View Ls-l/boot
[[Email protected] ~]# OK
Cancel Alias
[Roo[email protected] ~]# unalias OK
/**5.6 Redirect (important) */
0 Keyboard stdin (standard input)
1 screen stdout (standard output)
2 screen stderr (Error output)
Example 1:[[email protected] ~]# cat "cat" connect standard input to standard output "
Aaas
Aaas
Asd
Asd
Qwe
Qwe
[[Email protected] ~]# "ctrl+d" End command
1. Output redirect//Command syntax: [command] >[file]
Example 2: Full redirect output for the following table 1 in Root/test.log
[[email protected] ~]# ls 1>/root/test.log
Output AAA to/root/test.log
[Email protected] ~]# echo Aaa>/root/test.log
Show content in Root/test.log
[Email protected] ~]# Cat/root/test.log
Aaa
2. Error output redirection
Example 3:[[email protected] ~]# ls asdf 1>/root/test.log 2>root/test.log
= [[email protected] ~]# ls asdf 1>/root/test.log 2>&1
= [[email protected] ~]# ls asdf &>/root/test.log
3. Standard input
[email protected] ~]# cat </ETC/PASSWD
=[[email protected] ~]# cat/etc/passwd
[[email protected] ~]# cat >/root/test.log <<eof "<<eof: can replace ctrl+d end command"
7. Pipeline (important)//Command syntax: [Command 1]| [Command 2]| [Command 3]
[[email protected] ~]# Ps-ef/root/test.log View information for all current processes
[[email protected] ~]# grep ' keyword '/root/test.log retrieve all information containing this keyword
[[email protected] ~]# Rpm-qa/root/test.log Query System installation package for all installed software
[[email protected] ~]# Sort/root/test.log alphabetical order
[[email protected] ~]# Wc/root/test.log print line break (-L) for each file, number of characters W and number of bytes C
Example: Abc.log ACV SSDDG CA wc-l 4
FFF D wc-w 7
Qwewc-c 18
G
/**5.7 remote connection to the Linux system */
1. Server-side: SSH protocol
[[Email protected] ~]# service sshd status
Service (Management background service) status (status) [Start open/stop off]
[Email protected] ~]# NETSTAT-TLNP | grep 22
Netstat (view the network status of the current host) TLNP (t: only see tcp;l: Listening status; N: port number displayed numerically; p: Process information)
grep (the port number of SSH is 22)
Vncserver
/** Seventh directory and document management */
1. File types in Linux systems are not differentiated by suffixes
Linux file types Common: Normal file directory file device files (character device files and block device files) pipeline files and symbolic link files
"-rw-r--r" the first symbol of its property is '-', such a file is a normal file
"Drawxr-xr-xr-x" whose property the first symbol is ' d ', so that the file is a directory file
The first sign of its property is ' B ', so the file is a block device file
The first sign of its property is ' C ', so the file is a character device file
The first sign of its property is ' P ', so the file is a pipe file
First-out, also known as FIFO file
The first sign of its property is ' l ', so the file is a soft connection file (symbolic link file)
echo Displays the string on the terminal
Linux system basics with the Tang notes 2