Archive

Posts Tagged ‘Power Computing’

Setup a telnet chat server with STChat.

January 29th, 2010 Jimmy No comments

STChat is a simple telnet chat server that runs on Linux, Windows and MAC. I’ve only tested this on Linux so i can’t speak for the other OS’s. The chat system is really simple, supports colors, multiple terminal types (vt100 etc), usernames and admin mode. Putty, Linux telnet, and Windows telnet seem to work just fine when connecting to the chat server. No special installation is needed except that you do need a Java Runtime Environment (JRE) to run the server. Simply unpack the package and run ‘java stc 2020` to start the server on port 2020. If you want to run STchat on the standard telnet port, port 23, you’ll need to run the server as root. e.g. java stc 23

STChat comes with the complete source. Some of the code is deprecated but you can simply ignore these messages at compile time. Note: Default compiled binaries are included so don’t worry about this unless you plan to modify the source code. The STChat project page is located here.

Read more…

Linux: cut – divide file into columns.

January 28th, 2010 Jimmy No comments

cut

Divide a file into several parts (columns)
Writes to standard output selected parts of each line of each input file, or standard input if no files are given or for a file name of `-’.

Syntax
     cut [OPTION]... [FILE]...

In the options below, BYTE-LIST, CHARACTER-LIST, and FIELD-LIST are one or more numbers or ranges (two numbers separated by a dash)

Bytes, characters, and fields are are numbered starting at 1 and separated by commas.
Incomplete ranges may be given: -M means 1-M  ;  N- means N through end of line or last field.

Options

-b BYTE-LIST
--bytes=BYTE-LIST
     Print only the bytes in positions listed in BYTE-LIST.  Tabs and
     backspaces are treated like any other character; they take up 1
     byte.

-c CHARACTER-LIST
--characters=CHARACTER-LIST
     Print only characters in positions listed in CHARACTER-LIST.  The
     same as `-b' for now, but internationalization will change that.
     Tabs and backspaces are treated like any other character; they
     take up 1 character.

-f FIELD-LIST
--fields=FIELD-LIST
     Print only the fields listed in FIELD-LIST.  Fields are separated
     by a TAB character by default.

-d INPUT_DELIM_BYTE
--delimiter=INPUT_DELIM_BYTE
     For `-f', fields are separated in the input by the first character
     in INPUT_DELIM_BYTE (default is TAB).

-n
     Do not split multi-byte characters (no-op for now).

-s
--only-delimited
     For `-f', do not print lines that do not contain the field
     separator character.

--output-delimiter=OUTPUT_DELIM_STRING
     For `-f', output fields are separated by OUTPUT_DELIM_STRING The
     default is to use the input delimiter.

Example

Parse out column 2 from a semicolon (;) delimited file:

$ cat myfile.txt | cut -d \; -f 2 > output.txt

Bash and Shell Dialog Examples

January 26th, 2010 Jimmy No comments

Below are some basic examples of how to create Dialog based Bash scripts for the Linux console. Dialog provides a method of displaying several different types of dialog boxes from shell scripts. The bash dialog example below walks you through a basic “Hello World” shell script using Dialog.

#!/bin/sh
rm /tmp/h.out
while [ 0 ]; do

Create a two option dialog box 11 by 40 characters in size.

dialog --title "Hello World" --menu \
"Select Interface or <Cancel> to exit" \
   11 40 4  \
   "1" "Say Hi!" \
   "2" "Quit" 2>/tmp/h.out

Trap what the user selects into the SEL variable. Values will either be a 1 or a 2 based on our menu above.

SEL="`cat /tmp/h.out`"

Read more…

Easily write ISO files to USB drives in Linux.

January 13th, 2010 Jimmy 2 comments

Writing an ISO file to a USB drive just got super easy for me. I found this program called UNetbootin which lets me select and ISO drive, select the /device I want to write to, and BAM, bootable USB drive. One thing to note, when selecting your /device (e.g. /dev/sdb1) make sure it’s mounted. When I plugged in my 1gig stick I mounted it to /mnt/sdb1 and selected /dev/sdb1 from the drop down menu. You’ll need to know which /device is your USB drive. Ubuntu automatically mounts your drive so all you have to do is run a “df” command in a shell to see all your mounted drives.

