Linux Process Management from Command Line

1. Log into your server via SSH: (If you're not sure how to do that, there is a SSH HowTo here)

2. Once you're logged into your server, at the command prompt type: 
 

#ps -auxw 
OR
#top
<enter>
3. Once you see the list of processes that are running on your server, look in the CPU column and see which process is using the highest amount of your CPU.

4. Once you find this process, look all the way to the left of that same line and you'll see a number that is called the PID which stands for "Process ID" (make note of the number). You want to kill this process by following these steps:

While you have top running, hit your k key. By hitting the k key, you will now see: Kill PID 823 with signal [15]:

Example:

Cpu(s): 4.0% user, 1.4% system, 0.0% nice, 94.6% idle
Mem: 1033504k total, 723376k used, 310128k free, 94012k buffers
Swap: 2000084k total, 0k used, 2000084k free, 231276k cached
PID to kill:


Now enter the PID number of the process you want to kill.

<enter>

Type y for yes.

<enter>

~~~~~~~~~~~~~~~~~~~~~~~~~~~

Another method of killing a process is as follows:

# ps aux | grep name_of_process
At the command line type: kill -9 PID_Number_Here
You can also type:
# killall -9 name_of_process which will kill any process with that name.

<enter>
The -9 will ensure "execution".
 
The ps commands discussed so far only list processes that were started from your terminal session
[root@localhost ~]# ps -af
UID        PID  PPID  C STIME TTY          TIME CMD
root      2605  2377  0 21:35 tty5     00:00:00 top
root      3140  2663  0 21:53 pts/1    00:00:00 ps -af 
 
The ps program will display all the processes running and their PID 
numbers and other information. 
 
To see a long format of the processes in your login session, use: 
[root@localhost ~]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S     0  2663  2661  0  75   0 -  1135 wait   pts/1    00:00:00 bash
4 R     0  3724  2663  0  78   0 -  1054 -      pts/1    00:00:00 ps
 


[root@localhost ~]# ps ux
killall [process name]
killall -KILL [process name]
killall -SIGKILL [process name]
killall -9 [process name] 
kill -s KILL [PID]
kill -KILL [PID]
 
To display a long format of all the processes in the system, use the following:
[root@localhost ~]# ps -Al
Type the following ps command to display all running process:
[root@localhost ~]# ps aux | less

To see every process on the system :

# ps -A
# ps -e

To See every process except those running as root :

# ps -U root -u root -N

To See process run by user vivek :

# ps -u vivek

The top program provides a dynamic real-time view of a running system. Type the top at command prompt:

# top

Output:

Fig.01: top command: Display Linux Tasks
Fig.01: top command: Display Linux Tasks

 

display a tree of processes

$ pstree

Sample outputs:

Fig.02: pstree - Display a tree of processes
Fig.02: pstree - Display a tree of processes

Task: Print a process tree using ps

# ps -ejH
# ps axjf

Task: Get info about threads

Type the following command:
# ps -eLf
# ps axms

Task: Get security info

Type the following command:
# ps -eo euser,ruser,suser,fuser,f,comm,label
# ps axZ
# ps -eM

Task: Save Process Snapshot to a file

Type the following command:
# top -b -n1 > /tmp/process.log
Or you can email result to yourself:
# top -b -n1 | mail -s 'Process snapshot' you@example.com

Task: Lookup process

Use pgrep command. pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to screen. For example display firefox process id:
$ pgrep firefox
Sample outputs:
3356
Following command will list the process called sshd which is owned by a user called root:
$ pgrep -u root sshd

Say hello to htop and atop

htop is interactive process viewer just like top, but allows to scroll the list vertically and horizontally to see all processes and their full command lines. Tasks related to processes (killing, renicing) can be done without entering their PIDs. To install htop type command:
# apt-get install htop
or
# yum install htop
Now type the htop command at the shell prompt:
# htop
Sample outputs:
Fig.03: htop - Interactive Linux / UNIX process viewer
Fig.03: htop - Interactive Linux / UNIX process viewer (click to enlarge)

atop program

The program atop is an interactive monitor to view the load on a Linux system. It shows the occupation of the most critical hardware resources (from a performance point of view) on system level, i.e. cpu, memory, disk and network. It also shows which processes are responsible for the indicated load with respect to cpu- and memory load on process level; disk- and network load is only shown per process if a kernel patch has been installed. Type the following command to start atop:
# atop
Sample outputs:
Fig.04: Atop Command in Action
Fig.04: Atop Command in Action

 

Running the command below will list all running processes on the system.
ps aux
Now, we use the "grep" command to filter out the process we are looking for.
ps aux | grep <process_name>
Replace <process_name> with the name of the process you want to search for. The command above will list all the lines from the output of "ps aux" that contain the string specified with the "grep" command.
For example, if you want to find if Apache Web Server is running or not. You'll run the command as follows:
ps aux | grep httpd
if the output shows some lines with httpd then that means Apache Web Server (or some process with the name "httpd") is running.

 

 


outlook email error troubleshooting

ERROR: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)

