P2
P2
Theory:
Command ifconfig
Description Display and manipulate route and network interfaces.
Syntax ifconfig [interface] [options]
Option up: Activate the specified interface.
down: Deactivate the specified interface.
netmask: Set the network mask.
broadcast: Set the broadcast address.
mtu: Set the MTU for the interface.
Output
Command ip
Description It is a replacement of ifconfig command.
Syntax ip [OPTIONS] OBJECT { COMMAND | help }
Option address: Manage IP addresses.
link: Manage network interfaces.
route: Manage routing table.
neigh: Manage ARP table.
netns: Manage network namespaces.
Output
Command tracepath
Description Similar to traceroute but doesn't require root privileges.
Syntax tracepath [options] host
Option -b: Print both hostnames and numeric IPs.
-n: Print numeric IP addresses only.
Output
Command traceroute
Description Network troubleshooting utility.
Syntax traceroute [options] host
Option -4 : Use IPv4.
-6 : Use IPv6.
-m MAX_TTL : Set the max number of hops.
-p PORT : Set the destination port.
Output
Command ping
Description To check connectivity between two nodes.
Syntax ping [options] destination
Option -c COUNT : Stop after sending COUNT packets.
-i INTERVAL : Wait INTERVAL seconds between sending each packet.
-s PACKET_SIZE : Specify the number of data bytes to be sent.
Output
Command netstat
Description Display connection information.
Syntax netstat [options]
Option -a : Show all sockets.
-t : Show TCP connections.
-u : Show UDP connections.
-p : Show the PID and name of the program to which each socket belongs.
Output
Command ss
Description It is a replacement of netstat.
Syntax ss [options] [ FILTER ]
Option -t : Display TCP sockets.
-u : Display UDP sockets.
-l : Display only listening sockets.
-p : Display process using the socket.
Output
Command dig
Description Query DNS related information.
Syntax dig [@server] [name] [type] [class] [options]
Option +short : Provide concise output.
+tcp : Use TCP for the query.
+noall : Suppress all output except the query result.
Output
Command nslookup
Description Find DNS related query.
Syntax nslookup [options] [name | -] [server]
Option -type=TYPE : Specify the query type (e.g., A, AAAA, MX).
-timeout=SECS : Set the query timeout interval.
Output
Command route
Description Shows and manipulate IP routing table.
Syntax route [options]
Option add : Add a route.
del : Delete a route.
-n : Show numerical addresses instead of resolving hostnames.
Output
Command host
Description Performs DNS lookups.
Syntax host [options] [name] [server]
Option -a : Use any query type.
-t TYPE : Specify the query type (e.g., A, MX, CNAME).
Output
Command arp
Description View or add contents of the kernel's ARP table.
Syntax arp [options]
Option -a : Display all entries.
-d : Delete an entry.
-s : Create an ARP entry.
Output
Command Iwconfig
Description Used to configure wireless network interface.
Syntax iwconfig [interface] [options]
Option essid : Set the network name (SSID).
key : Set the encryption key.
mode : Set the operating mode (e.g., managed, ad-hoc).
Output
Command hostname
Description Shows the Hostname of the current computer system.
Syntax hostname [options] [name]
Option -f : Display the FQDN.
-i : Display the IP address(es) of the host.
Output
Command curl
Description To download a file from internet.
Syntax curl [options] [URL]
Option -O : Save the downloaded file with the same name as in the URL.
-o : Save the downloaded file with a specified name.
-L : Follow redirects.
Output
Command mtr
Description Combines ping and tracepath into a single command.
Syntax mtr [options] [host]
Option -r : Generate a report.
-c COUNT : Set the number of pings sent.
Output
Command whois
Description Will tell you about the website's whois.
Syntax whois [options] [domain]
Option -H : Hide legal disclaimers.
-P : Suppress PAGER.
Output
Command ifplugstatus
Description Tells whether a cable is plugged in or not.
Syntax ifplugstatus [options]
Option -a : Show status of all interfaces.
-q : Quiet mode, only show errors
Output
Command iftop
Description Network bandwidth monitoring tool that shows a list of network connections from/to
your system and their bandwidth usage in real-time.
Syntax iftop [options]
Option -i interface : Specify which interface to monitor.
-B : Display bandwidth in bytes per second instead of bits.
-n : Show numerical addresses instead of resolving hostnames.
-N : Show port numbers instead of resolving port names.
-P : Show ports.
-F : Filter the traffic shown, e.g., -F "not port 22" to exclude SSH traffic.
-h : Show help message.
Output
Command tcpdump
Description Powerful command-line packet analyzer. It allows the user to display TCP/IP and other
packets being transmitted or received over a network to which the computer is attached.
Syntax tcpdump [options] [expression]
Option -i interface : Listen on interface (e.g., eth0).
-n : Don't convert addresses (e.g., host addresses, port numbers) to names.
-c count : Stop after receiving count packets.
-v : Verbose mode. Provides more information about the packets.
Output
Conclusion: Thus, all the basic networking commands in Linux have been studied.