In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Basic characteristics of Linux Bash
1. History (command history)
1. Syntax and common parameters
History
Lists all history of the current shell
History [- c]
Clear all history of the current shell
History [n]
N is a number that lists the most recent n records
History [- raw] histfiles
-a [HISTFILES]: manually append the command history of the current session buffer to the file. If histfiles does not exist in advance, it will be created. If no histfiles file is specified, it will be written to ~ / .bash _ history by default.
-r HISTFILES: reads the contents of histfiles into the history of the current shell
-w HISTFILES: writes the history of the current shell to the histfiles file
2. Environmental variables
HISTSIZE: number of command history entries. Default is 1000.
HISTFILE:~/.bash_history
HISTFILESIZE: the number of entries recorded in the command history file
[root@Nginx ~] # echo $HISTFILE/root/.bash_ license [root @ Nginx ~] # echo $HISTSIZE1000 [root@Nginx ~] # echo $HISTFILESIZE1000
3. Call history
! #: repeated execution of Article # command
!! Execute the previous command
! String: executes the most recent command containing the specified string
! $: call the last parameter of the previous command
[root@Nginx ~] # history 10 1019 history-a 11.txt 1020 cat 11.txt 1021 echo $HISTSIZE 1022 ls 1023 echo $HISTFILESIZE 1024 history 1025 ping baidu.com 1026alias 1027 ls 1028 history 10 blocks # [root@Nginx] #! 1026aliasalias cdnet='cd / etc/sysconfig/network-scripts'alias cp='cp-i'alias l.='ls-d. *-color=auto'alias ll='ls-l-color=auto'alias ls='ls-color=auto'alias mv='mv-i'alias Rm='rm-i'alias which='alias | / usr/bin/which-- tty-only-- read-alias-- show-dot-- Showslink tildeboat i'alias rm='rm! [root@Nginx ~] #! aliasalias cdnet='cd / etc/sysconfig/network-scripts'alias cp='cp-i'alias l.='ls-d. *-- color=auto'alias ll='ls-l-- color=auto'alias ls='ls-- color=auto'alias mv='mv-i'alias rm='rm- I'alias which='alias | / usr/bin/which-- tty-only-- read-alias-- show-dot-- Showable tilt tilting rooms displaying string [root@Nginx ~] #! pingping baidu.comPING baidu.com (111.13.101.208) 56 (84) bytes of data.64 bytes from 111.13.101.208: icmp_seq=1 ttl=128 time=66.8 ms64 bytes from 111.13.101.208: icmp_seq=2 ttl=128 time=66.9 ms64 bytes from 111.13.101.208 : icmp_seq=3 ttl=128 time=66.9 ms64 bytes from 111.13.101.208: icmp_seq=4 ttl=128 time=67.4 Ms ^ C-baidu.com ping statistics-4 packets transmitted 4 received, 0% packet loss, time 7408msrtt min/avg/max/mdev = 66.844 packets transmitted 67.480 packets transmitted 67.480 Universe $[root@Nginx ~] # ping-c 1! $ping-c 1 baidu.comPING baidu.com (111.13.101.208) 56 (84) bytes of data.64 bytes from 111.13.101.208: icmp_seq=1 ttl=128 time=67.4 ms--- baidu.com ping statistics-1 received, 0% packet loss Time 4071msrtt min/avg/max/mdev = 67.433 ms
4. How to record the history of control commands
Environment variable: HISTCONTROL
Ignoredups: ignore duplicate commands, consecutive and identical commands
Ignorespace: ignore all commands that start with whitespace
Ignoreboth: both of the above articles are effective.
Modify the environment variable:
[root@Nginx ~] # export HISTCONTROL=ignoreboth [root@Nginx ~] # echo $HISTCONTROLignoreboth
Command and path completion
1. Command completion
Bash executes the command and Tab completes directly when the string given by the user has only a unique corresponding command; if it is not unique, Tab will give a list of matching commands again. Bash looks for a command that uniquely matches a string from left to right according to the path defined in the PATH variable. The command to be executed is found for the first time.
2. Path completion
Take the string given by the user as the beginning of the path, and search the specified parent directory for the file name that begins with the specified string. If it is unique, complete it directly; otherwise, Tab again and give the list.
III. Command line expansion
~: expand to the user's home directory
~ USERNAME: expand to the home directory of the specified user
{}: you can host a comma-separated list and expand it into multiple paths
[root@Nginx] # mkdir-pv / tmp/ {1 {1.1, 2}, 2} / {a B} mkdir: created directory "/ tmp/11.1" mkdir: created directory "/ tmp/11.1/a" mkdir: created directory "/ tmp/11.1/b" mkdir: created directory "/ tmp/11.2" mkdir: created directory "/ tmp/11.2/a" mkdir: created directory "/ tmp/11.2/b" mkdir: created directory "/ tmp/2" mkdir: created directory "/ tmp/2/a" mkdir: created directory "/ tmp/2/b"
Fourth, the execution status result of the command
There are two kinds of results in program execution: one is the return value, and the other is the execution status result.
Bash's characteristic scalar $?, which saves the execution status result of the most recent command.
0: successful
1-255: failed
[root@Nginx ~] # CST [root@Nginx ~] # echo $? 0 [root@Nginx ~] # data-bash: data: command not found [root@Nginx ~] # echo $? 17:39:35 on Sunday, July 9, date2017
5. Alias (command alias)
1. Syntax and common parameters
Alias [- p] [name [= value]...]-p: print the set command alias
Alias: displays all available command aliases for the current shell process
Alias NAME='VALUE': defines an alias NAME, which is equivalent to executing VALUE.
Note: there are spaces in VALUE with quotation marks.
2. Alias configuration
(1) the alias defined on the command line is useful only for the current shell
(2) the definition is valid for the current user in ~ / .bashrc
(3) the definition is valid for all users in / etc/bashrc
(4) after the configuration is completed, rereading the configuration file will take effect immediately.
Source / etc/bashrc
3. Unalias (revoke the alias)
Unalias [- a] name [name.]-a: undo all aliases Note: if the alias is the same as the name of the original command, use "\ COMMAND" if you want to execute the original command:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.