I'm currently studying penetration testing and Python programming. I just want to know how I would go about executing a Linux command in Python. The commands I want to execute are:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080
If I just use print
in Python and run it in the terminal will it do the same as executing it as if you was typing it yourself and pressing Enter?
bash
was a bloated shell... – mikeserv yesterdayos.system
recommend using thesubprocess
module. – jordanm yesterday