process related commands

For this purpose Use this Command Examples*

To see currently running process ps $ ps

To stop any process by PID i.e. to kill process
kill {PID} $ kill 1012

To stop processes by name i.e. to kill process killall
{Process-name} $ killall httpd

To get information about all running process ps -ag $ ps -ag

To stop all process except your shell kill 0 $ kill 0

For background processing (With &, use to put particular command and program in
background) linux-command & $ ls / -R | wc -l &

To display the owner of the processes along with the processes ps
aux $ ps aux

To see if a particular process is running or not. For this purpose you
have to use ps command in combination with the grep command
ps ax | grep process-U-want-to see


For e.g. you want to see whether Apache web server process is running
or not then give command
$ ps ax | grep httpd

To see currently running processes and other information like memory
and CPU usage with real time updates. top
See the output of top command.
$ top

Note that to exit from top command press q.
To display a tree of processes pstree $ pstree


--

The read Statement

Following script first ask user, name and then waits to enter name
from the user via keyboard. Then user enters name from keyboard (after
giving name you have to press ENTER key) and entered name through
keyboard is stored (assigned) to variable fname.

$ vi testscript
#Script to read your name from key-board
#
echo "Your first name please:"
read name
echo "Hello $name, Lets be friend!"

Run it as follows:
$ chmod 755 testscript
$ ./testscript
Your first name please: vivek
Hello vivek, Lets be friend!

--

Shell Arithmetic

Use to perform arithmetic operations.

Syntax:
expr op1 math-operator op2

Examples:
$ expr 1 + 3
$ expr 2 - 1
$ expr 10 / 2
$ expr 20 % 3
$ expr 10 \* 3
$ echo `expr 6 + 3`

--

to createwa dialog box to dipaly information

1. creat a file called testscript and make it executeable #vi testscript
#
#
# Script to print user information who currently login , current date & time
#
clear
echo "Hello $USER"
echo "Today is ";date
echo "Number of user login " ; who | wc -l
echo "Calendar"cal
exit 0

2. we make a file caled testscritp1 and makke it chmod +x

3. we add the following script to this list
dialog --backtitle "Linux Shell Tutorial" --title "Calender"
--infobox "`./testscript`" 29 25 ; read

4. ./testscript1
--

parameter subsitution

Now suppose we are working in directory called
"/the/path" and I want to copy some samba
files from "/mnt/cdrom/lsoft" to my current working directory, then my
command will be something like

$cp /mnt/cdrom/lsoft/samba*.rmp /the/path

Instead of giving above command I can give command as follows

$cp /mnt/cdrom/lsoft/samba*.rmp `pwd`

Here file is copied to your working directory. See the last Parameter
substitution of `pwd` command, expand it self to
/the/path. This will save my time.

command kudzu

the kudzu command detect all the hardare configuration on your pc and
when ever you add a new hardware and run kudzu the device is written
in /etc/sysconfig/hwconf

--

changing you hostname

#echo www.company.com > /proc/sys/kernel/hostname
#hostname
www.company.com

--

if your locate command is not woking

if you update command is not woking you need to run updatedb at root

#updatedb (enter)

--

how to start MySqt at boot

as root:

cd /etc/rc.d/rc3.d
ln -s /etc/rc.d/init.d/mysqld S98mysql

above was done on fedora 4 which has the same structure as Red Hat.
How does it work? /etc/rc.d/init.d contains scripts to start and stop
services on your computer. By creating a symlink to mysql startup
script in /etc/rc.d/rc3.d you're telling your system to run it during
runlevel 3 startup, which is your regular login. You can also start
and stop your services manually using files in /etc/rc.d/init.d
directly,

--

Other Articles

Enter your email address: