the-art-of-command-line README

The project's README from github.com/jlevy/the-art-of-command-line. As one markdown file: README.md.

🌍 Čeština ∙ Deutsch ∙ Ελληνικά ∙ English ∙ Español ∙ Français ∙ Indonesia ∙ Italiano ∙ 日本語 ∙ 한국어 ∙ polski ∙ Português ∙ Română ∙ Русский ∙ Slovenščina ∙ Українська ∙ 简体中文 ∙ 繁體中文

The Art of Command Line

Note: I'm planning to revise this and looking for a new co-author to help with expanding this into a more comprehensive guide. While it's very popular, it could be broader and a bit deeper. If you like to write and are close to being an expert on this material and willing to consider helping, please drop me a note at josh (0x40) holloway.com. –jlevy, Holloway. Thank you!

![curl -s 'https://raw.githubusercontent.com/jlevy/the-art-of-command-line/master/README.md' | egrep -o '\w+' | tr -d '`' | cowsay -W50](cowsay.png)

Fluency on the command line is a skill often neglected or considered arcane, but it improves your flexibility and productivity as an engineer in both obvious and subtle ways. This is a selection of notes and tips on using the command-line that we've found useful when working on Linux. Some tips are elementary, and some are fairly specific, sophisticated, or obscure. This page is not long, but if you can use and recall all the items here, you know a lot.

This work is the result of many authors and translators. Some of this originally appeared on Quora, but it has since moved to GitHub, where people more talented than the original author have made numerous improvements. Please submit a question if you have a question related to the command line. Please contribute if you see an error or something that could be better!

Meta

Scope:

Notes:

Basics

Everyday use

      find . -name '*.py' | xargs grep some_function
      cat hosts | xargs -I{} ssh root@{} hostname
      set -euo pipefail
      trap "echo 'error: Script failed: see failed command above'" ERR
      # do something in current dir
      (cd /some/other/dir && other-command)
      # continue in original dir
      diff /etc/hosts <(ssh somehost cat /etc/hosts)
{
      # Your code here
}
cat <<EOF
input
on multiple lines
EOF
      TCPKeepAlive=yes
      ServerAliveInterval=15
      ServerAliveCountMax=6
      Compression=yes
      ControlMaster auto
      ControlPath /tmp/%r@%h:%p
      ControlPersist yes
      stat -c '%A %a %n' /etc/timezone
>>> 2+3
5

Processing files and data

the-art-of-command-line (jlevy/the-art-of-command-line)

Searching Database…

What is this?A single-page guide collecting essential command-line tips, tricks, and notes for using Bash on Linux and other Unix-like systems, from basics through advanced scripting and debugging.
Is this a tutorial I read start to finish, or more of a reference?It's organized into sections (Basics, Everyday use, Processing files and data, System debugging, One-liners, Obscure but useful, macOS only, Windows only) so you can read it fully or jump to the topic you need, and look things up elsewhere once you know the command name.
Where should a beginner start?Start with the Basics section: read the man bash page in full, pick a text editor (nano for simplicity, Vim or Emacs for power users), and learn how to find documentation with man and apropos.
Do I need any special tools to follow along, or just a terminal?Just a standard Unix/Linux terminal with Bash; some tips reference optional extra tools installed via apt, yum, dnf, pacman, pip, or brew.
Does everything here apply to macOS or Windows too?No — the guide is written for Linux by default, with separate dedicated sections only for macOS-specific and Windows-specific items; many other tips happen to work elsewhere but aren't guaranteed.
Is this for complete beginners or experienced sysadmins?Both — it aims for breadth and brevity so it's useful whether you're new to the shell or already fairly experienced.
What kind of shell does this focus on?It focuses on interactive Bash, though many tips also apply to other shells and to general Bash scripting.
Does it cover scripting best practices, not just interactive use?Yes, it covers Bash scripting habits like using set -e, set -u, set -o pipefail, and trap for error handling, plus variable expansion and quoting pitfalls.
Is there a tool mentioned for understanding unfamiliar commands?Yes, it recommends using Explainshell to get a breakdown of what a command's options and pipes do, and curl cheat.sh/command for quick cheat sheets.
Is this guide available in other languages?Yes, it's translated into many languages including Czech, German, Greek, Spanish, French, Japanese, Korean, Polish, Portuguese, Romanian, Russian, Ukrainian, and both Simplified and Traditional Chinese.
Creator
jlevy
Size
2.7 MB
Stars
162.5K
Updated
CommitJul 12
Age
11y
Commits · 90 Days