Wednesday, June 10, 2009

Thinking out of the BoX !! Download YouTube Videos : The Linux Way !


In this article I will outline a few methods to download YouTube Videos to your system and getting them to play in your favorite player. We will go in a step-wise way :

A. Getting the Video

1. Online Tools

There are some sites like KeepVid.com which allow users to input a YouTube link and they would give you the download link. So get the download link from this site and download the flv file.
2. Firefox Plugin
There is a firefox extension which allows you to download YouTube videos as you watch them. I haven’t tried this.
3. Command Line Tools
This is the safest and best way (for CLI junkies :-D ). Download the script YouTube-dl (thanks to Ricardo Garcia Gonzalez for this nice script). Just put that script in your ~/bin or /usr/bin directories or somewhere in the application path.
To download the flv video do this :
youtube-dl
e.g : youtube-dl http://www.youtube.com/watch?v=D1R-jKKp3NA

B. Playing the video

1. Use VLC Player or MPlayer or Kaffeine to play the flash video.
2. If the above method doesn’t work out (It din’t in my case)..Then go the difficult way :
* Get ffmpeg for your system. SuSE users can get it here.
* Convert the flv video to avi (or any other format) using ffmpeg :
ffmpeg -i my_flash_video.flv the_avi_file.avi
* Now drag and drop the avi file into your favorite video player n watch the video :-)

Still unsatisfied ?! “Dude I’m a *nix user. I can’t sit and do all these steps to get a simple video playing !!” No probs. We will write a shell script to do all this work for you.

Note : I found the downloader in youtube-dl quite slow. So I tweaked it a bit(I don’t know python :-D ) to use an external downloader (axel rocks!). Open the file youtube-dl in your favorite editor and change the following lines :

282 # Abort here if in simulate mode
283 if cmdl_opts.simulate:
284 sys.exit()

to the following :

282 # Abort here if in simulate mode
283 if cmdl_opts.simulate:
284 cond_print(video_data.geturl())
285 sys.exit()

That will make the script output the downloadable video link to the standard output (when run in simulate mode). Now write the shell script :
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Usage : $0 "
echo "e.g : $0 http://www.youtube.com/watch?v=D1R-jKKp3NA steve_jobs"
else
outputfile=".avi"
todnload=`youtube-dl -s $1 | tail -n 1 -`
echo "Got the file.."$todnload
axel -n 100 $todnload -o $2".flv" # wget -c $todnload -O $2".flv" .if you don't use axel
echo "Download Completed..."
ffmpeg -i $2".flv" $2$outputfile # get the avi file
fi

Done. Now paste that code into a file utube in your path. Then run utube as :
utube http://www.youtube.com/watch?v=D1R-jKKp3NA steve_jobs

This will give 2 files steve_jobs.flv and steve_jobs.avi ;)
Just drag the *.avi to kaffeine and enjoy the speech by Steve Jobs !

Monday, June 8, 2009

Arrow keys not working in VMware Server 64bits, host=Fedora 11 64bits, Guest = XP pro 32bits


Ok, I got the solution:

Edit your "/etc/vmware/config" file, so type:
sudo gedit /etc/vmware/config


And add this to it:
xkeymap.nokeycodeMap = true
xkeymap.keycode.108 = 0x138 # Alt_R
xkeymap.keycode.106 = 0x135 # KP_Divide
xkeymap.keycode.104 = 0x11c # KP_Enter
xkeymap.keycode.111 = 0x148 # Up
xkeymap.keycode.116 = 0x150 # Down
xkeymap.keycode.113 = 0x14b # Left
xkeymap.keycode.114 = 0x14d # Right
xkeymap.keycode.105 = 0x11d # Control_R
xkeymap.keycode.118 = 0x152 # Insert
xkeymap.keycode.119 = 0x153 # Delete
xkeymap.keycode.110 = 0x147 # Home
xkeymap.keycode.115 = 0x14f # End
xkeymap.keycode.112 = 0x149 # Prior
xkeymap.keycode.117 = 0x151 # Next
xkeymap.keycode.78 = 0x46 # Scroll_Lock
xkeymap.keycode.127 = 0x100 # Pause
xkeymap.keycode.133 = 0x15b # Meta_L
xkeymap.keycode.134 = 0x15c # Meta_R
xkeymap.keycode.135 = 0x15d # Menu

Save it and be happy!

Thursday, June 4, 2009

The FAT16, FAT32 and NTFS file size limitation


The file size limitation appears to be the problem,
but the maximum size depends on the operating system.
What is the size of the file you're copying and where does it reside?

