Tanveer’s Weblog

Entries categorized as ‘Linux’

[Tips] MP3 support, DVD playback in Ubuntu

July 19, 2008 · 1 Comment

Some times it is really disturbing after installed a new Ubuntu/Linux and cant play mp3 files. That’s why i need to make a note down here :D

1. MP3 support, DVD playback, Java plugin, and Flash plugin

To install ubuntu-restricted-extras package. In terminal window, command is:

sudo apt-get install ubuntu-restricted-extras

For Kubuntu, command is :

sudo apt-get install kubuntu-restricted-extras

For Xubuntu, command is:

sudo apt-get install xubuntu-restricted-extras

2. Install w32codecs

This non-free multimedia codecs will be used for MPlayer and Xine. To install w32codecs, you can see also here.

3. Install CompizConfig Settings Manager

sudo apt-get install compizconfig-settings-manager

4. Install Opera 9.24

To use commercial repository for Ubuntu 7.10.

sudo gedit /etc/apt/sources.list

Add this line:

deb http://archive.canonical.com/ gutsy partner

After save file, run these commands:

sudo apt-get update
sudo apt-get install opera

5. Clean up Ubuntu

To clean up Ubuntu 7.10, run the following commands:

sudo apt-get autoclean
sudo apt-get clean

Or use:

sudo apt-get autoremove

Done!

Categories: Linux · Tips' n Tricks' · UBUNTU
Tagged:

[Apache] Loopback Interface Testing

July 15, 2008 · 2 Comments

Sometimes it’s really important to test multiple websites on localhost. How we can do that? Very easy! ;) .. Yes we can use different port for each site. Some days ago i found one of the windows hosting server did this for their different users. So we can also be able to to it in apache..

What we need is to initialize the port for each site.. here is an example

We need to edit our httpd.conf file and paste these code in the suitable place

Listen 127.0.0.1:8000
Listen 127.0.0.1:1111
BindAddress 127.0.0.1

Port 1111
Port 8000

ServerName 127.0.0.1

NameVirtualHost *

<VirtualHost *:8000>
DocumentRoot “/home/username/test/example.org/htdocs”
<Directory “/home/username/test/example.org/htdocs”>
Options Indexes FollowSymLinks MultiViews
AllowOverride None

Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:1111>
DocumentRoot “/home/username/test/example.com/htdocs/”
<Directory “/home/username/test/example.com/htdocs/”>
Options Indexes FollowSymLinks MultiViews
AllowOverride None

Order allow,deny
Allow from all
</Directory>
</VirtualHost>

done, now port 8000 is for our development and 1111 is for testing purpose

enjoy ;)

Ref: Security Tips for Server Configuration

Categories: Apache · Linux · Tips' n Tricks'
Tagged: ,

[Linux] Crontab every five minutes

July 8, 2008 · 3 Comments

Well, i want to schedules to run one of my file every 5 minutes. Then what would be the best choose. Yes, CRON.
I can schedule my cron to run that file every five minutes to execute my desired results. Thats why i want to make a note on this regards.

To edit the crontab i use the following command:

$ crontab -e

To list my currnet crontab

$ crontab -l

The following is the format entries in a crontab must be. Note all lines starting with # are ignored, comments.

So in terminal print ‘Hello’ every 5 minutes..


# MIN   HOUR   MDAY  MON  DOW   COMMAND 
   */5     *      *     *    *    echo 'Hello' 
MIN	Minute 	 0-60
HOUR	Hour [24-hour clock] 	0-23
MDAY	Day of Month 	1-31
MON	Month 	1-12 OR jan,feb,mar,apr ...
DOW	Day of Week 	0-6 OR
sun,mon,tue,wed,thu,fri,sat
COMMAND	Command to be run 	Any valid command-line

Examples

Here are a few examples, to see what some entries look like.

#Run command at 7:00am each weekday [mon-fri]
00 07 * * 1-5 mail_pager.script ‘Wake Up’

#Run command on 1st of each month, at 5:30pm
30 17 1 * * pay_rent.script

