Purpose
This lesson provides an introduction to the Linux command-line. Command line tools are less discoverable than graphical tools, but once you get used to them they’re often more efficient. It is also easier to combine multiple tools together and automate repetitive workflows.
Learning Material
Start by reading through this MDN command line crash course.
Read through the ten lessons at linuxcommand.com. Note that most of the discussion applies, to some degree, to macOS as well.
Exercises
To learn as much as possible from these exercises, write your responses before revealing the provided answers. If any exercises seem irrelevant, you can skip them and instead write a justification as to why they are unimportant. These justifications will help us improve the lesson for future employees.
Exercise 1
Write a cheat sheet with all of the new commands you learned.
Exercise 2
Ripgrep is a powerful commandline tool that searches through files for patterns. It is similar to grep
, although it is often more convenient to use since it will ignore many types of files developers often don’t care about.
Install ripgrep using the appropriate package manager for your operating system (e.g., homebrew for macOS). Once you’ve installed ripgrep, try running which rg
. What does the output mean? Run man rg
and read through the description. You may also want to glance through the rip-grep user manual.
Clone a copy of our dicom standard repository. Now use ripgrep to search for the phrase “cow”. How many times does this word show up?
Exercise 3
Search online for a command that will let you pipe stadard output into your operating systems’ clipboard. Use this to copy the results of rg cow
into your clibpoard.
Exercise 4
jq is a lightweight and flexible command-line JSON processor. Install jq and read through the tutorial here.
Read through the examples under each of the basic filters on this page.
Our DICOM Standard repository is a set of Python scripts that is used to convert the DICOM standard from a bunch of HTML into a consistent JSON format. The final JSON files are stored in the standard
subdirectory of the repository. You can use these JSON files to play around with jq.
Using jq, print each CIOD’s name to standard output (if you don’t know what a CIOD is, don’t worry about that for now!).