You need to use the history command to display or manipulate the history list on a Linux or Unix-like systems. This command displays the list of commands previously typed with line numbers, prefixing each modified entry with a *.
Display list of previously typed commands
Simply type the following command:
history history 10 history | less history | grep 'command-name-here'
How do I reissue a long command without retyping it?
To reissue a command in bash/csh/tcsh/zsh shell, type ! the exclamation point followed by the number of the command you would like to run or repeat. For example, if you would like to reissue command ‘ssh firstname.lastname@example.org’ from the above output i.e. command # 80, type:
Scrolling through the command line history
You can also scroll through the command line history simply by using the [up] and [down] arrow keys too.
Searching the command line history
Press [CTRL-r] from the shell prompt to search backwards through history buffer or file for a command. After pressing [CTRL-r] just type first few command letter such as ssh:
(reverse-i-search)`ssh ': ssh -X vivek@nas01
To search all ssh related commands press [CTRL-r] again:
To repeat last command just type !! at a shell prompt
Say you type a long command:
ssh -X -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /Users/veryv/.ssh/google_compute_engine -A -p 22 email@example.com --
To repeat the same last command again, just type !!:
Or you can also refer to the previous command using:
To repeat to the most recent command starting with word ‘ssh’ type:
For more info see man pages – tcsh(1)
|Category||List of Unix and Linux commands|
|Firewall||CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Network Utilities||dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|