Instead of making a separate page for all of these small commands, here they are in a comprehensive list:

What are the most common Linux Commands that interviewers ask about?

This is often asked to make sure you’ve used Linux before and avoid wasting precious interview time on the absolute basics. Here are some commands you should be intimately familiar with:

  • ls – list a file or directory.
  • cd – change your working directory
  • pwd (actually a shell built-in and not a program) – see the current directory you’re in.
  • mv – rename (move) a file or directory.
  • cp – create a copy of a file or directory.
  • rsync – copy files and directories across hosts (via SSH).
  • rm – remove (delete) a file or directory.
  • chown – change ownership of a file or directory.
  • chmod – change the file mode (permissions) of a file or directory.
  • find – go through the filesystem and find files and directories. Optionally execute a command for each result you find.
  • locate – go through a database of cached (remembered) files and return matches. Can be useful for seeing where related things are.
  • vi / nano – common text editors for modifying files in a Linux shell environment. Jeff prefers nano, and Dave makes fun of him for it (even though it’s totally fine to use nano).
  • touch – create an empty file if it doesn’t exist, or update the accessed/modified times of a file if it exists.
  • less and tail – great ways to paginate (display, one screenful at a time) text on the Linux command-line. less is often used when piping together lots of commands on the shell. tail is often used to inspect logfiles, because it live-updates the output if lines are added while you’re watching.
  • basic shell concepts like pipes (|), booleans (&& and ||) quoting, input/output redirection (<> and &>), file descriptors (0/stdin, 1/stdout, 2/stderr), exit codes
  • basic shell logic (aka “learn some bash“)

 

How do you list a directory? What are some common flags and what do they do?

The ls command lists files and directories. Common flags are:

  • -a (include hidden files)
  • -l (long listing including file size, permissions, ownership, modification time)
  • -h (convert sizes to human-readable format instead of just number of bytes).

 

How do you change ownership of a file or directory?

The chown command is used to change ownership of files and directory. The -R flag can be used on a directory to recursively apply the ownership change to all files and directories inside of it.

 

How would you edit a file on the command line?

Common command-line text editors are nano (an easy editor for beginners) and vi (more complicated modal editor, installed in the vast majority of Linux environments).

Vim and emacs are more complex and powerful editors that you’re likely to find on an engineer’s laptop rather than installed in a production environment, however both can be used to edit remote files.

 

How would you check CPU and memory utilization on a machine?

Common tools for checking resource usage on Linux are top and some more specific tools that usually aren’t installed by default: htop, atop, iotop (for disk/IO monitoring), bmon (for network monitoring).

Interview Tip: When you’re asked these kinds of resource-monitoring questions, be sure to also mention using a more robust monitoring system like an ELK stack or third-party monitoring tool to view, aggregate, monitor, and alert on metrics like this. Interviewers are often trying to weed out “harcdore, old-school sysadmins” who log into everything manually instead of making life easy.

 

What’s stored in the Linux /etc directory tree?

The /etc/ directory tree in Linux contains configuration files for installed programs. Like so many things in Linux, this isn’t STRICTLY enforced — you can put configuration files wherever you want for most programs — but this is the traditional place for it. The normal structure is something like:

/etc/programname/configfile.conf

If you’re writing a program that runs on Linux, it’s good practice to create a directory in /etc/ with your program name, so that you don’t make a mess in the top-level /etc/ directory. Then, add one or more configuration files in the directory you created (/etc/yourprogram/).