The maximum file size on a FAT32 formatted partition is
4 GB or 4,294,967,296 bytes minus 2 bytes ...

The maximum file size on a FAT16 partition
under Windows 9.x and ME is 2 GB minus 1 byte ...

But the size limit using the FAT16 file system
under Windows NT or 2K is 4 GB ...

And the NTFS file system has a (theoretical) maximum file size of
16 exabytes or 18,446,744,073,709,551,616 bytes (2^64 sectors) ...

Thursday, May 28, 2009

Setup Samba - Filesharing with Windows


Setup Samba - Filesharing with Windows
If you have other Windows computers on your LAN and want to share files from Linux with them, you must setup Samba.
To setup Samba you must (1) install samba, (2) add you 'shares', (3) add users, (4) start Samba service and (5) manage security options (Firewall and SELinux).

1. Install Samba
It is best to have Samba installed in the installation process. If not < users can install using the command line:

[alex@localhost ~]$ sudo yum install samba samba-client

2. Add Shares
You must edit /etc/samba/smb.conf as root: (use nano instead of gedit if you do not have a GUI)

[alex@localhost ~]$ sudo gedit /etc/samba/smb.conf
Set your Windows Workgroup name in [global] section.
Added shares at the end of the file. Example:

workgroup = WORKGROUP
server string = Samba Server Version %v

# A publicly accessible directory, but read only, except for people in
# the "staff" group
[public]
comment = Public Stuff
path = /home/samba
public = yes
writable = yes
printable = no
write list = +staff

[Share]
comment = Samba shares
path = /home/commons
read only = no
valid users = alex
create mask = 0775
directory mask = 0775
#
# New additional samba shares
#
[mnt_local]
comment = Local shares
path = /mnt/local
public = yes
writable = yes
browseable = yes

[mnt_resume]
comment = Resume partition
path = /mnt/resume
public = yes
writable = yes
browseable = yes

[mnt_account]
comment = Accounts partition
path = /mnt/account
public = yes
writable = yes
browseable = yes




If 'writable' the location must be writable in Linux first. Additionally permissions must match (for example: drw-rw-rw-).
If home data (all personal files under /home/username) is to be accessible, then set 'browseable = yes' under [homes] (~line 250). This configuration file is very descriptive, read through it to get more ideas or information.

3. Add Users
To access shares, you must be a valid user. Add valid users AND passwords using the smbpasswd command.
This login name WILL be the login name and password you use from Windows to access your Linux computer. The password does NOT need to match your Linux password.

[alex@localhost ~]$ sudo smbpasswd -a alex
New SMB password:
Retype new SMB password:
account_policy_get: (warnings ignored)
Added user username.
(Note: 'alex' MUST be a valid account on the Fedora machine)

4. Start Samba Service
Run samba and check for any errors:

[alex@localhost ~]$ sudo /etc/init.d/smb start
Starting SMB services: [ OK ]
Use chkconfig or serviceconf to enable samba (smb) in both runlevels 3 and 5. This will make sure to run Samba each time Fedora boots.

[alex@localhost ~]$ /sbin/chkconfig --list smb
smb 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[alex@localhost ~]$ sudo /sbin/chkconfig --level 35 smb on
[alex@localhost ~]$ /sbin/chkconfig --list smb
smb 0:off 1:off 2:off 3:on 4:off 5:on 6:off
Restart Samba for every change to users/passwords or 'smb.conf'
[alex@localhost ~]$ sudo /etc/init.d/smb restart
Shutting down SMB services: [ OK ]
Starting SMB services: [ OK ]

5. Managing Security for Samba
Firewall
The Firewall will by default block Samba, to allow access run:

[alex@localhost ~]$ system-config-firewall

To allow Samba access to work through the firewall you must set 'Samba' as a 'Trusted Service' and hit 'Apply'. Alternatively if you are only using the shell and do not have access to a graphical X-server, you can run:

[alex@localhost ~]$ sudo system-config-firewall-tui

To allow Samba access to work through the firewall, use to go to Customize. In the Trusted Services: scroll down to Samba, hit and use again to go to Close, then finally to OK.
SELinux
SELinux has significant control over restricting different parts of Samba. Run system-config-selinux. Please read lines #23 - #51 in /etc/samba/smb.conf for a better explanation. Alternatively, you can run:

