John Tan
John Tan

Reputation: 539

How to view the log of all commands?

I'm trying to view all commands that I've entered into the unix environment in my Git Bash.

So I'm not trying to view the list of possible commands for Git Hub. Neither am I trying to view the logs for pushes and pulls.

I just want to view what I entered in the command line. This is because I recently encountered a connection problem in which I couldn't push or pull from my git. It just happened suddenly. One minute ago, I was still pushing and pulling perfectly.

Then, someone helped me to resolve it via the command prompt in git bash.

Right now, my friend has the same problem. So I'm looking for the command logs in hopes that it will solve his problem too.

Write failed: Broken pipe fatal: The remote end hung up unexpectedly.

Upvotes: 16

Views: 69435

Answers (4)

DeMo
DeMo

Reputation: 1

history n is the command n is the number of lines to show, i,e history 50 , it will show last 50 commands

Upvotes: 0

R M
R M

Reputation: 570

history 1

This will display all entries in History starting at line 1.

Upvotes: 13

ryan
ryan

Reputation: 889

If you are still in the shell a quick way to see your recent session command history is the command:

$ history

Very handy for the scenario mentioned in the question, i.e. a colleague has typed some commands quickly in your session and you want to go back and have a closer look at them.

Upvotes: 9

Rudi
Rudi

Reputation: 19940

You can do this with cat $HISTFILE.

Bash by default stores the last 500 commands in a history file, most likely called ~/.bash_history. This file is in the variable $HISTFILE (and the size is in $HISTFILESIZE). You can get the path to the history file with echo $HISTFILE.

Upvotes: 28

Related Questions