1. Which command displays all network interfaces and their IP addresses?
The ip a command lists all network interfaces, their assigned IP addresses, and their operational states. It replaces older tools like ifconfig in modern Linux systems.
ip a
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Linux & Shell Scripting · Question Set
Networking, Firewalls & SSH Configuration interview questions for placements and exams.
Questions
14
Included in this set
Subject
Linux & Shell Scripting
Explore more sets
Difficulty
Mixed
Level of this set
Go through each question and its explanation. Use this set as a focused practice pack for Linux & Shell Scripting.
The ip a command lists all network interfaces, their assigned IP addresses, and their operational states. It replaces older tools like ifconfig in modern Linux systems.
ip a
For complete preparation, combine this set with full subject-wise practice for Linux & Shell Scripting. You can also explore other subjects and sets from the links below.
ping sends ICMP echo requests to a host and waits for replies. It’s used to verify that a host is reachable and to measure round-trip network latency.
ping 8.8.8.8
hostnamectl is used to view and change the system hostname. It’s part of systemd and also shows OS information and kernel details.
sudo hostnamectl set-hostname dev-server
UFW (Uncomplicated Firewall) is a frontend for iptables that simplifies firewall configuration. The command ufw enable activates it with the default rules.
sudo ufw enable
The command ufw allow ssh opens port 22 for inbound SSH connections. You can also specify the protocol and IP range for more precise access control.
sudo ufw allow ssh
SSH (Secure Shell) connects securely to remote systems over the network. It encrypts both authentication and data transfer to protect communication from eavesdropping.
ssh user@192.168.1.10
ssh-keygen creates public and private SSH keys for secure, passwordless authentication. The generated keys are stored by default under ~/.ssh directory.
ssh-keygen -t rsa -b 4096
scp (secure copy) transfers files between hosts securely using the SSH protocol. It’s simple and encrypted, making it ideal for server-to-server data transfers.
scp file.txt user@server:/tmp/
The SSH client configuration file is located at ~/.ssh/config for user-specific settings or /etc/ssh/ssh_config for system-wide settings. It’s used to define connection parameters like hostname, user, port, and identity file for easy and repeatable access.
Host myserver HostName 192.168.1.20 User ubuntu IdentityFile ~/.ssh/id_rsa
Use ufw status numbered to list all active rules with indexes. To remove a rule, run ufw delete <rule_number>. You can add rules with ufw allow or ufw deny for specific ports or services.
sudo ufw status numbered sudo ufw delete 2
Use telnet or nc (netcat) to check connectivity to a remote port. If the port is open, the connection succeeds; otherwise, it times out. It’s often used to verify database or API endpoint availability.
nc -zv 192.168.1.50 22
First, check network reachability using ping and confirm port 22 is open. Then verify sshd service is running, review /var/log/auth.log for errors, and ensure the public key is correctly copied in ~/.ssh/authorized_keys.
systemctl status ssh cat /var/log/auth.log
iptables -L displays all firewall rules applied to INPUT, OUTPUT, and FORWARD chains. It’s used for fine-grained control over packets and ports.
sudo iptables -L -v -n
Disable root login by setting PermitRootLogin no in sshd_config. Use SSH keys instead of passwords. Change the default port, restrict users with AllowUsers, and enable firewall rules to allow only trusted IPs.
sudo vi /etc/ssh/sshd_config PermitRootLogin no PasswordAuthentication no