Running a process in background/foreground in linux
Run process in background
To run a command in background, you can use following command at command prompt
Above command will make your process run in background. You need to make sure that process is finished before logging off. A process run by above command will be terminated as soon as you logout.
If you want to run a command in background even after you logout then you can use following command
nohup Run a command immune to hang ups, with output to a non-tty.
This command will run your process in background even if you logs out.
Making current process to run in background
You can make current process as a background process by issuing following commands.
$ bg
You need to remember that the process is running in background, if you logs out then process will be terminated. You can disown to avoid killing the process after you close the terminal.
$ bg
$ disown
Execute following command to run any process in background
You can find process id by issues ps command. It displays the list of currently running process and their process ids. Use ps aux to see all the process currently running on your system including from other users. Use top to get updated list of all the processes running currently.
Run a process in foreground
rpm command – can’t create transaction lock
In case if you are getting error on running rpm command e.g.
$ rpm -e jdk-wrapper-1.5.0_15-1.gdg.noarch error: can't create transaction lock on /var/lib/rpm/__db.000
Installing eclipse in ubuntu/linux
Download eclipse from http://www.eclipse.org/downloads/
Make an opt directory in user’s home directory
$ mkdir ~/opt
Go to the directory where you have downloaded eclipse
$ tar -xvf eclipse-SDK-3.4.1-linux-gtk.tar.gz && mv eclipse ~/opt
Make a bin folder in user’s home directory
$ mkdir ~/bin
Next create an executable for Eclipe at ~/bin/eclipse
$ vi ~/bin/eclipse
Add the following lines in this file
export MOZILLA_FIVE_HOME="/usr/lib/mozilla/" export ECLIPSE_HOME="$HOME/opt/eclipse" $ECLIPSE_HOME/eclipse $*
Finally make script executable
$ chmod +x ~/bin/eclipse
You can now execute that file to start up Eclipse.
<< Back to Setting up j2ee developer environment ...
Installing JDK in ubuntu/linux
To install jdk6.0 type the following command in terminal window
$ sudo apt-get install sun-java6-jdk
Provide password for root. It will show you agreement. Select and wait for installation to be completed.
We should set JAVA_HOME environment variable after successful installation of jdk.
$ vi ~/.bashrc
Insert following line in above file
export JAVA_HOME=/usr/lib/jvm/java-6-sun
<< Back to Setting up j2ee developer environment ...
ifconfig command : Manage network configuration in linux
The most frequent use of ifconfig command is setting an interface’s IP address and netmask, and disabling or enabling a interface.
To see IP address of the machine, open terminal and type ifconfig
It’ll list all the interfaces connected to the device e.g.
root@ubuntu:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:1c:23:a4:ed:b0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:160524 errors:0 dropped:0 overruns:0 frame:0
TX packets:59261 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:40668433 (40.6 MB) TX bytes:14468340 (14.4 MB)
Interrupt:17
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:21240 errors:0 dropped:0 overruns:0 frame:0
TX packets:21240 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3990382 (3.9 MB) TX bytes:3990382 (3.9 MB)
To view a particular interface, provide interface name after ifconfig command.
root@ubuntu:~$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:1c:23:a4:ed:b0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:160524 errors:0 dropped:0 overruns:0 frame:0
TX packets:59261 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:40668433 (40.6 MB) TX bytes:14468340 (14.4 MB)
Interrupt:17
here are few more frequent usages of ifconfig
ifconfig eth0 down
This flag causes eth0 interface to be shut down.
ifconfig eth0 up
If interface eth0 is in the down state then by setting this flag will make eth0 interface active.
ifconfig eth0 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.20
Assign eth0 with the above values for IP, netmask and broadcast address.
Backup of mysql database
Use the following command to get backup of complete mysql database.
shell> mysqldump -u [username] -p[password] –all-databases > [backupfile.sql] –if you want to take backup of selective database then u need to specify database name like shell> mysqldump -u [username] -p[password] –databases [databasename] > [backupfile.sql]
Syntax in above commands are explained below
username – User name of mysql database
password – Password of mysql database
databasename – Name of the database you want to take backup
backupfile – Name of the backup file
http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html
Starting httpd in linux
To start httpd, you need to type following commands
<br> [root@momo ~]# cd /etc/rc.d/init.d/<br> [root@momo ~]# ./httpd start<br>
To test is httpd service is running, type following command
<br> [root@momo ~]# ps -ef|grep httpd<br>
and this will give you results like
<br> apache 2862 2860 0 Aug18 ? 00:00:00 /usr/sbin/httpd<br> apache 2863 2860 0 Aug18 ? 00:00:00 /usr/sbin/httpd<br> apache 2864 2860 0 Aug18 ? 00:00:00 /usr/sbin/httpd<br>
To check if your httpd is installed in the system, type below command in the console
<br> [root@momo ~]# httpd -version<br>