Symptoms And Errors:When attempting to send a email using your 3Essentials hosting account, your email client may report the following error message:
"553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)"

The full error message may appear as:
The message could not be sent because one of the recipients was rejected by the server. The rejected e-mail address was 'emailaddress@domain.com'. Subject 'Email Subject', Account: 'Your Account Name', Server: 'mail.yourdomain.com', Protocol: SMTP, Server Response:
'553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)', Port: 25, Secure(SSL): No, Server Error: 553, Error Number: 0x800CCC79
However, receiving email works correctly.
Cause:This error message is reported by your email client such as Outlook or Outlook Express because the check box labeled "My Server Requires Authentication" is not checked.  Your email client attempts to send the email to the server without providing a password, hence the server replies that you are not allowed to relay without proper authentication.
Resolution:To resolve this issue check the checkbox next to "My Server Requires Authentication"
Outlook Express: (reference image below)
Open Outlook Express > Click Tools > Accounts > Click the 'Mail' Tab > Click Properties > Click The 'Server' Tab
check the checkbox next to "My Server Requires Authentication"
Click Ok > Click Close


Outlook 2003 (reference image below)
Open Outlook 2003 > Click Tools > E-Mail Accounts > View or change existing e-mail accounts
Select the email account > Click Change > Click 'More Settings' > Click the 'Outgoing Server' Tab
Check the checkbox "My outgoing server (SMTP) requires authentication"
Click OK > Next > Finish

 

Necessary Command for Linux

# cat /etc/passwd |grep 500*
For Linux DNS Cache Clear:
# Service nscd restart
# /etc/init.d/nscd restart 

ian@attic4:~$ uptime
 17:41:17 up 20:03,  5 users,  load average: 0.00, 0.00, 0.00
The free command displays the amount of free and used memory in your system. By default the display is in kilobytes, but you can override this using -b for bytes, -k for kilobytes, -m for megabytes, or -g for gigabytes. The -t option displays a total line, and the -s option along with a value refreshes the info with the frequency specified. The number is in seconds but may be a floating point value. Listing 15 shows two examples.


ian@attic4:~$ free
             total       used       free     shared    buffers     cached
Mem:       4057976    1543164    2514812          0     198592     613488
-/+ buffers/cache:     731084    3326892
Swap:     10241428          0   10241428
ian@attic4:~$ free -mt
             total       used       free     shared    buffers     cached
Mem:          3962       1506       2456          0        193        599
-/+ buffers/cache:        713       3249
Swap:        10001          0      10001
Total:       13964       1506      12457
 

How to clear DNS cache

To flush DNS cache in Microsoft Windows (Win XP, Win ME, Win 2000):-
- Start -> Run -> type cmd
- in command prompt, type ipconfig /flushdns
- Done! You Window DNS cache has just been flush.
To flush the DNS cache in Linux, restart the nscd daemon:-

- To restart the nscd daemon, type /etc/rc.d/init.d/nscd restart in your terminal
- Once you run the command your linux DNS cache will flush.
To flush the DNS cache in Mac OS X Leopard:-
- type lookupd -flushcache in your terminal to flush the DNS resolver cache.
ex: bash-2.05a$ lookupd -flushcache
- Once you run the command your DNS cache (in Mac OS X) will flush.
To flush the DNS cache in Mac OS X:-
- type dscacheutil -flushcache in your terminal to flush the DNS resolver cache.
ex: bash-2.05a$ dscacheutil -flushcache
- Once you run the command your DNS cache (in Mac OS X Leopard) will flush.

SNMP configuration for windows 7

Once you have installed IsItUp, you need to install and configure the Windows SNMP service on the target system.  If you have already installed SNMP, please go to step 9 to setup monitoring a service.  The steps to install Windows SNMP are similar for all versions of windows however, the following screen shots are for Windows 7.



1.      Select “Control Panel” from the start menu.

   

2.      Select “Programs” from the control panel.




3. Select the “Turn Windows features on or off” link from the control panel.







 

3.      Check the “Simple Network Management Protocol (SNMP)” checkbox on the Windows Features Dialog box.




4.      Once Windows completes the installation, you need to configure the service.  Select the Start Menu and then enter “services.msc” in the search box and press return.




5.      Select the SNMP services from the list and double click.

  





6.      Select the “General” tab and make sure the service is set to “Automatic”.







  
7.      Select the Security Tab and click the “Add” button to set a “READ-ONLY” community string. Record this string as you will need it when configuring IsItUp in Step 9.  Then either select the “Accept SNMP packets from any host” or “Accept SNMP packets from these hosts” and specify the computer that IsItUp is running on.


















 

 





8.      Optional:  If you need to change the default SNMP port, open the windows “Services” file located at “C:\Windows\System32\drivers\etc\Services.” with any editor such as Notepad.   You can change the port to anything you like but the computer must be restarted for the change to take effect.