August 3, 2009

Change Linux Ethernet Speed and Duplex

Task: Change the speed and duplex settings

Setup eth0 negotiated speed with mii-tool
Disable autonegotiation, and force the MII to either 100baseTx-FD, 100baseTx-HD, 10baseT-FD, or 10baseT-HD:# mii-tool -F 100baseTx-HD
# mii-tool -F 10baseT-HD
Setup eth0 negotiated speed with ethtool# ethtool -s eth0 speed 100 duplex full
# ethtool -s eth0 speed 10 duplex half
To make these settings permanent you need to create a shell script and call from /etc/rc.local (Red Hat) or if you are using Debian create a script into the directory /etc/init.d/ directory and run update-rc.d command to update the script.

Read man page of mii-tool and ethtool for more information.

source: http://www.cyberciti.biz/faq/linux-change-the-speed-and-duplex-settings-of-an-ethernet-card/

July 29, 2009

enable multiple dummy ethernet interfaces in Linux

To get my dummy interfaces, just do this:
 modprobe dummy numdummies=5

July 22, 2009

How can I force a reload of an image from the server if the image already exists in the browser's cache?

Q416 How can I force a reload of an image from the server if the image already exists in the browser's cache?

By adding a different search string value after the image href. The following reloads the image from the server every 10 seconds:



<---script language="JavaScript">
function reloadImage() {
var now = new Date();
if (document.images) {
document.images.myImageName.src = 'picture.gif?' + now.getTime();
}
setTimeout('reloadImage()',10000);
}
setTimeout('reloadImage()',10000); //-->





Source: http://www.irt.org/script/416.htm

June 29, 2009

Measure TCP Throughput using netcat (nc)

netcat (nc) is installed on almost all Linux computers. So when you do not have tools such as iperf available for TCP throughput testing, try the way of doing it with netcat.

On machine A, do :

nc -v -v -l -n -p 2222 >/dev/null

For redhat or Fedora Core do this instead:

nc -v -v -l -n 2222 >/dev/null

On machine B do:
time yes|nc -v -v -n 192.168.0.8 2222 >/dev/null

Now wait 30 seconds, and hit Ctrl-C on machine B, and you shoud get something like this:
sent 87478272, rcvd 0
real 0m9.993s
user 0m2.075s
sys 0m0.939s

Now calculate the throughput
87478272 * 8 / 9.993 (the nubmer above after real)

You can use python as a calculator to do this. :-)

Now that's pretty easy, isn't it?

June 10, 2009

tcpdump "received by filter"

When you use tcpdump on Linux, and do not see all the packets you are expecting, and get something like this:

10 packets captured
100 packets received by filter
0 packets dropped by kernel

Make sure you use "tcpdump -Nn ...". This disables tcpdump name lookup, and makes tcpdump much faster/real-time. It took me some time to find this out. Hope this helps.

June 4, 2009

How to change stored Network Printer Credentials

Try running on the problematic PC (XP), from the start/run box:
rundll32.exe keymgr.dll, KRShowKeyMgr
This should open the password management console. If your saved share is present, you should be able to delete it.
The following article outlines in detail
http://www.windowsnetworking.com/kbase/WindowsTips/WindowsXP/AdminTips/Security/RemoveSavedPasswords.html

May 7, 2009

Virtualbox, Ubuntu, Change Screen Resolution

After installing the guest package, Ubuntu 9.04 still does not show the right screen resolution.

Then do this:

At the terminal type this

sudo dpkg-reconfigure -phigh xserver-xorg

and log out, and log back in.

Now your screen resolution is the same as your window size. Just maximize your window or go full screen to get the max screen resolution

April 21, 2009

Struct sockaddr and friends

Prototypes



include <netinet/in.h>

// All pointers to socket address structures are often cast to pointers
// to this type before use in various functions and system calls:

struct sockaddr {
unsigned short sa_family; // address family, AF_xxx
char sa_data[14]; // 14 bytes of protocol address
};


// IPv4 AF_INET sockets:

struct sockaddr_in {
short sin_family; // e.g. AF_INET, AF_INET6
unsigned short sin_port; // e.g. htons(3490)
struct in_addr sin_addr; // see struct in_addr, below
char sin_zero[8]; // zero this if you want to
};

struct in_addr {
unsigned long s_addr; // load with inet_pton()
};


April 1, 2009

vim marks

Marks

You can set marks within your documents to jump quickly between different positions of a document or even many documents.

Vim automatically sets various marks like

* {0-9} are the last 10 positions of closed files (0 the last, 1 the last but one)
* <> are the left and right position of marked texts
* ( and ) are the start or end of the current sentence
* { and } are the start or end of the current paragraph
* [ and ] are the first or last character of the last yanked or changed text
* . position of the last change
* ' or ` position before the last jump
* " position before the last exit of the file (local to a file)
* ^ position of the last insert-stop

