quarta-feira, 24 de fevereiro de 2010

Seting up a DHCP server

To quickly install and set up a DHCP server on Linux you need to download the DHCP software from here.
After the download do:
$ tar xzvf dhcp-4.1.1.tar.gz
After extract do:
$ cd dhcp-4.1.1/
$ ./configure
$ make; make install
 Now we have the dhcp server installed so we need to configure that.

The /etc/dhcpd.conf File

When the server starts it reads the dhcpd.conf file. In this file we need to pute the configurations that we wish to our network.

Normally this file is NOT created in installation, but you can:

$ touch /etc/dhcpd.conf

Finally we need to edit the file for our case.
So let's see an example that explains the most important fields. Adapt for your case:
ddns-update-style interim
ignore client-updates
 
subnet 192.168.1.0 netmask 255.255.255.0 {
 
   # The range of IP addresses the server
   # will issue to DHCP enabled PC clients
   # booting up on the network
 
   range 192.168.1.201 192.168.1.220;
 
   # Set the amount of time in seconds that
   # a client may keep the IP address

  default-lease-time 86400;
  max-lease-time 86400;
 
   # Set the default gateway to be used by
   # the PC clients
 
   option routers 192.168.1.1;
   # Don't forward DHCP requests from this
   # NIC interface to any other NIC
   # interfaces
 
   option ip-forwarding off;
 
   # Set the broadcast address and subnet mask
   # to be used by the DHCP clients
 
  option broadcast-address 192.168.1.255;
  option subnet-mask 255.255.255.0;
  
   # Set the NTP server to be used by the
   # DHCP clients

  option ntp-servers 192.168.1.100;

   # Set the DNS server to be used by the
   # DHCP clients

  option domain-name-servers 192.168.1.100;
 
   # If you specify a WINS server for your Windows clients,
   # you need to include the following option in the dhcpd.conf file:

  option netbios-name-servers 192.168.1.100;
 
   # You can also assign specific IP addresses based on the clients'
   # ethernet MAC address as follows (Host's name is "laser-printer":

  host laser-printer {
      hardware ethernet 08:00:2b:4c:59:23;
     fixed-address 192.168.1.222;
   }
}
#
# List an unused interface here
#
subnet 192.168.2.0 netmask 255.255.255.0 {
}
 To see more options:
$ man dhcp-options

So to start our DHCP server:
$ dhcpd start 



segunda-feira, 8 de fevereiro de 2010

Linux Training from Linux Experts - FREE

"A little less than a year ago, the Linux Foundation launched a program to provide a variety of training opportunities for Linux professionals. Just a few months later, the Foundation moved the program online, offering web-based sessions of select courses to reach a wider audience. On Tuesday, they took it one step further, announcing the free — as in beer — Linux Training Webinar Series.
The idea behind the Linux Foundation Training Program was to offer job training that would help fill the continuing demand for Linux professionals. The courses would be taught not by professors or lecturers, but by actual Linux developers, including the Foundation's Technical Advisory Board which boasts names like Ted Ts'o, Jonathan Corbet, Alan Cox, and Chris Wright, among others.
The first courses were held on-site at Linux Foundation events, including the inaugural event at the annual Collaboration Summit, as well as independent sessions in various cities and corporate-sponsored training. With the success of the Collaboration Summit sessions, the Foundation branched out, offering the same classes taught by the same faculty, but in a Virtual Classroom setting. The courses — which the Foundation will continue to offer — last from two to five days, and run anywhere from $1,200 (for two days) to $2,750 (for five days).
The new classes, designated the Linux Training Webinar Series, will provide an introduction to the basics of Linux, from tuning and file systems to community interaction. Instructors will continue to include prominent Linux developers, including TAB members. Foundation Executive Director Jim Zemlin described the program as "connect[ing] developers and users with the rock-stars of Linux...to expand the talent pool for Linux."
A number of courses have already been arranged, beginning with Jon Corbet's How to Work with the Linux community on March 1st. Other sessions will include Linux Performance Tuning with Ted Ts’o, Christoph Hellwig's A Linux Filesystem Overview, James Bottomley presenting An Introduction to Git, and “Btrfs: An Intro and Update from Chris Mason. Registration has already opened for Corbet's course, and those interested in other offerings can sign up to be notified as more information becomes available.
Additionally, the Foundation released its Winter/Spring 2010 course catalog for its Classroom, Virtual Classroom, and On-Site training programs. Developer sessions will include Developing Applications For Linux, Embedded Linux Development, Developing with GIT, Linux Kernel Internals and Debugging, and Developing Linux Device Drivers, with Linux Performance Tuning announced for the administration track.
More information on all of the Linux Foundation's training opportunities is available from training.linuxfoundation.org."
in LinuxJournal

quinta-feira, 4 de fevereiro de 2010

Symbian Opens Up

