Im in need of help. New learner to linux, and for school, they want me to create a log file of all the commands I executed for a project. I can't figure it out at all. Please help!
Asked
Active
Viewed 8,457 times
2 Answers
8
Bash keeps a log of commands you've run. You can access the log from the current session with the command:
history
After your session finishes it is written out to the file:
~/.bash_history
thomasrutter
- 37,804
4
Your question is a little unclear whether you are wanting the output as well since “log of all commands” could be interpreted either way.
In that case, you can use script:
script(1) - Linux man page
Name
script - make typescript of terminal session
Synopsis
script [-a] [-c COMMAND] [-f] [-q] [-t] [file]
Description
Script makes a typescript of everything printed on your
terminal. It is useful for students who need a hardcopy record
of an interactive session as proof of an assignment, as the
typescript file can be printed out later with lpr(1).
If the argument file is given, script saves all dialogue in file.
If no file name is given, the typescript is saved in the file
typescript.
This is usually the tool we were asked to use when showing the commands we used on an assignments as it also provides the output, which is sometimes important to the instructor.
rrauenza
- 301