To set a manual mark, use m{a-zA-Z} (m followed by either a,b..z or A,B,..Z), and to jump to one of the marks (manual or automatic) you can choose between ' and `

* ' ...sets the cursor to the first non-blank character in the marked line
* ` ...sets the cursor to the exact position where the mark was set

There is a little difference between lower-case and upper-case characters:

* {a-z} are local to a file
* {A-Z} are stored and available over sessions (associated with a file)

You can use L for your work-log and T for your time-table for example, and quickly update the information there.

For example you can jump to the last known position of a file before it was closed by typing `" (it’s easy to configure Vim to do it automatically at start).

To get a list of all marks Vim knows about type :marks. To delete marks use :delmarks (:delmarks a b c removes marks a and b and c, to delete all marks use :delmarks!).

More tips at http://blog.interlinked.org/tutorials/vim_tutorial.html

March 30, 2009

Fix Debian Problem: W: There is no public key available for the following key IDs

When you do an "apt-get" on Debian, you get:

W: There is no public key available for the following key IDs:
.....

To fix this problem, just run this:

sudo apt-get install debian-archive-keyring

March 20, 2009

google search tips 1

Typically google will display page with the "searched text" either in the page or in referring pages.

To only show pages with the search phrases in them, start your search with "allintext:"

Other possible web search options are:
allinanchor:,
allintext:,
allintitle:,
allinurl:,
cache:,
define:,
filetype:,
id:,
inanchor:,
info:,
intext:,
intitle:,
inurl:,
phonebook:,
related:,
site:

March 19, 2009

GNU Screen Reference

screen Quick Reference

Getting in

start a new screen session: screen
.. with session name: screen -S
attach to a running session: screen -r
.. to session with name: screen -r
the “ultimate attach”: screen -dRR (Attaches to a screen session. If the session is attached elsewhere, detaches that other display. If no session exists, creates one. If multiple sessions exist, uses the first one.)

Escape key

All screen commands are prefixed by an escape key, by default C-a (that's Control-a, sometimes written ^A). To send a literal C-a to the programs in screen, use C-a a.

Getting out

detach: C-a d
detach and logout (quick exit): C-a D D
exit screen: exit all of the programs in screen.
force-exit screen: C-a C-\ (not recommended)

Help

See help: C-a ? (lists keybindings)

Window Management

create new window: C-a c
change to last-visited active window: C-a C-a (commonly used to flip-flop between two windows)
change to window by number: C-a (only for windows 0 to 9)
change to window by number or name: C-a '
change to next window in list: C-a n or C-a
change to previous window in list: C-a p
see window list: C-a ” (allows you to select a window to change to)
show window bar C-a w (if you don't have window bar)
close current window: Close all applications in the current window (including shell)
kill current window: C-a k (not recommended)
rename current window: C-a A

Split screen

split display: C-a S
jump to next display region: C-a tab
remove current region: C-a X
remove all regions but the current one: C-a Q

Misc

redraw window: C-a C-l
enter copy mode: C-a [ (also used for viewing scrollback buffer)
paste: C-a ]
monitor window for activity: C-a M
monitor window for silence: C-a _
enter digraph: C-a C-v
lock (password protect) display: C-a x
enter screen command: C-a :

Disable screensaver in registry

At times, there is need to disable screensaver on Windows but the option is disabled on the Background windows. Use the following option in Registry to do it:

HKEY_CURRENT_USER\Control Panel\Desktop\screensaveactive

process binary data with gawk

In times, there is need for gawk to process binary data, such as dumping the content of a binary file (mimicking od or xxd), or dump the content of a binary packet. The following script comes handy for this purpose.

#dumpbin.awk
#!/usr/bin/gawk -f
BEGIN{
FS="";
RS="\n";
for (i = 0; i <>
d[sprintf("%c", i)]=i;
}
}
{
for (i=1;i<=NF;i++){
printf("%02X ",d[$i]);
count++;
if (count%16==0)
printf("\n");
}
printf("0A ");
count++;
if (count%16==0)
printf("\n");
}

March 9, 2009

California Limited Liability Company Fee

LLCs are subject to an $800 annual tax if they are doing business in California or have articles of organization accepted, or a certificate of registration issued by the California Secretary of State. The annual tax is prepaid for the privilege of doing business in California, and is due and payable on or before the 15th day of the 4th month after the beginning of the taxable year. The annual tax must be paid for each taxable year until the appropriate papers are filed.

In addition to the annual $800 tax, every California LLC must pay a fee based on total annual income. The LLC fee is due on or before the 15th day of the 4th month after the close of the LLC’s taxable year. The California Franchise Tax Board has a booklet containing much of what one needs to know about LLCs. For taxable years beginning on or after January 1, 2002, use the following chart to compute the fee:

If total annual income is equal to or over – but not over –

$250,000 to $499,999 the fee is $900
$500,000 to $999,999 the fee is $2,500
$1,000,000 to $4,999,999 the fee is $6,000
$5,000,000 and over the fee is $11,790

If the California Franchise Tax Board (FTB) determines multiple LLCs were formed for the primary purpose of reducing fees, the LLC’s total income from all sources that are reportable to California could include the aggregate total income of all commonly controlled LLC members. “Commonly controlled” means control of more than 50% of the capital interests or profit interests of the taxpayer and any other LLC or partnership by the same persons.

February 10, 2009

January 27, 2009

Install IE6 on Debian using ies4linux

1) Login as root and do:

apt-get update
apt-get install wine libxxf86dga1 libxxf86vm1 cabextract

2) Logout and login with a user account. Download and install IEs4Linux:

wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
tar zxvf ies4linux-latest.tar.gz
cd ies4linux-*

Do not run ./ies4linux,because the GUI version is not stable. Instead , run

./ies4linux --no-gui --install-corefonts

It is important to have the --install-corefonts option, otherwise some webpage does not display correctly.

January 14, 2009

VLC TIPS

To do one-way streaming of a MP3 file:

vlc test.mp3 --mtu=120 :sout="#duplicate{dst=std{access=udp,dst=192.168.100.5:1234}}"

or simple version:
vlc test.mp3 --sout udp:192.168.100.5:1234

To use non-GUI interface

vlc -I rc test.mp3 --mtu=120 :sout="#duplicate{dst=std{access=udp,dst=192.168.100.5:1234}}"

To hear the music:
vlc udp://@192.168.100.5
or
vlc udp://@
or
vlc udp://@:1234 (1234 is the default port)

VLC command line examples (test with version 0.9.8a)

Good Links
----------------
http://www.videolan.org/doc/streaming-howto/en/ch07.html
http://www.videolan.org/doc/play-howto/en/ch04.html
http://www.videolan.org/doc/streaming-howto/en/ch03.html (Command line module syntax)
http://www.videolan.org/streaming-features.html (Codec Matrix)


TO RECEIVE & PLAY
----------------------

To receive a UDP streaming on the 192.168.100.5 interface with a udp port of 3000

vlc udp://192.168.100.5:3000

a shorter version:

vlc udp://@:3000

If the udp port if the default port used by VLC (port 1234), this can be even shorter:

vlc udp://

To receive from a RTSP address, use:
vlc rtsp://URL

same goes for http, ftp or mms streaming url, and a SDP file.


TO STREAM
----------------------


syntax:
==============
vlc input_stream --sout "#module1{option1=parameter1{parameter-option1},option2=parameter2}:module2{option1=...,option2=...}:..."

You may also use the following syntax :
% vlc input_stream --sout-module1-option1=... --sout-module1-option2=... --sout-module2-option1=... --sout-module2-option2=... ...

The stream output also offers a simplified syntax, with which you can only you use the standard module main options:
% vlc input_stream --sout access/mux:url
where access, mux and url are as defined in the options of the -standard- module.

input_stream: any address usable by the RECEIVE&PLAY section above, so it can be RTP:// or HTTP:// or UDP:// ,etc

-I dummy
Disables the graphical interface
vlc://quit
Quit VLC after transcoding


Streaming Modules Discription
---------------------------------------

-- standard(std), allows to send the stream via an access output module: for example, UDP, file, HTTP, ... You will probably want to use this module at the end of your chains.

access=file/udp/http/https/rtp/mmsh
mux=ts/ps/mpeg1/ogg/asf/asfh/avi/mpjpeg
dst=filename/ipaddress:port/URL

-- transcode, is used to transcode (decode and re-encode the stream using a different codec and/or bitrate) the audio and the video of the input stream. If the input or output access method doesn't allow pace control (network, capture devices), this done "on the fly", in real time. This can require quite a lot of CPU power, depending on the parameters set. Other streams, such as files and disks are transcoded as fast as the system allows it.

vcodec=
vb=
venc=ffmpeg/theora/x264
fps=
deinterlace
scale=
width=
height=
acodec==
ab=
aenc=ffmpeg/vorbis/speex
samplerate=
channels=

-- duplicate, allows you to create a second chain, where the stream will be handled in an independent way.

dst= (Any of the stream output module described earlier, such as standard,transcode,etc can be used as parameter of this option)


-- display, allows you to display the input stream, as VLC would normally do. Used with the duplicate module, this allows you to monitor the stream while processing it.

