3

I recently saw an article on the internet. Using that by typing the first letter and pressing would show me the command starting with that letter.
For example let this be my command history:

sudo -s
ls
nautilus

Now if I type s and press would show me

sudo -s

How can I acheive this?

M.Tarun
  • 4,981
  • 6
  • 33
  • 64
  • 1
    Type `history` in Terminal. All command history are stored in `~/.bash_history` file – αғsнιη Jun 29 '14 at 08:40
  • That doesn't answer my question. – M.Tarun Jun 29 '14 at 08:46
  • 2
    possible duplicate of [Bash history search, partial + up-arrow](http://askubuntu.com/questions/59846/bash-history-search-partial-up-arrow) – TuKsn Jun 29 '14 at 08:53
  • Your question is _How to see command history?_ and my answer is current for your question. change your question title first. – αғsнιη Jun 29 '14 at 16:15
  • I able not able to figure out an appropriate one. Will you help me in figuring out a title for this quesion? – M.Tarun Jun 29 '14 at 16:18
  • The title is the first thing potential answerers will see, and if your title is clear [_like yours_], they won't read the rest – αғsнιη Jun 30 '14 at 04:47

1 Answers1

2

Two more useful things to know about this...

To execute a specific command from your history, you can just type an exclamation point followed by the number of the command as listed by history. So, to re-execute command number 510.

!510

To rerun your previous command just type two exclamation points. So when you run a command that needs super-user privileges and you forgot to do that - just give it the old “sudo bang bang” treatment:

sudo !!
snori74
  • 81
  • 4