02

DevOps Engineer · Step 2 of 8 · 9 min

Linux and the command line

Move around a Linux system, read logs, manage processes and permissions without a mouse.

Why Linux

Most servers, containers and cloud machines run Linux. Even when you use a managed service, you will read logs, debug containers and run scripts in a Linux shell. Comfort here is the first real skill of the job.

On a Mac, Terminal is close enough to start. On Windows, install WSL, the Windows Subsystem for Linux, which gives you a real Linux shell for free.

The commands you will use daily

Navigate with pwd, ls, cd. Read files with cat, less, head and tail; tail -f follows a log as it grows. Search with grep and find. Manage files with cp, mv, rm and mkdir. Check processes with ps and top, and stop one with kill.

Learn pipes: the | symbol sends one command's output into another, such as grep ERROR app.log | wc -l to count error lines. Most useful shell work is small commands joined together.

Permissions and users

Every file has an owner and permissions for reading, writing and running. ls -l shows them; chmod and chown change them. sudo runs a command as the administrator, called root.

Use sudo only when you need it and understand the command. A typo with root rights can delete a whole system, and there is no recycle bin.

Networks and services

You will often ask: is the service running, and can I reach it? systemctl status shows services on most Linux systems. curl makes web requests from the terminal. ssh logs you into a remote machine securely, ideally with keys instead of passwords. Learn what ports and DNS are; many outages turn out to be one of the two.

Try it

Run ten commands in a safe sandbox

  1. 1.Open a terminal on your machine, WSL on Windows, or a free browser sandbox such as Killercoda.
  2. 2.Create a folder, make a file, write three lines to it with echo, and read it with cat.
  3. 3.Use grep to find one line and wc -l to count lines.
  4. 4.Run ls -l and explain each permission letter. Ask a chatbot if you get stuck, but type every command yourself.
I am learning Linux. Give me ten short exercises, from easy to harder, using only safe commands in my home folder. Do not use sudo or rm -rf. After each, explain what the command did.
What does grep ERROR app.log | wc -l do?

Check yourself

What does grep ERROR app.log | wc -l do?