12 Useful Commands To Check Your Server Health using PuTTY or similar SSH client

You don’t need to install a SSH client if you are using Mac. Just open your Terminal window and you are good to SSH to your server.

As usual, things get a little bit complicated on Windows, You need to install SSH client in order to connect to your server.

PuTTY is an old school but classic software that allow you to remote ssh your server. It’s a free software application for Windows 95, 98, XP, Vista, and 7 which can be used to make an SSH connection to your server.

You can download the application at putty.org

Install the ssh client and connect to your server, run these ssh commands to see how it works!

SSH Goodies that might save your life

SSH Goodies that might save your life

You already know what commands will work for specific scenario and it’s reusable and even automatable…
Read more

 

1. Check the physical free memory of the system

Command:

# top

Check the node to make sure that no single process is consuming all of the available memory.

Check the physical free memory of the system and whether the SWAP free memory meets the requirements.

The screen lists the 15 most active processes that are currently running on the node. For a single process, the CPU usage should be less than 40%. The total CPU usage should be less than 70%.

The memory utilization (real – free)/real should be less than 70%.

2. Check free space of the system hard disk.

Command:

# df –h

The usage of the file system space should be less than 80%.

3. Check  for error messages

Command:

# ntpq -p

A table of system clocks appears. The line representing the system clock currently used by the node is marked with an asterisk (*).

4. Shows processes currently running on the system.

Command:

# ps -ef

Check which processes are running on the server, which user started the process (UID), process ID (PID), and the command that started the process (CMD).

This will output a list of all processes currently running on the system. The PID is important when you wish to “kill” the process, and the CMD is used to start the process again

5. Shows up active TCP connections

Command:

# ps -aux

Similar to “ps -ef” it shows up which TCP connection the server is connecting to. This will output a list of all processes and connections currently running on the system.

6. Compare a remote file with a local file

Command:

ssh user@host cat /path/to/remotefile | diff /path/to/localfile -

Useful for checking if there are differences between local and remote files.

7. How to move into another directory

Command:

cd [another directory]

8. How to go to home directory

Command:

cd ~

9. How to show the full path of the current directory

Command:

pwd

10. How to search for a file starting within current directory

Command:

find . -name [filename] -print

11. How to search for text within a file

Command:

grep

For example:

grep 'word' filename
grep 'word' file1 file2 file3
grep 'string1 string2'  filename

12.  CHMOD – how to change file permission

Command:

chmod [permission type] [file/folder name]

For example: chmod 755 filename

 

More handy SSH commands:

To compress one file or folder to a tar file

tar -cvf archieve.tar file

To compress files or folders excluding some directories

tar -cvf archieve.tar file --exclude "directory"
tar -cvf archieve.tar file --exclude "directory1" "directory2"

To extract a tar file

tar -xvf file.tar

Download a file from server to your computer

scp username@host:/path/to/hosts/file/host_file.txt ~/desktop

IF you are not sure what is the absolute path of your computer, just open a new SSH window, type CD ~, type PWD. This will show you where is your default directory when you use SSH to the server. Simply use scp username@host:/path/to/hosts/file/host_file.txt ~ will download the file to this directory.

Upload a file from your computer to the server

scp ~/desktop/file.txt username@host:/path/to/hosts/folder

It’s just the reverse way of Downloading a file from the server’

Leave a Reply

Your email address will not be published. Required fields are marked *

15 − 1 =

FacebookTwitterInstagramPinterestLinkedInGoogle+YoutubeRedditDribbbleBehanceGithubCodePenEmailWhatsappEmail
×
facebook
Hit “Like” to follow us and stay tuned for the latest posts