Showing posts with label Troubleshoot. Show all posts
Showing posts with label Troubleshoot. Show all posts

Saturday, September 20, 2008

(wget = DM) != GUI

Wget the default download manager in *nix systems is a very versatile tool. I will be focusing on some of its very important features useful to a end user. So here we begin :

  1. Simply downloading a file :
    $ wget <URL>
    Or better :
    $ wget -c <URL>
    -c or --continue lets you resume your incomplete download done using wget or a different program

  2. Downloading a file silently (a very imp. feature in wget, to work in background) :
    $ wget -q <URL> &
  3. Taking a log of all messages :
    $ wget <URL> -o filename
  4. Downloading files from a Queue :
    $ wget -i filename
    Strore all download links in a file separated by Return key and link it with wget
  5. Set your no. of retries and timeout seconds :
    $ wget -t <no. to tries> -T <duration> <URL>
  6. Displaying the content of a file rather than saving it on Hard Disk :
    $ wget -O - <URL>
  7. Retrieving all file with a particular extension from a web directory :
    $ wget -r -l1 -np -A.<extension> <directory>
    Example for http://www.abc.com/def/*.jpg
    $ wget -r -l1 -np -A.jpg http://www.abd.com/def/
  8. Downloading an entire Web Site :
    $ wget -c -r -nc -p -D <domain> -k <URL>
    For this I have written a script for easy downloading :
    #!/bin/bash

    # Bash Script for Web Site downloading by GNUger
    # Syntax : $ sitesdwn [URL]

    command="wget -c -r -p -k"
    domain=$(echo $1 | cut -d/ -f3 | cut --complement -d. -f1)

    echo
    read -p "Download within $domain only (y/n) : " opinion
    if [[ $opinion == 'y' ]] ; then
    command="$command -D $domain"
    fi
    read -p "Disable overwriting existing files (y/n) : " opinion
    if [[ $opinion == 'y' ]] ; then
    command="$command -nc"
    fi
    read -p "Download outside the current directory (y/n) : " opinion
    if [[ $opinion == 'n' ]] ; then
    command="$command -np"
    fi
    read -p "Save as HTML extension (y/n) : " opinion
    if [[ $opinion == 'y' ]] ; then
    command="$command -E"
    fi
    read -p "Enable compatibility with Windows (y/n) : " opinion
    if [[ $opinion == 'y' ]] ; then
    command="$command --restrict-file-names=windows"
    fi
    echo "Downloading ... "
    echo
    $command $1
    echo
    echo "End"
    exit 1
    fi
    Or download the script from here. Syntax :
    ./sitedwn.sh <URL>


This is not it.. there's hell lot more but beyond the scope of this post. So just read the Manuals (worth reading specially the Examples part). There are GUI version for wget :
  • GWget - For Gnome
  • Kget - For KDE
But they does not provide you so many options and manual customizations as wget (CLI) does.

References : man pages of wget, Linux Journal

Wednesday, July 30, 2008

Ubuntu getting slow....

The day I installed Ubuntu and the day after few upgrades.. I noticed drastic decrease in speed. I thought the problem was with my user, so I deleted the configuration files within my ~/ folder many times but never got a preferred result. Nautilus took 10-20 sec to just open, furthermore my gnutop went indiscoverable in my Hostel's LAN Server and I was receiving error messages after login. The symptom which took me towards the solution to this problem was, I got this message everytime I used sudo :
sudo: unable to resolve host HOSTNAME
After a bit of googling I found that it was already reported : Bug #195308.

Here is the solution (if it ever happens to you):
  • Open Terminal
  • Edit your /etc/hosts file
    sudo vim /etc/hosts

  • There replace :
    127.0.1.1 hostname.domainname
    with
    127.0.1.1 hostname

    Example in my case:
    Hostname : gnutop
    Domainname: workgroup

  • Save and Exit

This worked for me as a charm and thought of removing Ubuntu remained a thought.. now Ubuntu is as fast as ever.

Saturday, June 28, 2008

File transfer to/from Mobile Phone

With new distros its very simple to do file transfer using bluetooth. Just a matter of few clicks :
  1. Insert your Bluetooth Dongle, and a bluetooth icon will appear in the notification area, otherwise start your bluetooth service by executing : bluetooth-applet

  2. Right click on that icon and Browse Device > Select your Mobile > Connect

  3. If your device is not paired up, it will pop up pairing up menu on your phone and then on your PC. Then it will mount your phone's directory on your computer which you can browse using a Nautilus.

Else there is a geekier way too using CLI based obexftp :
  1. Discover your mobile's MAC address and its channel for Object Push
    $ obexftp -b

  2. Browse your phone's directory
    obexftp -b mac address -B channel -l
    You can also change the current directory to browse its content
    $ obexftp -b mac address -B channel -c directory -l
    NOTE: Replace mac address, channel & directory with your own value

  3. Now upload file :
    $ obexftp -b mac add -B channel -c phone directory -p file
    And retrieve file :
    $ obexftp -b mac add -B channel -c phone directory -g file

For more on Bluetooth check this page

Saturday, June 21, 2008

Webcam and MPlayer

Ubuntu really shocked me today when it recognized my integrated webcam automatically, which I discovered via Ekiga application.. Ok so drivers set, what I need now is record videos and take snapshots.. Mplayer as the title indicates does this all, the versatile player which can load video devices too. Lets begin with our task :