#Run command at 8:00am,10:00am and 2:00pm every day
00 8,10,14 * * * do_something.script

#Run command every 5 minutes during market hours
*/5 6-13 * * mon-fri get_stock_quote.script

#Run command every 3-hours while awake
0 7-23/3 * * * drink_water.script

Special Characters in Crontab

You can use an

asterisk

in any category to mean for every item, such as every day or every month.

You can use commas in any category to specify multiple values. For example: mon,wed,fri

You can use dashes to specify ranges. For example: mon-fri, or 9-17

You can use forward slash to specify a repeating range. For example: */5 for every five minutes, hours, days
Special Entries

There are several special entries, some which are just shortcuts, that you can use instead of specifying the full cron entry.

The most useful of these is probably @reboot which allows you to run a command each time the computer gets reboot. This could be useful if you want to start up a server or daemon under a particular user, or if you do not have access to the rc.d/init.d files.

Example Usage:

# restart freevo servers
@reboot freevo webserver start
@reboot freevo recordserver start

The complete list:

Entry Description Equivalent To
@reboot Run once, at startup. None
@yearly Run once a year 0 0 1 1 *
@annually (same as @yearly) 0 0 1 1 *
@monthly Run once a month 0 0 1 * *
@weekly Run once a week 0 0 * * 0
@daily Run once a day 0 0 * * *
@midnight (same as @daily) 0 0 * * *
@hourly Run once an hour 0 * * * *

Miscelleanous Issues

Script Output
If there is any output from your script or command it will be sent to that user’s e-mail account, on that box. Using the default mailer which must be setup properly.

You can set the variable MAILTO in the crontab to specify a separate e-mail address to use. For example:
MAILTO=”admin@mydomain.com”

Redirect Output to /dev/null
You can redirect the output from a cron script to /dev/null which just throws it away. By redirecting to /dev/null you will not receive anything from the script, even if it is throwing errors.
* * * * * /script/every_minute.pl > /dev/null 2>&1

Missed Schedule Time
Cron does not run a command if it was missed. Your computer must be running for cron to run the job at the time it is scheduled. For example, if you have a 1:00am scheduled job and your computer was off at that time, it will not run the missed job in the morning when you turn it on.

Related Links
[mkaz.com] At Command Mac OS X and eBay – at is similar to cron but for one time jobs, not reoccuring

Categories: Linux · Tips' n Tricks'

501 Method Not Implemented

May 8, 2008 · 2 Comments

Well, i solved this error in my style. What i did just append these following lines at the end of my apache web server config file (httpd.conf) and restart apache server.

Waoow!!! It solves the problem.

<VirtualHost *:80>
SecRuleInheritance Off
</VirtualHost>

Hope it will save lots of time to others ;)

Categories: Apache · Linux · Tips' n Tricks'

Unix/Linux Command Cheat Sheet

April 27, 2008 · Leave a Comment

Categories: Linux

JAVA Installation in Linux

April 27, 2008 · Leave a Comment

Fedora 8 comes with java icedtea which uses the source code from the OpenJDK project. It is very easy to install it through yum and it works just fine. Try it! If you still want to install the Sun Java go a few lines below.
OpenJDK
To install the java Plugin for Firefox type:

$ sudo yum install java-*-icedtea-plugin
Restart firefox and type about:plugins in the address bar. If the plugin has been successfully installed you should see ‘GCJ Web Browser Plugin’ among the plugins.

If you also want to use javac and java commands for compiling and running java programs type:

$ sudo yum install java-*-icedtea java-*-icedtea-devel
Sun Java
First you must install some libraries needed by Sun’ Java. Open a console and type:

$ sudo yum install compat-libstdc++-33 compat-libstdc++-296

When the libraries are installed create the neccessary links by typing:

$ sudo /sbin/ldconfig
Now click here to go to sun’s java site. You must download the Linux (self-extracting file) not the RPM file.

**Note: The rest of the guide is based on the i586 package. If you have Fedora x86_64 installed you should download the Linux x64 file and replace the file names as neccessary.

