Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 677
John Tan Avatar asked Feb 28 '12 17:02

John Tan


People also ask

How do I view a command log?

Open up a terminal window and issue the command cd /var/log. Now issue the command ls and you will see the logs housed within this directory (Figure 1).

How can I see all command history?

Open Start. Search for Command Prompt, and click the top result to open the console. Type the following command to view the command history and press Enter: doskey /history.

How do I view all logs in Linux?

Linux logs will display with the command cd/var/log. Then, you can type ls to see the logs stored under this directory. One of the most important logs to view is the syslog, which logs everything but auth-related messages.


2 Answers

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.

like image 167
Rudi Avatar answered Sep 18 '22 15:09

Rudi


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.

like image 29
ryan Avatar answered Sep 22 '22 15:09

ryan