Archive for the ‘SPR720A’ Category

Numbers Game in Python – Lab I

November 20, 2008

It was cool to handle with python deeper than the famous “Hello World”. I am still getting adapted with the new language, but its looks like not to be hard; No variables declarations, no brackets, no square brackets, just indent.

This is the code of my python game:


import random

print ‘###########################’
print ‘#           Welcome to guess a number game….. 🙂              #’
print ‘###########################’
print ‘Game Instructions: Your goal is to guess the secret number. ‘
print ‘to play type a number between 1 and 100 and the computer is going to ‘
print ‘say if you have to type a greater number or lower number\n’
print ‘PS: your have a maximum of 10 atempts to guess the number\n’

while True:
#Test the limit of the number of tryes
if number_tryes > 10:

#Test if the value entered is a number
guess=int(raw_input(“Enter a guess: “))
print ‘You have to type only numbers’
#Test if the number is in the range
if not 0 <= guess <= 100:
print ‘You have to type a numbe between 1 and 100’

if guess<secret:
print “Too low!”
elif guess>secret:
print “Too high!”
print “Correct!\n”
print ‘You typed’, number_tryes , ‘times to guess the magic number’
print ‘###########################’

Func RPM Verification Module – Release 0.1

November 3, 2008

Official Project Page:

Proposal of project:

Create a Func module that allows the system administrator to audit the integrity of all the rpms installed in all systems.

Verifying the Integrity of the Current System

The integrity of the rpms of the local system can be verified by the command:
# rpm –verify -a

–verify – verify the package
-a – option for all packages

A presentation of the purposed project is available:



Email to Func Mail List:

I sent a email to the Func Project mail list to telling about my intention of making the verification module

Hi my name is Milton Paiva, I am student of the Post-Graduate (Graduate
Certificate) Course - Linux and Unix System Administration from the
Seneca College and I just beginning to work in module for Func.

I intend to make a module able to execute the command "rpm --verify -a"
 to verify the integrity of all the packages on a given system.

I saw the module rpm inventory and I am thinking in make this module to
work in the same way as inventory, but instead of get all the rpms
installed in the system, I will verify the integrity of all the rpms
already installed in the system.

Func-list mailing list





Creating a RPM package for Clam Antivirus – FC9

October 5, 2008
#useradd clamav
#yum install rpmdevtools
#su - clamav

The following directory structure will be created:

     /   /      |    \      \

Create a spec file in the folder ~/rpmbuild/SPECS/clam.spec. After that use rpmlint to check the spec file.

$rpmlint clam.spec

To create a src package
$rpmbuild -bs clam.spec

To create a binary file
$rpmbuild -ba clam.spec

Now if it was successful you will have a binary rpm or src.rpm in the directory:

The packages are available in the following addresses:


SPR720 – LAB4

September 29, 2008

Installing a software from the source.

I choose the Clam AntiVirus to compile from the source. Clam AntiVirus is an open source (GPL) anti-virus toolkit for UNIX.

To compile the Clam I just needed gcc, ./configure; make; make install and that’s it.

About Clam AntiVirus –


Clam AntiVirus is an open source (GPL) anti-virus toolkit for UNIX, designed especially for e-mail scanning on mail gateways. It provides a number of utilities including a flexible and scalable multi-threaded daemon, a command line scanner and advanced tool for automatic database updates. The core of the package is an anti-virus engine available in a form of shared library.

Here is a list of the main features:

  • command-line scanner
  • fast, multi-threaded daemon with support for on-access scanning
  • milter interface for sendmail
  • advanced database updater with support for scripted updates and digital signatures
  • virus scanner C library
  • on-access scanning (Linux® and FreeBSD®)
  • virus database updated multiple times per day (see home page for total number of signatures)
  • built-in support for various archive formats, including Zip, RAR, Tar, Gzip, Bzip2, OLE2, Cabinet, CHM, BinHex, SIS and others
  • built-in support for almost all mail file formats
  • built-in support for ELF executables and Portable Executable files compressed with UPX, FSG, Petite, NsPack, wwpack32, MEW, Upack and obfuscated with SUE, Y0da Cryptor and others
  • built-in support for popular document formats including MS Office and MacOffice files, HTML, RTF and PDF

SPR720 – Lab 3

September 25, 2008

Ufa this lab was really hard, so many time that I do not use the commands sed, awk, etc…..

After some hours reading a book about shell scripting, IBM material about sed and awk I could finish my lab.

The idea is monitor the partitions of the system and if a partition usage hits 80%, print a warning message.

In a environment with lots of servers is impossible to memorize every partition in each server, and a good tool to keep monitoring the available space on the server is Nagios with the plugin NRPE – Nagios Remote Plugin Executer.

Here is my little script:

SPR720 – Command Lab

September 8, 2008

1. Go through the files in /usr/bin and for each file, note whether it’s a command you have used. Select 25 of the commands you haven’t used and research what they do (use manpages and online resources). Blog about your experience and what you’ve found.

List of commands that I have never used:

Source: Linux manpages

a2p – Awk to Perl translator
A2p takes an awk script specified on the command line (or from standard input) and produces a comparable perl script on the standard output.

