MCQs on Networking and Shell Scripting | Shell

Networking commands in shell scripting are essential for system administrators and developers. This set of 30 MCQs covers using tools like curl, wget, automating SSH commands, and network diagnostics.


Networking and Shell Scripting – MCQs

1. Working with curl and wget (10 Questions)

  1. What is the main function of the curl command in shell scripting?
    a) Uploading files to a server
    b) Sending HTTP requests to a server
    c) Transferring files over FTP
    d) Testing network connectivity
  2. Which of the following is a valid option for using curl to download a file?
    a) curl -o filename.txt
    b) curl --output filename.txt
    c) curl -d filename.txt
    d) Both a and b
  3. What is the purpose of the wget command?
    a) To make HTTP requests
    b) To transfer files from a remote server
    c) To test the network speed
    d) To check DNS resolution
  4. How can you use curl to send a GET request to a server?
    a) curl -X GET http://example.com
    b) curl --get http://example.com
    c) curl http://example.com
    d) curl -g http://example.com
  5. Which command is used to download a file from a remote server using wget?
    a) wget http://example.com/file
    b) wget -d http://example.com/file
    c) wget download http://example.com/file
    d) wget --get http://example.com/file
  6. Which option for curl is used to follow redirects automatically?
    a) -L
    b) -R
    c) -F
    d) -D
  7. How can you download a file and save it with a different name using wget?
    a) wget -o newfile.txt http://example.com/file
    b) wget -O newfile.txt http://example.com/file
    c) wget -rename newfile.txt http://example.com/file
    d) wget --save newfile.txt http://example.com/file
  8. Which command does curl use to interact with a web server over HTTPS?
    a) curl -X HTTPS
    b) curl -u https://
    c) curl --ssl https://
    d) curl --insecure https://
  9. What does the wget -r command do?
    a) Downloads files recursively from a server
    b) Resolves domain names
    c) Resumes downloading files
    d) Downloads all linked files in a webpage
  10. Which of the following is the correct curl command for testing a URL?
    a) curl -I http://example.com
    b) curl -v http://example.com
    c) curl http://example.com
    d) All of the above

2. Automating SSH Commands (10 Questions)

  1. What is the purpose of the ssh command in shell scripting?
    a) To copy files between servers
    b) To create SSH keys
    c) To connect to a remote server over a secure connection
    d) To test network connectivity
  2. How can you automate SSH login without entering a password?
    a) Use an SSH agent
    b) Set up SSH key-based authentication
    c) Use a password manager
    d) Set password: false in the SSH config
  3. Which command allows you to copy files between local and remote servers securely?
    a) scp
    b) ftp
    c) ssh
    d) rsync
  4. How can you use ssh to run a command on a remote server?
    a) ssh user@host "command"
    b) ssh -run user@host
    c) ssh user@host command
    d) ssh -exec command user@host
  5. What does the scp command stand for?
    a) Secure Command Protocol
    b) Secure Copy Protocol
    c) System Command Protocol
    d) Secure Configuration Protocol
  6. Which of the following is the correct scp command for copying a file to a remote server?
    a) scp file.txt user@host:/path
    b) scp file.txt /path user@host
    c) scp file.txt -user@host
    d) scp -r file.txt user@host:/path
  7. How can you copy an entire directory from a local machine to a remote server using scp?
    a) scp -r directory user@host:/path
    b) scp directory user@host:/path
    c) scp -d directory user@host:/path
    d) scp -x directory user@host:/path
  8. Which command is used to generate SSH keys for passwordless authentication?
    a) ssh-keygen
    b) ssh-auth
    c) ssh-keys
    d) ssh-create-key
  9. How can you disable the use of passwords for SSH login?
    a) Set PasswordAuthentication no in sshd_config
    b) Set DisablePassword yes in ssh_config
    c) Run disable-ssh-passwords
    d) Use the -no-password option with ssh
  10. How would you run a script remotely using ssh?
    a) ssh user@host "bash script.sh"
    b) ssh user@host script.sh
    c) ssh user@host -script script.sh
    d) ssh user@host -f script.sh

3. Basic Network Diagnostics (10 Questions)

  1. Which command is used to test the reachability of a host on a network?
    a) ping
    b) trace
    c) netstat
    d) curl
  2. What does the ping command do in shell scripting?
    a) Tests the connection speed
    b) Resolves domain names to IP addresses
    c) Sends ICMP Echo requests to a host
    d) Tracks packet loss
  3. Which of the following options is used with ping to specify the number of packets to send?
    a) -n
    b) -c
    c) -p
    d) -t
  4. What does the netstat command display?
    a) Network packet statistics
    b) Active network connections
    c) Hostname resolution
    d) Available bandwidth
  5. Which netstat option displays the network routing table?
    a) -r
    b) -t
    c) -n
    d) -a
  6. Which command can be used to display the route packets take to a network destination?
    a) traceroute
    b) ping
    c) tracepath
    d) route
  7. What does the traceroute command do?
    a) Displays active network connections
    b) Resolves IP addresses to hostnames
    c) Shows the route packets take to a destination
    d) Tracks data packets in transit
  8. What is the default number of hops traceroute will display when used without options?
    a) 15
    b) 30
    c) 10
    d) 5
  9. How do you display the current network interfaces using netstat?
    a) netstat -i
    b) netstat -p
    c) netstat -t
    d) netstat -r
  10. Which of the following ping options prevents the command from resolving hostnames?
    a) -n
    b) -t
    c) -r
    d) -c

Answers

QnoAnswer
1b) Sending HTTP requests to a server
2d) Both a and b
3b) To transfer files from a remote server
4c) curl http://example.com
5a) wget http://example.com/file
6a) -L
7b) wget -O newfile.txt http://example.com/file
8c) curl –ssl https://
9a) Downloads files recursively from a server
10d) All of the above
11c) To connect to a remote server over a secure connection
12b) Set up SSH key-based authentication
13a) scp
14a) ssh user@host “command”
15b) Secure Copy Protocol
16a) scp file.txt user@host:/path
17a) scp -r directory user@host:/path
18a) ssh-keygen
19a) Set PasswordAuthentication no in sshd_config
20a) ssh user@host “bash script.sh”
21a) ping
22c) Sends ICMP Echo requests to a host
23b) -c
24b) Active network connections
25a) -r
26a) traceroute
27c) Shows the route packets take to a destination
28b) 30
29a) netstat -i
30a) -n

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top