Wednesday, August 27, 2008

How to Download mms:// (MultiMedia Stream) Video?

If you are not able to download the mms://a-web-site/stream_video.wmv
and only able to play via streaming. But you might have slow speed,

Then, you can use mencoder to download above file.

$ mencoder -oac copy -ovc copy -o out_video_file.wmv mms://a-web-site/stream_video.wmv

PS. If you want to view via streaming, you can use mplayer:

$ mplayer mms://a-web-site/stream_video.wmv

Friday, August 22, 2008

Denial of Service (DoS) Prevention

You can prevent DoS on you machine, by running following
commands as root user. Or you can put following lines
in a shell script and run it as root.

# shut some DoS stuff down
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

# increase the local port range
echo 1024 65535 > /proc/sys/net/ipv4/ip_local_port_range

# increase the SYN backlog queue
echo 2048 > /proc/sys/net/ipv4/tcp_max_syn_backlog

echo 0 > /proc/sys/net/ipv4/tcp_sack
echo 0 > /proc/sys/net/ipv4/tcp_timestamps

Wednesday, August 6, 2008

How to stop certain network to start at boot time in Fedora?

For example, if you do not want wlan0 to be started at boot time,
just move ifcfg-wlan0 file from /etc/sysconfig/network-scripts/ directory
to any other directory.

I am telling not to remove the file, because you can start
wlan0 interface after copying the file back to /etc/sysconfig/network-scripts/
whenever you want. And give command

# service network restart

Friday, August 1, 2008

Fixing tsocks 1.8 Beta

I was trying to use tsocks 1.8 beta5 on Fedora 8. After installing
I was able to use it. But, on next day, what I found is: I was not
able to access any website, messenger service. Although, I was
able to ping websites. Then I realized the tsocks is interfering
with direct connection to Internet. I was not using ssh tunnel at
that moment.

I have created patch for Makefile and tsocks script.

$ vi patch_Makefile

5c5

< prefix=/usr

---

> prefix=/usr/local

9c9

< libdir = /lib

---

> libdir = ${prefix}/lib

31c31

< CFLAGS = -g -O2 -Wall

---

> CFLAGS = -O3 -Wall



$ vi patch_tsocks
6c6

< # /usr/bin/tsocks program [program arguments...]

---

> # $PREFIX/bin/tsocks program [program arguments...]

13c13

< # /usr/bin/tsocks telnet www.foo.org

---

> # $PREFIX/bin/tsocks telnet www.foo.org

20c20

< # . /usr/bin/tsocks on

---

> # . $PREFIX/bin/tsocks on

22c22

< # . /usr/bin/tsocks off

---

> # . $PREFIX/bin/tsocks off

26c26

< # source /usr/bin/tsocks on

---

> # source $PREFIX/bin/tsocks on

28c28

< # source /usr/bin/tsocks off

---

> # source $PREFIX/bin/tsocks off

33c33

< # /usr/bin/tsocks

---

> # $PREFIX/bin/tsocks

39a40,41

> PREFIX="/usr/local"

>

49c51

< export LD_PRELOAD="/usr/lib/libtsocks.so"

---

> export LD_PRELOAD="$PREFIX/lib/libtsocks.so"

51,52c53,54

< echo $LD_PRELOAD | grep -q "/usr/lib/libtsocks\.so" || \

< export LD_PRELOAD="/usr/lib/libtsocks.so $LD_PRELOAD"

---

> echo $LD_PRELOAD | grep -q "$PREFIX/lib/libtsocks\.so" || \

> export LD_PRELOAD="$PREFIX/lib/libtsocks.so $LD_PRELOAD"

56c58

< export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/usr\/lib\/libtsocks.so \?//'`

---

> export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\$PREFIX\/lib\/libtsocks.so \?//'`

71c73

< export LD_PRELOAD="/usr/lib/libtsocks.so"

---

> export LD_PRELOAD="$PREFIX/lib/libtsocks.so"

73,74c75,76

< echo $LD_PRELOAD | grep -q "/usr/lib/libtsocks\.so" || \

< export LD_PRELOAD="/usr/lib/libtsocks.so $LD_PRELOAD"

---

> echo $LD_PRELOAD | grep -q "$PREFIX/lib/libtsocks\.so" || \

> export LD_PRELOAD="$PREFIX/lib/libtsocks.so $LD_PRELOAD"


How to apply patch and install tsocks?

$ tar -zxvf tsocks-1.8beta5.tar.gz


$ cd tsocks-1.8


$ ./configure


$ patch Makefile < patch_Makefile

$ patch tsocks < patch_tsocks


$ make


$ sudo make install


PS: If you do not find patches working, please mail me
at mitesh[dot]singh[dot]jat[at]gmail[dot]com . I will
send both patches to you.

Monday, July 28, 2008