**Note: If you also want to compile java programs using Sun’s Java Development Kit Installation you must download Sun’s JDK bin file from here . Go to JDK 6 Update 3, accept the agreement and download the Linux self-extracting file (not the RPM file). The procedure is the same as below. You only have to replace jre1 with jdk1 in the following commands.

Go to the folder you have downloaded jre. Here it will be directory Desktop, Firefox’s default downlad directory.

$ cd ~/Desktop/
And type the following to install (when writting this guide 6u3 was the latest version, replace it with the file you have downloaded if it has changed):

$ sudo mv jre-6u3-linux-i586.bin /opt
$ cd /opt/
$ sudo chmod a+x jre-6u3-linux-i586.bin
$ sudo ./jre-6u3-linux-i586.bin
Use spacebar to read the agreement. At the end type yes to proceed with the installation.

Finally to make Firefox use the installed plugin type:

$ sudo ln -s ./jre1.6.0_03/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so
$ sudo ln -s /opt/jre1.6.0_03/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/firefox-2.0.0.8/plugins/libjavaplugin_oji.so
Restart firefox and type about:plugins in the address bar. If the plugins have successfully installed you should see Java(TM) Plug-in among the plugins.

Now, if you also want to run java programs using Sun’s java type in a console:

$ su -
(Give your root password)
# nano /etc/profile.d/java.sh
In that file copy the following:

export JAVA_HOME=/opt/jre1.6.0_03
export PATH=$JAVA_HOME/bin:$PATH
Next type:

# source /etc/profile.d/java.sh
# /usr/sbin/alternatives –config java
Here you should see something like this:

There are 2 programs which provide ‘java’.
Selection Command
———————————————–
*+ 1 /usr/lib/jvm/jre-1.7.0-icedtea/bin/java
2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
Enter to keep the current selection[+], or type selection number:
Check how many programs provide java and press Ctrl+C. Here I have 2 so in the next command I will use 3 at the end of the command. Increase by one the number of programs that you have.

# /usr/sbin/alternatives –install /usr/bin/java java /opt/jre1.6.0_03/bin/java 3
# /usr/sbin/alternatives –config java
Now you should get something like this:

There are 3 programs which provide ‘java’.
Selection Command
———————————————– *+ 1 /usr/lib/jvm/jre-1.7.0-icedtea/bin/java
2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
3 /opt/jre1.6.0_03/bin/java
Enter to keep the current selection[+], or type selection number:
Select the option you have entered e.g. 3. To test that you have correctly installed java type:

$ java -version
You should get something like that:

java version “1.6.0_03″
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
If at some time you update your Java installation simply remove the old one by typing:

$ sudo alternatives –remove java /opt/jre1.6.0_02/bin/java**Note: Currently there is a bug with Sun Java because it is incompatible with the newer libX11 included in Fedora 8. If you get an error like this xcb_xlib.c:50: xcb_xlib_unlock: Assertion ‘c->xlib.lock’ failed here is the workaround:

For sun-java5-bin:

sed -i ’s/XINERAMA/FAKEEXTN/g’ /usr/lib/jvm/java-1.5.0-sun-1.5.0.11/jre/lib/i386/xawt/libmawt.soFor sun-java6-bin:

sed -i ’s/XINERAMA/FAKEEXTN/g’ /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/i386/xawt/libmawt.soThe same fix (applied to the appropriate file) might work for other proprietary JDKs.

Categories: Linux

Using Official Packages in Linux

April 27, 2008 · Leave a Comment

If you want to stick to the official fedora packages open a terminal and type:

For KDE users:

$ sudo yum install compiz compiz-kde compiz-bcop compiz-fusion compiz-fusion \
compiz-fusion-extras compiz-fusion-extras-gnome compiz compizconfig-python \
libcompizconfig libcompizconfig-devel gnome-compiz-manager kicker-compiz
For Gnome users:

$ sudo yum install compiz compiz-gnome compiz-bcop compiz-fusion compiz-fusion \
compiz-fusion-extras compiz-fusion-extras-gnome compiz compizconfig-python \
libcompizconfig libcompizconfig-devel gnome-compiz-manager

Categories: Linux

