Challenge your understanding of crucial Linux networking commands including ifconfig, netstat, and curl. This quiz covers practical scenarios, syntax, and essential networking concepts for configuring interfaces, viewing connection details, and retrieving web content.
Which ifconfig command output line directly displays the IPv4 address assigned to an interface such as eth0 on a Linux system?
Explanation: The line beginning with 'inet' followed by an IP address, such as 'inet 192.168.1.15', shows the IPv4 address assigned to the interface. 'Broadcast' refers to the broadcast address, not the main IP. 'Netmask' shows the subnet mask, not the device’s IP. 'Network' is not a standard field in ifconfig output for current distributions, and does not display the assigned IP.
A user wants to display all currently listening TCP ports on their Linux system. Which netstat command option should they use for this purpose?
Explanation: The '-lt' option with netstat lists all listening TCP ports. '-ul' is used for listing listening UDP ports, '-ni' shows network interfaces in a numeric format, and '-pa' displays PID and program name for connections but doesn't specifically filter for TCP listening ports.
What does the basic command 'curl http://example.com' accomplish on a Linux system?
Explanation: Issuing 'curl http://example.com' fetches the content from the URL and prints it to standard output in the terminal. It doesn't save the file automatically; to do that you must specify '-o' or '-O'. The command doesn't open a browser or perform a network ping; those are separate functions with different tools.
Which of the following network details is NOT typically displayed by netstat by default on a Linux system?
Explanation: Netstat by default shows active network connections, routing tables, and interface statistics but does not display the ARP cache unless specifically asked with extra options. The ARP cache is typically shown using 'arp' or 'ip neigh' commands. Interface queues are not shown by default either, but the ARP cache is specifically excluded from standard netstat output.
How can you use ifconfig to enable or bring up a network interface, for example eth1, that is currently down?
Explanation: The command 'ifconfig eth1 up' brings the specified interface up and activates it for network use. 'Ifconfig eth1 on' and 'ifconfig eth1 enable' are not valid commands or options in ifconfig, and 'ifconfig up eth1' has the arguments in the wrong order and will not work.