"Nokia bought Symbian in 2008, and nobody believes that their thoughts were anywhere near Open Source particularly given that just weeks prior, it's Open Source chief declared that when it came to FOSS, the company wasn't "ready to play by the rules." Nevertheless, Open Source was exactly what Nokia had in mind for Symbian, as as of today, the process is complete.
SymbianParts of the Symbian platform have been Open Source for quite some time — portions of the code were Open Sourced shortly after it was donated to the Symbian Foundation, and other portions have slowly been released in the nearly two years since. The complete opening wasn't expected until later this year, but finished ahead of schedule due, said Foundation Executive Director Lee Williams, to "the extraordinary commitment and dedication from our staff and our member companies."
The Symbian Foundation picked the Eclipse Public License as its Open Source variant of choice. According to the Symbian Developer Community site, the EPL was chosen "because it balances our goals of encouraging development of the Symbian platform, builds a contributor community and encourages vigorous commercial competition through innovation on top of the platform." It goes on to specifically address the choice not to use the GPL, saying they "[want] to be absolutely clear" that those using the Symbian platform in devices "will be able to add new features and support new hardware without having to make all of that code open source," excepting certain alterations of the licensed code itself. Some code, however, is available under other Open Source licenses, though examples were not immediately available.
The full Symbian^3 codebase — 108 packages in all — is now available for download from the Symbian developer site, including developer and product development kits."

in Linux Journal

Creating Bootable USB Install Drives with UNetbootin

You can make easier your iso files bootable with UNetbootin. See this tutorial and learn:

Run Windows Programs With WIN



"Wine lets you run Windows software on other operating systems. With Wine, you can install and run these applications just like you would in Windows.

Wine is still under active development. Not every program works yet, however there are already several million people using Wine to run their software."

To install WIN go to this website and get the program. According to your installation run the installation file.

Util programms:
  • WineCheck -script that check errors on wine configurations.
  • WineTools - a little script that helps in the configuration of programs.

segunda-feira, 1 de fevereiro de 2010

Add a script to run on boot

So if you have a script and you wish to run them each time you boot up. This will tell you how to do that.

Write a script. put it in the /etc/init.d/ directory.
Lets say you called it XPTO.
  • Give them execution privileges using:
$chmod + XPTO
  •  Now run

$update-rc.d XPTO defaults

You can check out
% man update-rc.d for more information. It is a Debian utility to install scripts. The option “defaults” puts a link to start XPTO in run levels 2, 3, 4 and 5. (and puts a link to stop XPTO into 0, 1 and 6.)

  • To know which runlevel you are in use:
  $runlevel


Add a Grub Splash Image

The grub selection menu does not have a image. If you want to add your images to that menu you can, doing this:


$sudo apt-get install grub-splashimages
This will put the images in:
/boot/grub/splashimages
To add your own do this:

$cd /boot/grub
$sudo ln -s splashimages/debsplash.xpm.gz splash.xpm.gz
$sudo update-grub

What we just did was to link /grub/boot/splash.xpm.gz to the debsplash.xpm.gz splash image, and then updated the grub menu.


sábado, 30 de janeiro de 2010

Firefox Mobile 1.0

Firefox Mobile, the mobile browser developed by Mozilla based on the same engine as in the recently released Firefox 3.6, has finally hit version 1.0. The first device who became with this software is the Nokia N900.
Because their long list of features, looks the most complete mobile browser:
  • The familiar Awesome Bar;
  • Weave Sync for sharing your browser state between your PC and mobile;
  • tabbed browsing and Firefox add-ons. 
With the Nokia 900 and Firefox Mobile 1.0, even Flash content including the normal YouTube site is working, showing that a mobile browser does not have to equal a compromised Internet experience.

sexta-feira, 29 de janeiro de 2010

Convert packages files with Alien

If you have an rpm file for a package you wish to install, and if you cannot find a .deb debian package , you can use the alien package converter application.

Alien is a program that converts various package formates. Like rpm, dpkg, stampede slp, and slackware tgz file formats. If you want to use a package from another distribution than the one you have installed on your system, you can use alien.
But attention Alien should not be used to replace important system packages. In general, if you can’t uninstall the package without breaking your system, don’t try to replace it with an alien version.

Installing Alien:
$sudo apt-get install alien 

Example, conversion of a RPM file into DEB:
$sudo alien -k name_of_rpm_file.rpm  
  • The option -k will keep the version number of RPM file.
  • You can see more option on the Alien manual.



To get an entire web site

In Linux is simple to get an entire web site without install any program:

$wget -r http://Site_that_you_want


IPTables setting up a simple Linux Firewall

So this is a simple script that you can modify and adapt at you like:

#! /bin/sh
echo "\n\nSETTING UP IPTABLES FIREWALL..."

echo "    Loading firewall server rules..."
UNIVERSE="0.0.0.0/0"

# Clear any existing rules and setting default policy to DROP

