Lecture # 26 - Networking in Linux
Networking Commands in Linux

ifconfig:
ifconfig is used to show the configuration of different network interfaces. This command is written as ifconfig .

Here inet shows the IP Address, netmask shows the subnet mask, RX shows received packets and TX shows transmitted packets.
Show one Interface:
To show the configuration of only one interface
ifconfig [interface-name]is used.

Disable an Interface:
To disable or down an interface
sudo ifconfig [interface-name] downis used.

Enable an Interface:
To enable or up an interface
sudo ifconfig [interface-name] upis used.
ip:
Show Information of Interfaces:
To show the information of different interfaces there are two commands:
ip a:
This command is written as
ip a.

ip addr:
This command is written as
ip addr.
Show Information of one interface:
To show information of only one interface there are two commands
ip a:
To show information of only one interface using ip a,
ip a show [interface-name]is used.
ip addr:
To show information of only one interface using ip addr, ip addr show [interface-name] is used.

Disable an Interface:
To disable an interface sudo ip link set [interface-name] down is used.

Enable an Interface:
To enable an interface
sudo ip link set [interface-name] upis used.
ping:
Check Internet Connectivity:
To check internet connectivity
ping [website-url]is used. Pressctrl + Cto stop.

Send Specified Number of Packets:
To send specified number of packets
ping -c [number-of-packets] [website-url]is used.

Show the Timestamp of Packets:
To show the timestamp of sent packets
ping -D [website-url]is used.
traceroute:
Traceroute is used to trace the hops(devices) to reach the destination. If [* * *], this means no response from the hops. This command is written as traceroute [website-url] .

netstat:
Netstat is used to show the socket details. This command is written as netstat .

To show TCP and UDP sockets:
To show details of TCP and UDP sockets
netstat -tulnis used.

To show TCP sockets:
To show details of TCP sockets
netstat -tis used.

To show UDP sockets:
To show details of UDP sockets
netstat -uis used.

To show Summary or Protocols:
To show summary of protocols
netstat -sis used.

To show Routing Table:
To show routing table
netstat -ris used.

To show TCP and UDP sockets with Process ID:
To show TCP and UDP sockets details with Process ID of each socket
sudo netstat -tulnpis used.
ss:
ss is used to show the socket statistics.
Show all sockets:
To show all sockets statistics
ss -allis used.

Show Established Sockets:
To show the statistics of established sockets
ss -eis used.

Show TCP Sockets:
To show the statistics of TCP sockets
ss -tis used.

Show UDP Sockets:
To show the statistics of UDP sockets
ss -uis used.
dig:
The dig command is used to perform Domain Name System (DNS) queries. This command is written as dig [website-url] .

nslookup:
nslookup is used to query Domain Name System (DNS) servers to obtain various types of DNS information. This command is written as nslookup [website-url] .

host:
The host command is used for performing Domain Name System (DNS) lookups to obtain various information related to domain names and IP addresses. This command is written as host [website-url] .

arp:
arp is used to display and manipulate the Address Resolution Protocol (ARP) cache, which is a table maintained by the operating system that maps IP addresses to MAC addresses on a local network segment. There are two ways to write this command.
- Method 1:
arp

- Method 2:
arp -a

Show Specific Interface:
To display ARP of a specific interface arp -i [interface-name] is used.

hostname:
This command displays the hostname of the machine. This command is written as hostname .

Change Hostname:
To change the hostname of a machine
sudo hostnamectl set-hostname [new-host-name]is used.
curl:
This command is used to display the html code of a website. This command is written as curl [website-url] .

To save the code into a file:
To save the html code of the file
curl -o [file-name] [website-url]is used.
wget:
This command is used to download the contents of a website into a file. This command is written as wget [website-url] .

Save the output in a file:
To save the output in a file after downloading the contents from the website
wget -o [file-name] [website-url]is used.

Save the HTML code of a website recursively:
To save the html code of a website recursively or you can say save the html code of a whole website
wget --mirror [website-url]is used.






