Try using a Python tool maybe that allows you to see what happens when you execute a command.
It seems that you can check in advance about file operations such as file creation, deletion, movement, permission change by command execution
** Precautions **
That being said, maybe should :warning: NEVER :warning: be used to run untrusted code on a system you care about!
A process running under maybe can still do serious damage to your system because only a handful of syscalls are blocked.
Currently, maybe is best thought of as an (alpha-quality) "what exactly will this command I typed myself do?" tool.
Install with pip
# pip install maybe
Just add maybe
before executing the command
$ maybe COMMAND [ARGUMENT]...
$ ls
file1 file2 file3
** Delete file **
$ maybe rm -f ./*
maybe has prevented rm -f ./file1 ./file2 ./file3 from performing 3 file system operations:
delete /home/*******/test/file1
delete /home/*******/test/file2
delete /home/*******/test/file3
Do you want to rerun rm -f ./file1 ./file2 ./file3 and permit these operations? [y/N] y
$
Asks if you really want to do it
** Add directory / file **
$ maybe mkdir test ;maybe touch test/file1
maybe has prevented mkdir test from performing 1 file system operations:
create directory /home/*******/test/test
Do you want to rerun mkdir test and permit these operations? [y/N] y
maybe has prevented touch test/file1 from performing 1 file system operations:
create file /home/*******/test/test/file1
Do you want to rerun touch test/file1 and permit these operations? [y/N] y
** Starting a daemon **
# maybe /etc/init.d/docker start
Starting docker:
maybe has prevented /etc/init.d/docker start from performing 26 file system operations:
write 33 bytes to /var/log/docker
create file /root/nohup.out
write 7 bytes to /var/log/docker
write 35 bytes to /var/log/docker
write 1 bytes to /var/log/docker
create file /var/run/docker.pid
write 4 bytes to /var/run/docker.pid
write 91 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 5 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 7 bytes to /root/nohup.out
write 6 bytes to /root/nohup.out
write 7 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
write 1 bytes to /root/nohup.out
Do you want to rerun /etc/init.d/docker start and permit these operations? [y/N]
Recommended Posts