Using Unofficial Packages in Linux

April 27, 2008 · Leave a Comment

Some times we can choose to try some unofficial packages. How? This is the way you can..
First download the tar.gz files from the internet and then extract it in a sepperate directory and install them with:

$ sudo rpm -hiv *.rpm
If you use only KDE you must not downlad

compiz-all-0.6.99-1.fc8.i386.rpm
compiz-gnome-0.6.99-1.fc8.i386.rpm
compizconfig-backend-gconf-0.6.99-1.fc8.i386.rpm
compizconfig-backend-gconf-debuginfo-0.6.99-1.fc8.i386.rpm
fusion-icon-all-0.1-100.fc8.noarch.rpm
fusion-icon-gtk-0.1-100.fc8.noarch.rpm
Whereas if you use only Gnome you must not download

compiz-all-0.6.99-1.fc8.i386.rpm
compiz-kde-0.6.99-1.fc8.i386.rpm
compizconfig-backend-kconfig-0.6.99-1.fc8.i386.rpm
compizconfig-backend-kconfig-debuginfo-0.6.99-1.fc8.i386.rpm
fusion-icon-all-0.1-100.fc8.noarch.rpm
fusion-icon-qt-0.1-100.fc8.noarch.rpm
Use yum to resolve dependencies. I also had to install the following packages:

$ sudo yum install PyQt mesa-libGLU-devel libdrm-devel
When the installation completes run fusion-icon and you are ready! An icon should appear at your tray. You can access the ‘Settings Manager’ and the ‘Emerald Theme Manager’ from it easily.

Categories: Linux

Compiz-Fusion

April 27, 2008 · 3 Comments

Compiz-fusion is that cool cube you may have seen in many linux desktop’s screenshots. It is provided through yum but for the time being there are no packages for fusion-icon (a tray icon to control compiz-fusion) and ccsm (compiz settings manager).
git
If you want to install them also you can read my guide on How to compile and install compiz-fusion from git on Fedora 7. The steps should be the same.
Unofficial Repo
If you prefer the easy yum way you can install the following unofficial repository in your system and get the latest compiz-fusion packages. Just type:

$ su -
# wget http://www.dfm.uninsubria.it/compiz/fusion/compiz-fusion.repo -O /etc/yum.repos.d/compiz-fusion.repo

Next you will need to remove the fedora compiz packages first and delete /home/username/.gconf/apps/compiz )

$ su
# yum install compiz-all fusion-icon-all compiz-fusion-plugins-unsupported compiz-bcop ccsm emerald-themesLordMorgui has mirrored the repo so you will need to edit to account for the changes

$ su
# gedit /etc/yum.repos.d/compiz-fusion.repo
and change to

[fusion] name=Compiz Fusion repository
#baseurl=http://www.dfm.uninsubria.it/compiz/fusion/$basearch/
mirrorlist=http://www.dfm.uninsubria.it/compiz/mirror-f$releasever-$basearch
enabled=1
gpgcheck=0
To start compiz-fusion just use fusion-icon. It will place an icon at the tray which contains anything you want to configure.

Categories: Linux

Accessing Windows Shares

April 27, 2008 · Leave a Comment

If you want to access your Windows shared folders through Linux and also to be able to view your videos and listen to your mp3 through your local network install smb4k like this:

$ sudo yum install smb4k
Now run smb4k. Go to Settings -> Configure Smb4K -> Samba and put your workgroup’s name. Press Ok and exit. Now click on the Refresh button and let smb4k to scan your network. If you have iptables firewall running you should set Samba as a trusted service. To do so run Firewall from the start menu or open a terminal and type:

system-config-firewall
Here in ‘Trusted Services’ find ‘Samba’, tick it and press ‘Apply’.

When the shares appear at the left window double click on the one you want. Currently smb4k has a bug with the sudo command. So if you get a message like:

mount error 1 = Operation not permitted Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
open a terminal and type:

$ sudo chmod u+s /sbin/mount.cifs
$ sudo chmod u+s /sbin/umount.cifs
Each time you update smb4k or a samba component you have to run again this command.

Categories: Linux