[alex@localhost ~]$ system-config-selinux
Go to Boolean and type 'samba' in the Filter (without quotes).
The following is NOT complete and is NOT recommended but is a quick enable to allow Samba to work permissively through SELinux.
[alex@localhost ~]# sudo /usr/sbin/setsebool -P samba_export_all_rw on
Alternatively, you can ignore SELinux at this point and try to access your shares in Windows and SELinux TroubleShooter should give an automatic pop-up in GNOME explaining what is wrong. If you follow those recommendations you most likely will be more secure.
For any changes made above to the SELinux settings or smb.conf, it is recommended to restart Samba.
Top Resources

More Information
Fedora 10 - Services and Daemons in Fedora 10
Fedora 10 Blog Entries
Fedora Nvidia Driver Install Guide
Fedora 9 - Personal Installation Guide
Fedora 9 Update and Nvidia Update
Update to RPMFusion
Fedora Core 5 on Dell D810 Latitude Laptop
Managing Services in Fedora
Fedora Help Forum Posts and Threads
Top Resources

5. Managing Security for Samba

Firewall

The Firewall will by default block Samba, to allow access run:

[mirandam@charon ~]$ system-config-firewall

To allow Samba access to work through the firewall you must set 'Samba' as a 'Trusted Service' and hit 'Apply'. Alternatively if you are only using the shell and do not have access to a graphical X-server, you can run:

[mirandam@charon ~]$ sudo system-config-firewall-tui

To allow Samba access to work through the firewall, use to go to Customize. In the Trusted Services: scroll down to Samba, hit and use again to go to Close, then finally to


OK.



Thursday, May 7, 2009

UNIX network analysis


Finding open ports on your workstation
[root@localhost alex]# nmap -T Aggressive -O 192.168.0.106

