#! /usr/bin/env python
import sys
    import cgitb # NOTE Indentation
    cgitb.enable() # ENABLE CGI
except ImportError:
    sys.stderr = sys.stdout
    import MySQLdb
except ImportError:
    sys.stderr = sys.stdout

# NOTE, Python is really strict about indenting all
# the function definitions, otherwise it will stop.
# Function for CGI Printing
def cgiprint(inline=''):
# End of Function Definition

# Function to Establish a connection and print out Rows
# Assume Database has two columns of information.
def PrintDataBase( hostname, username, passwd, databasename, querystring ):
       conn = MySQLdb.Connect( hostname, username, passwd, databasename)

# Run a MySQL query from Python and get the result set
       c = conn.cursor()
       records = c.fetchall()
       print '
' # block it to make it pretty and sweet. for row in records: print "
" print row[0] print "

" print row[1] print "

" conn.close() #close the data base #NOTE , the last statement must NOT be indented. # This way everything will be closed when we are done looping through # ALL THE ENTRIES. print '
' # End of blockquote to make it pretty and sweet. # End of Function Definition # Print the page title and heading first contentheader = 'Content-Type: text/html' thepage = ''' %s %s ''' h1 = '


' if __name__ == '__main__': cgiprint(contentheader) # content header cgiprint() # finish headers with blank line title = 'Display Linux Commands using Python' headline = h1 % 'Display Linux Commands using Python' print thepage % (title, headline) # NOW print the first paragraph .... print '''

There are hundreds of Linux commmand line commands out there. Here I will attempt to give you the most important basic ones. These commands can be typed at any terminal prompt . Note, many of them require you first be logged in as root (su) before you can issue them. I have placed them in alphabetical order using a MySql database. Please let me know, if you feel I have left out your favorite most used command, by clicking here.

Note, if you are familiar already with Linux or UNIX commands and want a good source for comparing the same command on various platforms (Linux, Solaris, HP-UX, MAC OSX, etc.), please go to the rosetta stone.

''' # END of first Paragraph # print "

Abbreviated List of Linux Commands

" #Call Function to Print out Data Base initializing Querystring a_query = "SELECT Name_of_the_command, Text_of_the_command FROM The_Database_table ORDER BY Name_of_the_command ASC" PrintDataBase("a_host", "a_user", "a_password", "a_database", a_query ) print ' Return to entry page. ' print