Interview Questions: Part 2
Networking and scripts.
Part two. These questions check that you can work with servers, and write simple scripts. Again, pause, answer out loud, then compare.

- Servers and scripts
- Answer out loud
- Then compare
Networking
How do you log in to a remote server? SSH user at host. Why use keys instead of passwords? They can't be guessed, and you never send a secret. How do you copy a folder to a server? R sync dash AV. And how do you test a web address from the terminal? Curl.
| key | value |
|---|---|
| Remote login | ssh user@host |
| Why keys? | safer than passwords |
| Copy a folder | rsync -av dir/ host: |
| Test a URL | curl -I URL |
Scripting
What's the first line of a bash script for? The shebang says which program runs it. What's dollar one? The first argument. What's dollar question mark? The exit code of the last command, zero for success. And how do you run a script every night? Add it to cron.
| key | value |
|---|---|
| #!/bin/bash | which shell runs it |
| $1 | first argument |
| $? | last exit code, 0 = OK |
| Every night | crontab -e |
Tricky ones
What does set dash E do? It stops a script at the first error. What's the difference between single and double quotes? Double quotes expand variables, single quotes don't. And why shouldn't you work as root all the time? One mistake could damage the whole system. Use sudo, only when needed.
| key | value |
|---|---|
| set -e | stop at the first error |
| "$x" vs '$x' | expands vs literal |
| Root all the time? | no, use sudo |
| Where are logs? | /var/log |
Summary
SSH, keys, R sync, curl, the shebang, exit codes, cron, and quoting. If you can answer these, you're ready for most beginner Linux interviews. Next, the final quiz.
Key takeaways- ssh and keys
- $1, $?, set -e
- Quotes and sudo