With UNetbootin I was able to write any ISO file to any USB stick and boot them on a few various laptops and Netbooks I have kicking around that support booting off USB drives.

Ahhh yes, no more manually copying files to thumb drives and manually creating Master Boot records…..gotta love it!

Setting up a firewall in Linux with iptables.

January 7th, 2010 Jimmy No comments

Setting up a firewall in Linux is actually surprisingly easy. With Ubuntu you may want to make sure the iptables package is installed. If you run Slackware, the best Distro on Earth, you’ve already got it. Iptables is the heart of most firewall scripts in Linux.

I’m going to assume that you are running a Linux box with two Ethernet cards installed. One controller will be on the public network side, the other on the private network side. For this example we’ll also be using the 192.168.1.* network as the private network and 10.10.8.* as the public (outside) network.

Ok now it’s time to jump into the firewall script. I created a simple bash script called rc.firewall.

#!/bin/sh

###Firewall Kernel Modules and base configuration###
iptables -F -t nat
iptables -F -t mangle
iptables -F -t filter

iptables -X
iptables -t nat -X
iptables -t mangle -X
iptables -t filter -X

echo &quot;1&quot; &gt; /proc/sys/net/ipv4/conf/all/forwarding
echo 1 &gt; /proc/sys/net/ipv4/ip_forward

/sbin/modprobe iptable_nat
/sbin/modprobe iptable_filter
/sbin/modprobe ip_tables
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ipt_REJECT
/sbin/modprobe ipt_REDIRECT
/sbin/modprobe ipt_MASQUERADE
/sbin/modprobe ipt_LOG

###Now we want to forward all web traffic to a server on the internal network.
iptables  -t nat -A PREROUTING -d 10.10.5.56 -p tcp --dport 80 -j DNAT --to 192.168.1.27:80

##Lets configure a secure web connection too.
iptables  -t nat -A PREROUTING -d 10.10.5.56 -p tcp --dport 443 -j DNAT --to 192.168.1.27:443

##A configuration to a telnet port on another Linux box? Forward public traffic on port 2000 to port 23 on an internal server.
iptables  -t nat -A PREROUTING -d 10.10.5.55 -p tcp --dport 2000 -j DNAT --to 192.168.1.210:23

###We can't forget to route Quake Arena traffic as well.
iptables  -t nat -A PREROUTING -i eth0 -p udp --dport 28960 -j DNAT --to 192.168.1.64:28960

##Now lets BLOCK a bunch of IP addresses. Basically we are blocking the INPUT, OUTPUT and FORWARDING for all data, source and destination for the given IP address of 213.2.31.55.
iptables  -A FORWARD -p tcp -s 213.2.31.55/8  -j DROP
iptables  -A INPUT -p tcp   -s 213.2.31.55/8  -j DROP
iptables  -A OUTPUT -p tcp -s 213.2.31.55/8  -j DROP
iptables  -A FORWARD -p tcp -d 213.2.31.55/8  -j DROP
iptables  -A INPUT -p tcp   -d 213.2.31.55/8  -j DROP
iptables  -A OUTPUT -p tcp -d 213.2.31.55/8  -j DROP

###Route all web based surfing and Internet access through this firewall.
iptables  -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Thats basically it. Save and run the firewall script. You can test by trying to surf from within the network. Make sure the Gateway on your workstation is set to the internet IP address where this script is running.

You can also call a friend or someone to try to access a web server or whatever for testing.

Cool desktop widgets for Linux with Screenlets.

January 6th, 2010 Jimmy No comments

If you’re looking to pretty up your Linux desktop with some cool widgets take a look at the screenlets package. Screenlets is availible as a Debian or Ubuntu package so installing is just a matter of going to your package manager and searching for “screenlets”. Once installed you can access the screenlets from the applicatons -> screenlets menu. From what I see screenlets only works in Gnome.

