≡ Menu

ps command

UNIX / Linux: awk Add Two Numbers

How do I add two numbers using awk? How do I calculate all incoming number stream on fly and display the total using awk?
[click to continue…]

Where Are MySQL Files Stored in UNIX / Linux

Where are my mysql database and table files are stored in UNIX or Linux operating systems?
[click to continue…]

Warning: bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.7/FAQ

I am a new Unix/Linux command line bash/ksh/tcsh user. I was told to use the following ps command:

ps -auxf | sort -nr -k 4 | head -10

And I get the output along with warning message that read as follows:

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ

How do I fix this problem?
[click to continue…]

sshpass: Login To SSH Server / Provide SSH Password Using A Shell Script

How do I login over ssh without using password less RSA / DSA public keys? How do I use ssh in a shell script? How do I login non-interactivly performing password authentication with SSH and shell scripts?
[click to continue…]

How To Tell If Your Linux Server Uses xinetd OR inetd sever

Q. How to tell if my Linux server is using xinetd or inetd service?
[click to continue…]

Linux / UNIX: List Open Files for Process

Q. How do I list all open files for a Linux or UNIX process using command line options?
[click to continue…]

How to: Find Out Whether a UNIX / Linux Process Is Running or Not

Q. I'd like to find out if httpd / mysqld or sshd process is running or not under CentOS Linux server. How do I determine whether a process is running or not?

A. You need to use following commands:

[a] ps - It report a snapshot of the current processes

[b] grep - Filter out process names

Find out if sshd is Process is Running or Not

Type the following command at shell prompt:
$ ps -ewwo pid,args | grep [s]sh

5341 /usr/sbin/sshd
 5864 /usr/bin/ssh-agent x-session-manager
 6289 ssh oldbox
 7126 ssh admin@core.r1.vsnl.router


  • ps : Command name
  • -ewwo pid,args : -e option force to select all running processes. -o option is used to specify user-defined format. In our case we are forcing to display only program pid and its arguments. Finally -w option specifies wide output. Use this option twice for unlimited width.
  • grep [s]sh : We are just filtering out sshd string

Killing processes in UNIX

Q. Sometime I need to stop a command or task under UNIX. I also noticed that some process will ignore my keystroke-generated signals such as CTRL + C or CTRL+D, so my question is – How do I kill process in UNIX?

A. You need to use a command called kill. The kill utility sends a signal to the processes specified by the pid operand(s). Only the super-user (root) may send signals to other users' processes.

kill command syntax

The kill command causes the specified signal to be sent to the specified process. The kill command has the general form as follows:
kill -N PID

  • N is a signal number
  • PID is the Process Identification Number. If you do not know the PID, it can be learned through the ps command.

Understanding signal numbers

The signal number 1 is a hangup signal. I recommended using 1 signal because it should kill the process and it can save the buffer (if supported). For example if it is an editor, save the buffer. This is the default if you do not specify a signal number. Signal number 9, a kill signal, is the surest way to kill a process.

Some of the more commonly used signals:

signal #Usage
1 HUP (hang up)
2 INT (interrupt)
3 QUIT (quit)
6 ABRT (abort)
9 KILL (non-catchable, non-ignorable kill)
14 ALRM (alarm clock)
15 TERM (software termination signal)

How do I use kill command?

Terminate the processes with pids 1412 and 1157:
$ kill 1412 1157
Send the hangup signal (SIGHUP) to the process with pid 5071:
# kill -s HUP 5071
Terminate the process group with pgid 12117:
# kill -- -12117
If you do not know the PID of a process, you can learn it by issuing a process status command, ps.
# ps | more
# ps | grep file.c
# ps | grep -i httpd

To send -9 (KILL) singal to the processo with pid 1234, enter:
# kill -9 1234

Linux / UNIX: Find out or determine if process pid is running

How do I find out my process is running on a Unix-like operating systems? How do I get the pid number for particular process on a Linux operating systems using bash shell?
[click to continue…]

grep in Bash

How do I use grep command in Bash?
[click to continue…]