Historical Command--history
history-c Empty History command
History-w The history command in the cache to the history command to save the file, the default file is ~/.bash_history
The history command saves 1000 by default and can be modified in the environment variable configuration file/etc/profile
Call methods for historical commands
1. Use the up and down arrows to invoke the history command
2. Use "!n" to re-execute the nth command
3. Use "!!" Re-execute the previous command
4. Use "!xxx" to re-execute the last command that starts with the string "XXX"
Command alias--alias
1. Customizing an Alias
Alias aliases = "Original Command"
As shown below:
1[[email protected] ~]# alias netstat="NETSTAT-ANPT"//define an alias2[[Email protected] ~]# alias3AliasCP='cp-i'4Alias l.='ls-d. *--color=auto'5Alias Ll='ls-l--color=auto'6Aliasls='ls--color=auto'7AliasMV='mv-i'8Alias netstat='NETSTAT-ANPT' //alias definition success can be viewed using alias9AliasRM='rm-i'TenAliaswhich='alias |/usr/bin/which--tty-only--read-alias--SHOW-DOT--show-tilde' One[[Email protected] ~]# netstat A Active Internet connections (servers and established) -Proto recv-q send-q Local address Foreign address State Pid/Program name -Tcp0 0 0.0.0.0: A 0.0.0.0:* LISTEN2036/sshd theTcp0 0 127.0.0.1:631 0.0.0.0:* LISTEN1926/cupsd
Aliases defined using the command alias are only temporary and fail after a reboot.
If you want to make the alias permanent, you need to write to the configuration file
Vim ~/.BASHRC use vim to edit the current user's. bashrc file, write the alias definition to a file to be permanently active
1 Remove alias2[[Email protected] ~]# Unalias netstat3[[email protected] ~]# alias//View alias Netstat has been deleted4AliasCP='cp-i'5Alias l.='ls-d. *--color=auto'6Alias Ll='ls-l--color=auto'7Aliasls='ls--color=auto'8AliasMV='mv-i'9AliasRM='rm-i'TenAliaswhich='alias |/usr/bin/which--tty-only--read-alias--SHOW-DOT--show-tilde' One A View Current Environment command lookup path -[Email protected] ~]#Echo$PATH -/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Linux history commands and command aliases