-- rtp, streams over RTP (one UDP port for each elementary stream). This module also allows RTSP support.
dst=ipaddress
port=port number (must be an even number)
port-video= port number (must be an even number)
port-audio= port number (must be an even number)
mux= ,This option allows to set the encapsulation method used to send the stream. See mux= options of the standard module for a description of the available method. Only ts is possible for RTP streams. By default, each elementary stream is sent as a separate RTP media, i.e. no encapsulation is done.


Examples
---------------
-- To record from microphone and send out using udp
vlc --mtu=120 dshow:// :dshow-vdev="none" :dshow-adev="" :sout=#transcode{acodec=mp4a,ab=24,channels=1}:duplicate{dst=std{access=udp,mux=ts,dst=:1234}}

or
vlc --mtu=120 dshow:// :dshow-vdev="none" :dshow-adev="" :sout=#transcode{acodec=mp4a,ab=24,channels=1}:std{access=udp,mux=ts,dst=:1234}

or (record a-law wav file, somehow there is a lot of noise)
vlc dshow:// :dshow-vdev="none" :dshow-adev="" --dshow-audio-channels=1 --dshow-audio-samplerate=8000 --dshow-audio-bitspersample=8 :sout=#transcode{acodec=alaw,ab=64,channels=1}:std{dst=c:\temp\abc.wav,mux=wav,access=file}

-- To stream a wav file as G711 alaw. Note that VLC is sensitive to the input format. To stream G711, the input file has to be 8000 samples per second, 8bit.
vlc.exe c:\tools\record\national_anthem.wav --sout "#transcode{acodec=alaw,ab=64,scale=1,channels=1,ar=8000}:rtp{dst=192.168.100.40,port-audio=1250}"


January 6, 2009

scp with automatic password input

I know I should use certificate to automate this, but sometimes we do need to do scp with a password and it would be nice to automate it. Here Document does work. We need "expect" utility to do it. Here is an example:

#!/usr/bin/expect -f

# trick to pass in command-line args to spawn
#eval spawn scp $argv
eval spawn scp hcw root@10.0.0.1:.

expect "password: $"
send "yourpassword\n"

# wait for regular shell prompt before quitting
# probably a better way using 'wait'
expect "$ $"

January 1, 2009

Camera Hack with Google

inurl:/view/index.shtml
(These camera hacks, are mostly security cameras) Airports, Car Parks, Colleges, Back Gardens, Traffic Cams etc.

inurl:viewerframe?mode=
(These camera hacks, are mostly) Private Web Cams etc.

inurl:lvappl
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc live webcams
(Brings up a huge list of Web Cams from around the world, you just have to pick one)

inurl:"viewerframe?mode=motion"
(Thses are Network Cameras)

intitle:"snc-rz30 home"
(These cameras are mostly security cameras, shops, car parks)

intitle:"WJ-NT104 Main"
(These cameras are mostly security cameras, shops, car parks)

inurl:LvAppl intitle:liveapplet
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc

intitle:"Live View / - AXIS"
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc

inurl:indexFrame.shtml "Axis Video Server"
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc

intitle:Axis 2400 video server
(These camera hacks, are mostly security cameras) Car Parks, Colleges, Clubs, Bars etc.

inurl:/view.shtml
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc.

intitle:"Live View / - AXIS" | inurl:view/view.shtml
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc.

inurl:ViewerFrame?Mode=
(Thses are Network Cameras)

inurl:ViewerFrame?Mode=Refresh
(These camera hacks, are mostly security cameras) Parks, Bird Tables etc.

inurl:axis-cgi/jpg
(These camera hacks, are mostly security cameras) you will have to keep refreshing these..

intitle:liveapplet
(These camera hacks, are mostly security cameras) Car Parks, Colleges, Clubs, Bars etc.
allintitle:"Network Camera NetworkCamera" (Thses are Network Cameras)

intitle:axis intitle:"video server"
(These camera hacks, are mostly security cameras) Car Parks, Colleges, Clubs, Bars, Ski slope etc.

intitle:"EvoCam" inurl:"webcam.html"
(These camera hacks, are mostly security cameras) From europe etc.

intitle:"Live NetSnap Cam-Server feed"
(Thses are Network Cameras) Private and Non Private Web Camera.

inurl:indexFrame.shtml Axis
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc.

inurl:"MultiCameraFrame?Mode=Motion"
(These camera hacks, are mostly security cameras) Pet shop, Colleges etc.

intitle:snc-z20 inurl:home/
(These camera hacks, are mostly security cameras) Swimming pool, and more.

intitle:snc-cs3 inurl:home/
(These camera hacks, are mostly security cameras) Swimming pool, and more.