Starting Nmap 4.76 ( http://nmap.org ) at 2009-05-07 11:38 EDT
Interesting ports on 192.168.0.106:
Not shown: 991 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
902/tcp open iss-realsecure
1521/tcp open oracle
3306/tcp open mysql
6000/tcp open X11
8009/tcp open ajp13
8222/tcp open unknown
8333/tcp open unknown
Device type: general purpose
Running: Linux 2.6.X
OS details: Linux 2.6.15 - 2.6.25
Network Distance: 0 hops

OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 2.49 seconds

Finding other services on your network
[root@localhost alex]# nmap -sT 192.168.0.106/22

Starting Nmap 4.76 ( http://nmap.org ) at 2009-05-07 11:47 EDT
Stats: 0:00:08 elapsed; 104 hosts completed (2 up), 2 undergoing Connect Scan
Connect Scan Timing: About 84.28% done; ETC: 11:48 (0:00:00 remaining)
Interesting ports on 192.168.0.1:
Not shown: 998 closed ports
PORT STATE SERVICE
80/tcp open http
5678/tcp open unknown
MAC Address: 00:1C:F0:54:4C:67 (D-Link)

Interesting ports on 192.168.0.100:
Not shown: 999 filtered ports
PORT STATE SERVICE
10000/tcp open snet-sensor-mgmt
MAC Address: 00:11:A0:04:59:EA (Vtech Engineering Canada)

Interesting ports on 192.168.0.106:
Not shown: 991 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
902/tcp open iss-realsecure
1521/tcp open oracle
3306/tcp open mysql
6000/tcp open X11
8009/tcp open ajp13
8222/tcp open unknown
8333/tcp open unknown

Nmap done: 1024 IP addresses (3 hosts up) scanned in 98.37 seconds
[root@localhost alex]#

Discovering hosts on your network
[root@localhost alex]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.0.1 ether 00:1c:f0:54:4c:67 C wlan0


Finding other hosts on your network
[root@localhost alex]# nmap -sP 192.168.0.106/22

Starting Nmap 4.76 ( http://nmap.org ) at 2009-05-07 11:41 EDT
Host 192.168.0.1 appears to be up.
MAC Address: 00:1C:F0:54:4C:67 (D-Link)
Host 192.168.0.100 appears to be up.
MAC Address: 00:11:A0:04:59:EA (Vtech Engineering Canada)
Host 192.168.0.106 appears to be up.

Nmap done: 1024 IP addresses (3 hosts up) scanned in 81.99 seconds
[root@localhost alex]#

Windows How do I tell if a TCP network port is open or not?

So how do I tell if a TCP or UDP network port is open or not under UNIX or Linux oses?
Sure iptables can be used to block or open port or to apply packet filtering.
However any program can open a network port. For example if use has access to gcc / cc compiler she can open a port.

So it is necessary to list open TCP or UDP ports.

List open TCP port with netstat

Use netstat command to list open tcp port
Code:

[root]# netstat -tulpn

Output:
Code:

tcp        0      0 0.0.0.0:22               0.0.0.0:*                   LISTEN      11960/sshd
tcp        0      0 127.0.0.1:3306           0.0.0.0:*                   LISTEN      3992/mysqld
tcp        0      0 64.19.12.xx:80           0.0.0.0:*                   LISTEN      9474/lighttpd
tcp        0      0 64.19.12.xx:80           0.0.0.0:*                   LISTEN      9474/lighttpd
tcp        0      0 127.0.0.1:25             0.0.0.0:*                   LISTEN      1859/master
tcp        0      0 64.19.12.xx:443          0.0.0.0:*                   LISTEN      9474/lighttpd
netstat also works under Windows XP or 2000 server

Using telnet 
You can also use telnet to find out if port is open or not
Code:

telnet server-ip port-no
telnet localhost 80
telnet 192.168.1.111 25

telnet also works under Windows XP or 2000 server/UNIX oses

Using nmap
Nmap is a free security scanner which is used to evaluate the security of computers, and to discover services or open/close port numbers
Code:

nmap server-ip

Code:

[root]# nmap localhost

Sample output from my computer:
Code:

Starting nmap 3.81 ( http://www.insecure.org/nmap/ ) at 2006-10-10 03:52 MST
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1656 ports scanned but not shown below are in state: closed)
PORT    STATE SERVICE
21/tcp  open  ftp
22/tcp  open  ssh
53/tcp  open  domain
80/tcp  open  http
139/tcp open  netbios-ssn
445/tcp open  microsoft-ds
902/tcp open  iss-realsecure-sensor

Nmap finished: 1 IP address (1 host up) scanned in 0.449 seconds

Nmap works under Windows and UNIX oses
Checking to see if a port is open, blocked, dropped, or filtered at the iptables or windows firewall is not simple. But with above three tools you can get list of open port quickly for both Windows and UNIX servers.

Have fun 

Wednesday, May 6, 2009

Howto create Loop Device on REDHAT, CENTOS or FEDORA


Type : System
Operating System : Redhat,Fedora,Centos
Write by : Fabien FAYE

This mini howto explain how to create more loop device on your operating system.

You need to create more loop device in some case like encrypted file system or HVM xen virtualization.

By default there are 7 devices available, named /dev/loop0 through to /dev/loop7 .

* INFORMATION
* HOT CREATION
* STANDARD CREATION
* MODULE LIMITATION
* TIPS & COMMAND

INFORMATION
-----------
You can find the loop device like that :

# ls -al /dev/loop*
brw-r----- 1 root disk 7, 0 Mar 19 09:34 /dev/loop0
brw-r----- 1 root disk 7, 1 Mar 19 09:34 /dev/loop1
brw-r----- 1 root disk 7, 2 Mar 19 09:34 /dev/loop2
brw-r----- 1 root disk 7, 3 Mar 19 09:34 /dev/loop3
brw-r----- 1 root disk 7, 4 Mar 19 09:34 /dev/loop4
brw-r----- 1 root disk 7, 5 Mar 19 09:34 /dev/loop5
brw-r----- 1 root disk 7, 6 Mar 19 09:34 /dev/loop6
brw-r----- 1 root disk 7, 7 Mar 19 09:34 /dev/loop7

The creation of the loop device is very simple but you have 2 options for this creation one is without reboot and the other one is with a reboot.

HOT CREATION
------------
Creation of loop8, loop9, loop10 :

[root]# mknod -m640 /dev/loop8 b 7 8
[root]# mknod -m640 /dev/loop9 b 7 9
[root]# mknod -m640 /dev/loop10 b 7 10

a.) -m640 define the permission of the device
b.) /dev/loop8 define the name of the device
c.) b for the creation of the special block device
d.) 7 8 the number 7 AND 8 define the MAJOR AND the MINOR

Note: If you made a mistake, just delete the note using:
[root]# rm /dev/loop8

Check if the loop is created
----------------------------
[root]# ls -l /dev/loop8
brw-r----- 1 root root 7, 8 Oct 3 14:54 /dev/loop8

[root]# ls -l /dev/loop9
brw-r----- 1 root root 7, 9 Oct 3 14:54 /dev/loop9

[root]# ls -l /dev/loop10
brw-r----- 1 root root 7, 10 Oct 3 14:54 /dev/loop10


Now you have the applied the proper owner on these devices
----------------------------------------------------------
[root]# chown root:disk /dev/loop8
[root]# chown root:disk /dev/loop9
[root]# chown root:disk /dev/loop10

Now you have to change the module limitation and reboot your system.

STANDARD CREATION
-----------------
You have to modify this file /etc/udev/makedev.d/50-udev.nodes

