Linux history commands and command aliases

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.