Viewing :


Fireup this command to bring up your video streamer:
$ mplayer -fps 15 tv:// -tv  driver=v4l2:device=/dev/video0

You can replace your video fps(frames per second), device and driver value as per your convenience.

Specify the video dimensions :
$ mplayer -fps 15 tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0

Horizontally inverse the stream i.e. mirror effect :
$ mplayer -vf mirror -fps 15 tv:// -tv  driver=v4l2:device=/dev/video0

View Fullscreen :
$ mplayer -aspect 16:10 -fps 15 tv:// -tv  driver=v4l2:device=/dev/video0
$ mplayer -aspect 16:10 -vf mirror -fps 15 tv:// -tv driver=v4l2:device=/dev/video0

Then press 'f' key to enter Fullscreen. NOTE: Enter aspect value as per your screen resolution ratio eg. 4:3, 16:9, 1:1


Snapshots:


Take snapshots while streaming by pressing 's' :
$ mplayer -vf screenshot -fps 15 tv:// -tv  driver=v4l2:device=/dev/video0

Mirrored :
$ mplayer -vf mirror,screenshot -fps 15 tv:// -tv  driver=v4l2:device=/dev/video0

The files will be saved in your current directory with name "shot####.png", where #### is for index number.


Video Capturing:


For video capturing you will need a companion of mplayer named "mencoder", install it if you don't have one. So here is the way you start your recording:

Without sound:
$ mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -nosound -ovc lavc -o filename.avi

With sound:
$ mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0:forceaudio:adevice=/dev/dsp -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o filename.avi

You can combine other subtags like vf, aspect, fps to enhance your video.

This is all, you can try a different short program too for video/photo capturing : VideoView.

This post took from me a lot of manual reading and googling but am happy to present it before you. Here are the major sources : Gentoo Wiki, Mencoder -vf and mplayer manuals.

Thursday, June 5, 2008

Formatting USB Drive with Linux

This is a guide to format a Thumb drive in Linux. After a bit of Googling I got mkfs, which is used to build a Linux file system on a device. Now for thumb drive we use FAT32 or VFAT filesystem, so we use mkfs.vfat instead.

Syntax (quick format) :
# mkfs.vfat -F32 {device}

For Fedora/RedHat based :
 # /sbin/mkfs.vfat -F32 {device}


I have made a script for easy formatting :

1> Open Terminal :
$ nano format.sh

2> Paste this and save :
#!/bin/bash
# Bash Script for formatting USB drives by GNUger

if [[ $EUID -ne "0" ]]
then
echo "You must be root"
exit 1
fi

device=$(df | tail -n1 | awk '{ print $1; }')
read -p " Is device ($device) correct(y/n) : " opinion1
if [[ $opinion1 == 'n' ]] || [[ $opinion1 == 'no' ]]
then
read -p "Enter device name : " device
fi
echo
echo "Formatting : $device"
echo
read -p "Proceed with formatting(y/n) : " opinion2
if [[ $opinion2 == 'y' ]] || [[ $opinion2 == 'yes' ]]
then
umount $device
read -p "Volume label : (Enter for none) " label
if [[ ${#label} == 0 ]] ; then
/sbin/mkfs.vfat -F32 $device
else
/sbin/mkfs.vfat -F32 -n "$label" $device
fi
exit 1
fi

Attached the file here

3> Then allow the file to execute:
$ chmod +x format.sh

4> Insert your thumb drive and execute :
# ./format.sh


You can also use GParted for formatting and resizing.

Sunday, May 25, 2008

Mplayer : Universal Media Player

Since mplayer is the only multimedia player on my PC other than Amarok, so I will obviously want it to work with each and every media file I have or may encounter and mplayer did all its work with 100% perfection till one day when I tried to play .rm/.rmvb files with it.. So what next, install a separate player for that? Never..the solution is more simple than anyone can expect :

1> If you have not installed the codecs for mplayer then download them from here or mirrors. Extract the contents and copy them to /usr/lib/codecs directory.

2> Now for enabling Real Player support, download this or mirror, extract the contents to the above mentioned folder.
Note: For copying files to /usr/lib/codecs u will need administrative rights (sudo)

TIP:
For opening any file with mplayer (CLI), Right Click File > Properties > Open with > Add > xterm -e mplayer > Click on "Always open with same application". This is quite fast and handy.

Saturday, May 24, 2008

Enabling/Disabling 'sudo' for Local User(s)

Fedora/RedHat based distros doesn't give sudo power to local users by default, So its the root who grants them the power. Here's a way:

1> Open Terminal / Konsole and then login as root :
$ su -

2> Change the permission of /etc/sudoers to read-write mode :
# chmod u=rw /etc/sudoers

3> Open the file using a texteditor (I am using vim) and search for :
# vim /etc/sudoers

## Allow root to run any commands anywhere
root ALL=(ALL) ALL
Below that add (by i in vim) this:
username ALL=(ALL) ALL
Note: Here you can add or remove users and may have more than one user

4> Save and close the file ( Q then wq in vim) and change permission back to default :
# chmod u=r /etc/sudoers

Alternatively you can also go for :
$ su -c /usr/sbin/visudo
It will open sudoers file in rw mode in vim editor