Networking Commands Miscellaneous Commands

Network Connectivity

ping
checks the network connectivity between host and server/host.

Syntax :

ping hostname/IP address

Example :

ping google.com

Route Path

traceroute
prints the route that a packet takes to reach the host.

Syntax :

traceroute host_address

Example :

traceroute google.com

Network Interface

A network interface is a software interface to networking hardware.

Different types of network interfaces are:

  • Ethernet

  • Loopback etc.

Information About Network Interfaces

ifconfig

ifconfig
gives you the information of various network interfaces.

ifconfig

Ethernet Interface

exxxx is a physical interface representing Ethernet network card.

Loopback Interface

  • lo is a special virtual network interface called loopback device.

  • It is used to connect to services running on the user system

Environment Setup

Environment Variables

  • Linux environment variables act as placeholders for information stored within the system.

  • They will be available to the programs launched from the shell.

Listing

env
command can be used to print all the environment variables.

env

Creating & Updating

export
command is used to define/update value for a variable.

Syntax :

export VARIABLE_NAME=variable_value

Example :

export CUSTOM_ENV_VARIABLE=10

Accessing Environment Variables

  • Use $ to access environment variables.

  • When redefining variables, do not use the dollar sign.

Syntax :

echo $VARIABLE_NAME

Example :

$ echo $CUSTOM_ENV_VARIABLE

Delete Environment Variable

unset
command removes an environment variable.

unset VARIABLE_NAME

Commands Folder Path

PATH variable holds the colon-separated list of folder paths where executables are located.

echo $PATH

Aliasing Command

alias
is a (usually short) name that the shell translates into another name or command.

Syntax :

alias name=value

Example :

alias t=traceroute
t google.com

Un-aliasing Command

unalias
removing an existing alias is known as unaliasing.

unalias alias_name

Persistent Variables

Environment variables defined in a shell are deleted as soon as you exit the terminal.

To persistent environment variables we write them in .bashrc or ~/.bash_profile configuration files.

Editing .bashrc

Syntax :

export VARIABLE_NAME=variable_value

Example :

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/Examples/startup-files (in the package bash-doc)
# for Examples
case $- in
*i*) ;
...
export CUSTOM_ENV_VARIABLE=5
  • To immediately apply all changes in .bashrc,
    use the 
    source
     command
source ~/.bashrc

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

Contact Form