Python Running from Command line

To run Python on Unbutu Command line

run command
$ python2.7
$ python3.5
or simply
$ python

Note: The last one (python) command will start the default version…
You will see below screen
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
Enter Python Code directly
>>> print (“Write on Console”)
Write on Console

Running Python file from command line
Enter command
$ python2.7
$ python3.5
or simpy
$ python

To get argument from command line
Enter command
$ python arg1, arg2, arg3

and your code in file should look like;

import sys
print (sys.argv)
file_name = sys.argv[0]
num1 = int(sys.argv[1])
num2 = int(sys.argv[2])
sum = num1 + num2
print (str(num1) + " + " + str(num2) + " = " + str(sum))

Note: the first argument will always be the name of a file, to get arguments other than file, use >> sys.agrv[1:]
Note: All argument are sent as of string data type.

Arguments Handling

import sys
print ("All Args: " + str(sys.argv))
print ("File Name: " + sys.argv[0])
print ("Other Args: " + str(sys.argv[1:]))

Firewall Settings

To check the current status of firewall
sudo ufw status

To Disable the firewall
sudo ufw disable

To Enable the firewall
sudo ufw enable