iptables -P INPUT DROP
iptables -F INPUT
iptables -P OUTPUT DROP
iptables -F OUTPUT
iptables -P FORWARD DROP
iptables -F FORWARD



# Flush the user chain.. if it exists
if [ "`iptables -L | grep LOG_AND_DROP`" ]; then
   iptables -F LOG_AND_DROP
fi

# Delete all User-specified chains
iptables -X

# Reset all IPTABLES counters
iptables -Z

# Creating a DROP chain
iptables -N LOG_AND_DROP
iptables -A LOG_AND_DROP -j LOG --log-prefix "atack happens------->"
iptables -A LOG_AND_DROP -j REJECT --reject-with icmp-host-unreachable

echo  "     - Loading INPUT rulesets"

#######################################################################
# INPUT: Incoming traffic from various interfaces.  All rulesets are
#        already flushed and set to a default policy of DROP.
#

# loopback interfaces are valid.
#iptables -A INPUT -i lo -s $UNIVERSE -d $UNIVERSE -j ACCEPT

# remote interface, claiming to be local machines, IP spoofing, get lost
iptables -A INPUT -s 192.168.0.0/24 -j LOG_AND_DROP
iptables -A INPUT -s 127.0.0.0/8 -j LOG_AND_DROP
iptables -A INPUT -s 200.200.200.200 -j LOG_AND_DROP
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j LOG_AND_DROP
iptables -A INPUT  -p ip -f  -j LOG_AND_DROP
iptables -A INPUT  -p tcp --tcp-flags ALL ACK,RST,SYN,FIN -j LOG_AND_DROP
iptables -A INPUT  -m state -p icmp --state INVALID -j LOG_AND_DROP



# Allow any related traffic coming back to the MASQ server in
iptables -A INPUT  -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo  -s 200.200.200.200 -j ACCEPT
iptables -A INPUT -i lo  -s 127.0.0.1 -j ACCEPT




# Catch all rule, all other incoming is denied and logged.
iptables -A INPUT -s $UNIVERSE -d $UNIVERSE -j LOG_AND_DROP


echo  "     - Loading OUTPUT rulesets"

#######################################################################
# OUTPUT: Outgoing traffic from various interfaces.  All rulesets are
#         already flushed and set to a default policy of DROP.
#

iptables -A OUTPUT -o lo  -d 200.200.200.200 -j ACCEPT
iptables -A OUTPUT -o lo  -d 127.0.0.1 -j ACCEPT
iptables -A OUTPUT  -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state NEW -j ACCEPT


echo  "     - Loading FORWARD rulesets"

#######################################################################
# FORWARD: Enable Forwarding and thus IPMASQ
#          Allow all connections OUT and only existing/related IN

iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD  -s 192.168.0.0/24 -m state --state NEW -j ACCEPT

# Catch all rule, all other forwarding is denied and logged.
iptables -A FORWARD -j LOG_AND_DROP

echo "    Firewall server rule loading complete\n\n"


Download Books from Google to see offline

First you need to put the Google Book URL in this site.(All download instructions are in that site).

After you have all jpg files corresponding to pages of the book in your Linux computer you need to convert this files to PDF. You can run this script on your directory that contains all JPG files:
#!/bin/bash
declare -a ARRAY
ARRAY=$(ls | grep .jpg | grep -v .pdf)

for i in $ARRAY; do
    mv "$i" "$i.pdf"
done
After you have all files in PDF extension you can use this command to join all PDF files:

$pdfjoin --outfile NAME.pdf *.pdf



You can install pdfjoin typing:
$sudo apt-get install pdfjoin

Enjoy ;-)

Shell Script that randomly change image on Linux Desktop

Use this script to randomly display a different image every x seconds. All the images on a given directory are chosen. An image will be chosen at random and displayed each time by the script.

Usage:
You pass to program the images directory that you wants and the interval time
$ ./change_wallpaper.sh "/home/USER_DIRECTORY/Pictures/" "60"

#código
#!/bin/bash
#Program made by
##António L. R. Mendes
function setPaper(){
    declare -a ARRAY
    PATH_IMG=$1
    TIME=$2
    ARRAY=$(ls $PATH_IMG | grep [jpg][png] | sort -R)
       
    for i in $ARRAY; do
        gconftool-2 -t str -s /desktop/gnome/background/picture_filename "$PATH_IMG/$i"
        sleep $TIME
    done
   
    setPaper $PATH_IMG $TIME

}



#we can config:
# $1 - path to the images
# $2 - time to change
PATH_IMG=$1
TIME=$2
if [ ! -d "$PATH_IMG" ]; then
    echo "The directory $PATH_IMG is not a valid directory."
    exit
fi

if [ ! $TIME -gt 0 ]; then
    echo "The time introduced is not valid so the default value is 60 sec."
    $TIME=60
fi


echo "Program will change images in $PATH_IMG every $TIME seconds."
setPaper $PATH_IMG $TIME