C
C
calculator2122021-04-09 17:55:57
linux
calculator212, 2021-04-09 17:55:57

Is it possible to somehow intercept commands that are executed through the terminal in ubuntu?

There is a ~/.bash_history file, which stores the history of commands entered into the terminal, is there a way to make such a utility that will receive the text of commands entered into the terminal, for example, to create its own log file.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Mamonov, 2021-04-09
@calculator212

It only stores the history of commands that have been entered into bash.
If you have another shell, you will not see the list of commands in .bash_history.
For example, I may start bash immediately after logging in, but then I will start, for example, zsh.
bash.history will be empty.
This I mean that even if you make your own shell, it can be easily bypassed.
I know at least one real solution that will work.
You make a module for the Linux kernel, there you intercept the exec system call and everything connected with it, and then it will not be very easy to bypass you.
I did something similar for Unix FreeBSD 20 years ago :))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question