Linux


some times you need to copy a file or directory from your machine to another machine using command line, if so you can use the scp command :

suppose that the file needed to be copied /home/mostafa/file.txt, and you have access to the other machine mostafa@nile-sys.com

$ scp /home/mostafa/file.txt  mostafa@nile-sys.com:/home/mostafa/

this command will copy the file.txt to the the path /home/mostafa/file.txt in the remote machine nile-sys.com

also you can copy files between 2 remote machine with the same command as follows:

$ scp mostafa@www.nile-sys.com :/home/mostafa/file2.sh mostafa@ns1.nile-sys.com:/home/mostafa

when you are using tomcat as you application server for not small application you can easy get (out of memory exception). this is because the default heap size tomcat use is small and suitable only for small web applications.

to set the start and maximum heap size run the following command before starting your tomcat:

export CATALINA_OPTS=”-Xms256m -Xmx512m”

or

export JAVA_OPTS=”-Xms256m -Xmx512m”

this will create environment variable called CATALINA_OPTS  or JAVA_OPTS contains the required options to make tomcat start heap size 256M and maximum heap size 512M.

In this post I’ll talk about how to use connection pooling in struts running on tomcat server:

you will need to edit in the following places:

  • META-INF/context.xml
  • WEB-INF/web.xml

first you need to add a context.xml file to your application to be used by tomcat application server when defining and creating your application context.

To do that create a folder called META-INF beside your WEB-INF.

in this folder create file and name it context.xml

open this file and add the following code:

<Context path=”/yourAppPath” docBase=”yourAppDocBase
debug=”5″ reloadable=”true” crossContext=”true”>
<Resource name=”jdbc/resourceName” auth=”Container” type=”javax.sql.DataSource”
maxActive=”100″ maxIdle=”10″ maxWait=”10″
username=”userName” password=”Password” driverClassName=”com.mysql.jdbc.Driver”
url=”jdbc:mysql://localhost:3306/DatabaseName?autoReconnect=true”/>
</Context>

replace names in Bold with your application parameters resourceName is the name of the datasource that you will use. the previous code creates a new database resource on your application context.

now you need to create a reference to the created resource. edit your web.xml and add the following code:

<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/resourceName</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

replace names in Bold with your application parameters.

now you only need to know how to get the datasource from your code:

Context ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup(“java:comp/env/jdbc/resourceName“);

Connection connection = ds.getConnection();

and you can enjoy using the new connection

I wish that I made this topic clear and I’ll be happy to receive your comments and questions.

Hello every one,

few days ago my ubuntu machine started to give me this error every  time i login:

ISD-Server could not start because port 5800 is not available.

i google it but didn’t found a good solution but after while i found one from ubuntu forum:

ica is part of italc.sourceforge.net and it is installed on my machine when i installed edubuntu.

and to stop getting this error message here is what i did:

$sudo apt-get remove libitalc italc-client italc-master

and i never see the error message again.

here is the thread which i found the solution in:

http://ubuntuforums.org/showthread.php?t=749394&page=2

sometimes i needed for a desktop dictionary on ubuntu linux, now i found how to setup the arabic dictionary in the linux Dictionary:

for gnome :

- open Applications Menu -> Accessories -> Dictionary.

- the Dictionary application is opened. now click edit menu and select Preferences.

- in the source tab click Add button.

- A new window opened, in the Description field write: Arabic Dictionary. or whatever you want to name it.

- let Transport select box as Transport.

- Hostname : dict.arabeyes.org

- Port: 2628

now enjoy using the desktop dictionary.

now i’ll explain how to install ubuntu without using cdrom and with a usb flash memory:

a usb flash memory by default is formatted in vfat file system, i will not change the file system type.

- first you need to create a master boot record in the flash memory

$ sudo parted /dev/sdb set 1 boot on

you need to change sdb to you usb device, you can know what is the link to your device from the command mount

now you have a bootable usb storage device all what you need next is to copy the kernel and init parameters file in the suitable place in your flash memory.

- create a directory named casper in root of your flash memory.

- download the following files and put them in the directory named casper

1- http://archive.ubuntu.com/ubuntu/dists/hardy/main/installer-i386/current/images/hd-media/vmlinuz

2- http://archive.ubuntu.com/ubuntu/dists/hardy/main/installer-i386/current/images/hd-media/initrd.gz

- get the iso image which will be used to install ubuntu, you need to download the alternative CD not the normal cd.

- extract the iso image and copy the folder isolinux from the extracted iso to the root of usb flash memory.

- rename the isolinux folder in the root of the flash memory to syslinux.

- inside the syslinux folder rename the file isolinux.cfg to syslinux.cfg

- copy the alternative cd iso image -not the extracted folder- to the folder casper on the flash memory.

everything now is fine and you can reboot that machine and boot from the usb flash memory then install ubuntu.

enjoy.

Today, when i was trying to install some packages i got this error:

dpkg: parse error, in file `/var/lib/dpkg/status’ near line 14938 package `human-theme’:
`Replaces’ field, invalid package name `
E: Sub-process /usr/bin/dpkg returned an error code (2)

i googled it to search for a know solution but got nothing useful this time. so i decieded to think a little bit and try to solve it my self. and here is the solution i got.

i open the file which through the parse error:

# gedit /var/lib/dpkg/status

then i visited the line which given to has the problem and found the name of package has some encoded characters so i removed the non understandable characters and saved the file.

then:

#apt-get -f update

every thing after that went ok. and i enjoyed my ubuntu again.

Salam all,

this about how to convert a flac audio file to a mp3 format to gain the size reduce

you need to have the following packages installed: flac , lame

for ubuntu you can install them by:

$ sudo apt-get install flac lame

for defora

# yum install flac lame

then to convert a flac file to mp3

$ flac -cd filename.flac | lame -h – filename.mp3

this post is bout how to use the screen command to connect multiusers to the same screen:

first you need to create a new screen and give it a name:

# screen -S screenName

if you want to have multi users able to connect to it, so you need to enable the multiuser mode:

press Ctrl+a

you will find screen command line appears at the bottom of the screen, then type

:multiuser on

and press enter

now you screen is running in multiuser mode and ready to accept other connection

to attach to this screen:

# screen -x screenName

to create a new SVN repository it is an easy task :

  • first you need to have the subversion installed in your machine :
  • fedora :

# yum install subversion

  • ubuntu :

# apt-get install subversion

  • now you have subversion installed and ready to create your repository:

# svnadmin create /path/to/repository/folder

Next Page »