Finding the Largest and the Smallest File in a Directory

1. In order to find 9 largest files in a directory (say /etc),
please give following command:
$ ls -lS /etc | head

total 2816
-rw-r--r-- 1 root root 600399 2008-07-28 10:11 prelink.cache
-rw-r--r-- 1 root root 362047 2007-04-18 14:10 services
-rw-r--r-- 1 root root 144190 2007-10-12 15:08 lynx.cfg
-rw-r--r-- 1 root root 122098 2008-07-25 10:47 ld.so.cache
-rw-r--r-- 1 root root 117276 2007-09-17 17:57 Muttrc
-rw-r--r-- 1 root root 114765 2007-10-11 01:28 gwen-public-ca.crt
-rw-r--r-- 1 root root 84649 2007-08-23 12:54 sensors.conf
-rw-r--r-- 1 root root 44990 2007-10-16 18:50 php.ini
-rw-r--r-- 1 root root 31274 2007-10-09 14:33 jwhois.conf

2. In order to find 9 smallest files in a directory (say /etc),
please give following command:

$ ls -lSr /etc | head
total 2816
-rw-r--r-- 1 root root 0 2007-08-03 06:09 odbc.ini
-rw-r--r-- 1 root root 0 2000-01-13 04:48 motd
-rw-r--r-- 1 root root 0 2000-01-13 04:48 exports
-rw-r--r-- 1 root root 0 2007-08-16 19:23 environment
-rw-rw-r-- 1 root disk 0 2007-08-22 17:15 dumpdates
-rw-r--r-- 1 root root 0 2007-09-24 19:28 cron.deny
-rw------- 1 root root 1 2007-10-05 17:41 at.deny
lrwxrwxrwx 1 root root 7 2008-07-18 03:26 rc -> rc.d/rc
lrwxrwxrwx 1 root root 10 2008-07-18 03:26 rc6.d -> rc.d/rc6.d

Wednesday, July 23, 2008

Installing Linux (Fedora 8) on Macbook Pro

I was trying to install Linux on Macbook Pro along with Mac OS X, because
it has Intel Processor, Intel chipset on Motherboard
and Nvidia 8600 GT graphics card. I followed steps
given in Debian Wiki (Mainly upto rEFIt part) and
in Mactel (for remaining part).

I would like to suggest some tips regarding installation of
Fedora 8 along with Mac OS X on Macbook Pro.

  1. Audio: Download the latest Linux kernel and compile it with Intel HD Audio drivers 82801H (ICH8 Family).
  2. Video: Boot into new kernel, and install NVidia driver, restart X server by logging out and logging in.
  3. Keyboard: Download pomme daemon, Compile and install it. Now Optical Drive Eject button will work.
  4. Backlight: Even after installing pommed, I was seeing very bright screen. I was not able to stare at screen for more than a minute. Later, after some tweaking of /etc/pommed.conf , I was able to decrease the backlit. I changed init = -1 to init = 1, as shown below:
# nVidia GeForce 8600M GT backlight control (MacBook Pro v3 & v4)
lcd_nv8600mgt {
# initial backlight level [12] (0 - 15, -1 to disable)
init = 1
# step value (1 - 2)
step = 1
# backlight level when on battery [6] (1 - 15, 0 to disable)
on_batt = 6
}

PS: Everything else should work as given in Mactel site. Feel free to write
comments. If you have any doubt, mail me at mitesh[dot]singh[dot]jat[at]gmail[dot]com

Friday, July 18, 2008

What is Pseudo Terminal (PTY)?

Honestly, I did not know about the Pseudo Terminal before facing a problem. I had overwritten /etc/fstab in Fedora 8. As a result, I was not able to open either Terminal or Konsole. The error, I was getting, was:


Not enough permission for PTY device.



Then, I searched Internet for PTY device, there I found the full form of PTY, which is Pseudo Terminal.

Like the /dev directory, /dev/pts contains entries corresponding to devices. But unlike /dev, which is an ordinary directory, /dev/pts is a special directory that is created dynamically by the Linux kernel.The contents of the directory vary with time and reflect the state of the running system.

The entries in /dev/pts correspond to pseudo-terminals (or pseudo-TTYs, or PTYs). Linux creates a PTY for every new terminal window you open and displays a corresponding entry in /dev/pts.The PTY device acts like a terminal device—it accepts input from the keyboard and displays text output from the programs that run in it. PTYs are numbered, and the PTY number is the name of the corresponding entry in /dev/pts.

Then, I searched for how to open Pseudo Terminal with enough permissions.

Solution: Since I had overwritten the /etc/fstab, the entry to

mount devpts was not present. I then created the following entry in /etc/fstab file.


# file_system mount_point type options dump pass

none /dev/pts devpts (rw,mode=620) 0 0