5 Most useful linux commands to test connectivity

Most useful linux commands to test connectivity

5 Linux commands to test connectivity

  1. Ping Command: It is used to check the source host reachability to the destination host.

Syntax:

ping <IP>

Example:

ping google.com OR ping 10.10.0.21

2. Traceroute Command: It is used to see all the hops in between the source and destination hosts

Syntax:

Unix: traceroute <ip> OR traceroute -p <destination_port> <destination_ip>

Windows: tracert <ip>

Example:

traceroute 10.10.0.21
traceroute - p 10.10.0.21 3868

3. Nslookup command: It is used to get information from the Domain Name System (DNS) server. Its helpful to obtain the domain name or IP address mapping or any specific DNS record.

Syntax:

nslookup <domain/IP>

Example:

nslookup techCruds.com OR nslookup 10.10.0.21

4. Telnet command: It is used to check if your host is able to connect to destination host using telnet protocol which is part of TCP/IP protocol suite.

Syntax:

telnet -s <src_ip> <dest_ip> <dest_port>   OR
telnet <dest_ip> <dest_port>

Example:

telnet -s 10.10.0.21 12.34.12.21 3868       OR
telnet 12.34.12.21 3868

5. Curl Command: It is used as a tool to retrieve information from Uniform Resource Locator (URL) or an IP. This tool is not by default installed in your linux machines but need to install externally using below command:

sudo apt-get install curl

Syntax:

curl --insecure <dest_ip/domain>:<dest_port>

Example:

curl --insecure google.com      OR
curl --insecure 172.10.x.x:8080

Also curl command can be used in different way as below:

curl -k -v -X POST --header 'Content-Type: application/json' --header 'Accept:application/json'  -d '<api_request_in_json_format>' <API_URL_to_be_triggered>

Other useful Linux commands:

  1. Cat command:
    It is used to read the content of the file without opening it in editor.
    Syntax:
cat <file_name>

If file is very bigger and doesnot fit the screen you can use “| less” to scroll up and down on screen.

Syntax:

cat <file_name> | less

You can also search for any text from Top or from Bottom using below expressions:

From Top:

> cat <file_name> | less

/<text_to_search>

From Bottom:

> cat <file_name> | less
(go to end of file using END button on laptop)
?<text_to_search>

2. cd command:
It changes your current directory:
Syntax:

 cd <directory_name>

Example:

Cd /folder/subFolder

To go to home directory simple use below command:
cd ~

To go one level up:
cd ..

To go to folder which is one level up:
cd ../SubFolderName

3. chmod command:
It is used to set file permission flags on a file or folder. It has read, write or execute permissions as below:

Pattern:

-rwxrwxrwx

From above,

  1. 1st 3 characters represent permissions for owner.
  2. 2nd/middle 3 characters represent permissions for group.
  3. Last 3 characters represent permissions for others.

If you don’t want to give specific permission then use “-“.
For example, -rwxrwxrw-
Here, we are not giving write permission to others.

Other way to use chmod is to give permission using 3 digit number.
Where digit representations are as below:

Left digit - owner
Middle digit - group
Right digit - others

And digit values significance is as below:
0: No permission
1: Execute permission
2: Write permission
3: Write and execute permissions
4: Read permission
5: Read and execute permissions
6: Read and write permissions
7: Read, write and execute permissions

So, now we can set permission as below for any file or folder:
Example:

chmod 765 techCruds.txt

Where,
7 for owner
6 for group &
5 for others

4. scp command:
It is used to securely copy file/s or directory/s from one location to another.

  1. From your local to remote system
  2. From remote to your local system
  3. Between two remote systems from your local system

Syntax:

scp [options] [user@src_host:]file  [user@dest_host:]file

Where Options are,
-P – Specifies the remote host ssh port.
-p – Preserves files modification and access times.
-q – Use this option if you want to suppress the progress meter and non-error messages.
-C – This option forces scp to compresses the data as it is sent to the destination machine.
-r – This option tells scp to copy directories recursively.

Example:

scp -r techCruds.text adminuser@10.10.0.21:/home/adminuser/

5. find command:
It is used to find specific file or file with any extensions inside specific path or inside any folder structure.

Syntax:

find <path> - name <file_name>/<file_extension>

Example:

find . - name thisfile.txt
find ./techCruds - name *.txt

6. netstat command:
It can be used to check if specific port or IP is being used for not.

Syntax:

netstat -an | grep <port>/<IP>

Example:

netstat -an | grep 2368
netstat -an | grep 20.18.8.23

Ajax apple certificate signing apple keystore basic crud operations in nodejs certificate expiration certificate expiration date check command certificate import command configuration connectivity test Content-Type crud operations CSR creation command import certificate command jks jks create command jks file keystore keytool commands Laravel linux commands linux commands to test connectivity nodejs openssl command signing csr command ssl certificates timezone truststore

Other Articles related to Linux commands:

SSL Certificate 3 most useful commands: Create, Import and Signing CSR

Top 15 useful Keytool commands

External Links related to Linux commands :

Ubuntu Tutorials

Share via
Copy link
Powered by Social Snap