[root] # vi /etc/udev/makedev.d/50-udev.nodes
loop0
loop1
loop2
loop3
loop4
loop5
loop6
loop7
loop8
loop9
loop10
parport0
parport1
parport2
parport3
net/tun
ppp
console
null
zero

Now you have to change the module limitation and reboot your system.

MODULE LIMITATION
-----------------
In the kernel, you have to allow more creation of loop device.

There is an absolute maximum of 256 devices limited in the kernel. The default limit is set to 8.

# modinfo loop
filename: /lib/modules/2.6.18-53.1.14.el5.centos.plusxen/kernel/drivers/block/loop.ko
alias: block-major-7-*
license: GPL
srcversion: 82DB6DB3DABF3B945D6394D
depends:
vermagic: 2.6.18-53.1.14.el5.centos.plusxen SMP mod_unload gcc-4.1
parm: max_loop:Maximum number of loop devices (1-256) (int)
module_sig: 883f35047d15787f0a982eee333b2d8112f51f09f68f09b79223a34983b3aef66820c08cc6e8cd3709f6d7c56171e5a579ee1ca2ca56349c56b983a7c46

Now you have to change this value with the modprobe.conf file.

#vi /etc/modprobe.conf
...
options loop max_loop=64
...

TIPS & COMMAND

The command line losetup is used for set up and control loop device.

# losetup
usage:
losetup loop_device # give info
losetup -d loop_device # delete
losetup -f # find unused
losetup -a # list all used
losetup -r # read-only loop
losetup [-e encryption] [-o offset] [-r] {-f|loop_device} file # setup

Last Updated on Tuesday, 03 February 2009 22:17

Thursday, April 23, 2009

Fairfax Auto Parts


Alexandria
Fairfax Auto Parts
456 S. Pickett Street
Alexandria, VA 22304
703-823-0800

Annandale
Fairfax Auto Parts 7219 Columbia Pike
Annandale, VA 22003
703-354-7600

Burke
Fairfax Auto Parts 5663 Burke Centre Parkway Directions
Burke, VA 22015
703-425-4400
Kamp Washington Fairfax Auto Parts-No. Va. 10912 Lee Hwy. Directions
Fairfax, VA 22030
703-591-6500
Falls Church Fairfax Auto Parts 431 S. Maple Ave. Directions
Falls Church, VA 22046
703-534-1200
Merrifield Fairfax Auto Parts, Inc. 8701 Lee Hwy. Directions
Fairfax, VA 22031
703-560-1560
Newington Fairfax Auto Parts 8196-A Terminal Rd. Directions
Newington, VA 22079
703-339-8300
Vienna Fairfax Auto Parts 121 Church Street NE Directions
Vienna, VA 22180
703-281-5700
Chantilly Fairfax Auto Parts 14154-C Willard Road Directions
Chantilly, VA 20151
703-631-3800
Sterling Fairfax Auto Parts 47060 Harry Byrd Hwy. #100 Directions
Sterling, VA 22170
703-450-6600
Fairfax City Economy Auto Parts 3855 Pickett Road Directions
Fairfax, VA 22031
703-978-4500
Machine Shop Machine Shop 8701 Lee Hwy. Directions
Fairfax, VA 22031
703-560-0813
Manassas - Rt. 234 Economy Auto Parts 8106 Sudley Road Directions
Manassas, VA 20110
703-368-1002
Manassas - Euclid Ave. Champ Auto Parts 9088 Euclid Ave. Directions
Manassas, VA 20110
703-368-7106
Manassas - Rt. 28 Manassas Auto Parts 7809 Centreville Rd. Directions
Manassas, VA 20110
703-368-7191
Herndon Fairfax Auto Parts 23070 Oak Grove Road Directions
Sterling, VA 20166
703-707-0800

Monday, April 20, 2009

TBD


Computing Hourly or Annual Rate


Constant multiplier = 2080

1. How to compute for the Annual Salary given the hourly rate?
Hourly rate = $45.00
Annual = $45.00 x 2080
Annual = $93,600.00

2. How to compute for the Hourly Salary given the Annual Income?
Annual = $93,600.00
Annual = $93,600.00 / 2080
Hourly rate = $45.00

Friday, April 10, 2009

Copy CDROM to ISO image file


1. Using dd
[root] dd if=/dev/cdrom of=/usrISO/tncdcopy.iso

2. Using cat
[root] cat /dev/cdrom > /tmp/trendnet.iso

Note:
1. Ensure that the cd-rom is not mounted
2. These two commands will produce the same result and same size of ISO image