ab – Apache HTTP server benchmarking tool
ab  is  a  tool  for  benchmarking  your  Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs.  This  especially shows you how many requests per second your Apache installation is capable of serving.

ac –  print statistics about users’ connect time
ac prints out a report of connect time (in hours) based on the logins/logouts in the current wtmp file.  A total is also printed out.

bc – An arbitrary precision calculator language
bc  is  a language that supports arbitrary precision numbers with interactive execution of statements.

bzmore, bzless – file perusal filter for crt viewing of bzip2 compressed text

bzgrep, bzfgrep, bzegrep – search possibly bzip2 compressed files for a regular expression

bzcat – decompresses files to stdout

bzip2recover – recovers data from damaged bzip2 files

bzcmp, bzdiff – compare bzip2 compressed files
Bzcmp  and  bzdiff are used to invoke the cmp or the diff program on bzip2 compressed files.  All options specified are passed directly to cmp or diff.  If only 1  file  is  specified, then  the files  compared  are  file1 and an uncompressed file1.bz2. If two files are specified, then they are uncompressed if necessary and fed to cmp or diff.  The exit status from cmp or diff  is  preserved.

cd-info – List informations about the medias in the cd/dvd drive

cd-drive – List informations about the physical drive

comm – compare two sorted files line by line
Compare sorted files FILE1 and FILE2 line by line. With  no option, produce three-column output.  Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files.

cmp – compare two files
The cmp utility compares two files of any type and writes the results to the standard output.  By default, cmp is silent if the files are the same; if they differ, the byte and line number at which the first difference occurred is reported.

createuser – define a new PostgreSQL user account
createuser  creates a new PostgreSQL user (or more precisely, a role).  Only superusers and users with CREATEROLE privilege can create new users, so createuser must be invoked by someone who  can connect as a superuser or a user with CREATEROLE privilege.

createrepo – Create repomd (xml-rpm-metadata) repository
createrepo  is  a program that creates a repomd (xml-based rpm metadata) repository from a set of rpms.

ddate – converts Gregorian dates to Discordian dates
ddate prints the date in Discordian date format. If  called with no arguments, ddate will get the current system date, convert this to the Discordian date format and print this on the standard output. Alternatively, a Gregorian  date  may  be specified on the command line, in the form of a numerical day, month and year.

file – determine the file type

id – print user identity
Print information for USERNAME, or the current user

isosize – outputs the length of a iso9660 file system
This  command  outputs the length of an iso9660 file system that is contained in given file. That file may be a normal file or a block device (e.g. /dev/hdd or /dev/sr0). In the  absence  of  any switches (or errors) it will output the size of the iso9660 file system in bytes. This can now be a large number (> > 4 GB).

locale – Get locale-specific information.
The locale program writes information about the current locale environment, or all locales, to standard output. When invoked without arguments, locale summarizes the current locale environment for each locale category defined by the LC_* environment variables.

last, lastb – show listing of last logged in users
Last  searches  back  through  the file /var/log/wtmp (or the file designated by the -f flag) and displays a list of all users logged in (and out) since that file was created.  Names of users and tty’s  can  be  given,  in  which  case last will show only those entries matching the arguments. Names of ttys can be abbreviated, thus last 0 is the same as last tty0.

lndir – create a shadow directory of symbolic links to another directory tree
The  lndir  program makes a shadow copy todir of a directory tree fromdir, except that the shadow is not populated with real files but instead with symbolic links pointing at the  real  files  in the  fromdir  directory  tree.   This is usually useful for maintaining source code for different machine architectures.  You create a shadow directory containing links to the real source,  which you  will  have usually mounted from a remote machine.  You can build in the shadow tree, and the object files will be in the shadow directory, while the source files in the shadow directory  are just symlinks to the real files.

look – display lines beginning with a given string
The look utility displays any lines in file which contain string as a prefix.  As look performs a binary search, the lines in file must be sorted (where sort(1) got the same options -d and/or -f that look is invoked with).

lua – lua compiler

lsdvd – read the content info of a DVD

An application  for reading the contents of a DVD and printing the contents to your terminal and dump for further processing in external applications.

nc – arbitrary TCP and UDP connections and listens

The nc (or netcat) utility is used for just about anything under the sun involving TCP or UDP.  It can open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, do port scanning, and deal with both IPv4 and IPv6.  Unlike telnet(1), nc scripts nicely, and separates error messages onto standard error instead of sending them to standard output, as telnet(1) does with some.

nsupdate – Dynamic DNS update utility
nsupdate is used to submit Dynamic DNS Update requests as defined in RFC2136 to a name server. This allows resource records to be added or removed from a zone without manually editing the zone file. A single update request can contain requests to add or remove more than one resource record.

ntfsfix – fix common errors and force Windows to check NTFS

ntfsfix  is  a  utility  that fixes some common NTFS problems.

ntfscmp – compare two NTFS filesystems and tell the differences

After finish the research in the folder /usr/bin I realize that there are a lot of tools, some times not so popular, that can help a lot in the administration and problem solving on Linux Servers.