import subprocess
#WE USE SUBPROCESS LIBRARY IN PYTHON TO RUN SOME LINUX AND SHELL COMMANDS
#FOR EXAMPLE.
#LET'S CREATE AN ECHO COMMAND USING PYTHON SUBPROCESS LIBRARY.
subprocess.run("echo Hello World", shell=True)
#OUTPUT:
#Hello World
#TO LIST FILES IN A CURRENT DIRECTORY
subprocess.run("ls -la"), shell=True)
#OUTPUT: WILL LIST FILES IN THE CURRENT DIRECTORY.
#WITH SUBPROCESS THERE IS NO LIMIT ON HOW YOU INTERACT WITH THE SHELL USING PYTHON
#AS A GATEWAY.
import subprocess
p = subprocess.Popen(['ls','-al'], stdout=subprocess.PIPE)
res = p.stdout.read()
print (res)
pip install subprocess