3D Linux Desktop switcher with Compiz.

January 6th, 2010 Jimmy No comments

If you’re looking for a really cool 3D Linux desktop do a search for Compiz. You’ll want the Compiz and CompizConfig packages from your distributions package system. In Ubuntu you can use the Synaptic Package Manager to download and install the necessary software.

Once installed you’ll want to open up the CompizConfig Settings Manger. (System – Administration – CompizConfig Settings Manager)

Check all the cube options.

Once you’re done with that you should be able to click your middle mouse button and move the cube (3D task switcher) around.

Note:Some computer hardware will not be able to use the Compiz. Most computers with Intel,Nvidia and ATI chipsets should work fine..

Spy on MSN, AIM and Yahoo chats with ChatSniff.

January 6th, 2010 Jimmy No comments


Everyday I am impressed at what I find for Linux software, especially security related software such as sniffers. I wanted to see what was availible for instant messenger sniffers and sure enough I found a cool looking program called ChatSniff. For all you Ubuntu users, they’ve got a debian package for you to install on their homepage.

ChatSniff is an easy to use program for Linux that monitors, or “sniffs” networks for AIM, MSN, Yahoo! and Jabber instant messages. It requires recent versions of python, python-gtk2, python-glade2, and tethereal.

python-pyao (for sound) and gksu are optional, but recommended (the packages require them).

Enhancements:
- Moved to single instance of tethereal
- Removed “any” device from device list
- First time case for net dev selection
- Major HIG/UI adjustments (brad)
- Moved to a single pane view
- Added status bar
- Added auto-start
- Added toolbar
- Major code cleanup
- Packet output cleanup
- Better error dialog formating
- Added versioning to preferences
- Start/stop timestamps
- Help dialog now reflects reality
- No more ugly empty space above first packet
- Sundry minor tweaks

Desktop Video Recording in Linux (Like Fraps).

January 5th, 2010 Jimmy No comments

RecordMyDesktop is an open source tool for recording your desktop into a the OGV open source video format. You can then use a video editing program such as In the near future I am going to be making some video tutorials on programming and Linux which requires me to have a desktop video recording tool similar to FRAPS. RecordMyDesktop is the easiest desktop video recording software I have found so far. Once you record your desktop with RecordMyDesktop you can then use WinFF to convert that into a more common format such as Mpeg4 or Flash(flv).

When you get RecordMyDesktop don’t forget to install the GTK front-end gtk-recordmydesktop as well which gives you the GUI front end app you see above.

WinFF Conversion

WinFF is also available from your Ubunto or Debian package manager.

Sample Video
3D Task Manager for Linux

Which Linux desktop for Netbooks?

January 5th, 2010 Jimmy No comments

Recently I’ve acquired an Asus eeePC 4gb Netbook. The Netbook had some funky version of Linux preinstalled which ran everything as the root user with no authentication. Talk about a disaster ready to happen! After installing Ubuntu Netbook Remix I noticed some lag in the Remix user interface which brought up the question, which Linux desktop should I be using?

Gnome was obviously the default desktop I tested because it came with Ubuntu Netbook Remix. Gnome is cool and all but I had to test the other two mainstream desktops as well, KDE and XFCE.

KDE4 installed without a hitch and booted right up but the KDE Plasma desktop environment was just a tad too much for my little Netbook. The system was usable and worked fairly ok but was still a touch on the laggy side, laggier than Gnome for sure. KDE4 looks really cool on the Netbook but I would sacrifice some looks for a lag free desktop experience.

KDE4 on my Netbook.

XFCE would have to be my topic pick and is still the Linux desktop environment I am using on my netbook. The desktop looks good and runs really smooth with no laggy window moving at all. All I did to install the XFCE desktop was open up a terminal and run sudo apt-get install xubuntu-desktop. This will install everything you’ll need for your netbook desktop. XFCE also makes your desktop seem a little bigger, I think that is because I could change the height to 21 pixels high, the smallest before you cut the text in half.

My XFCE Netbook Desktop.