August 21st, 2024

Essential Terminal Commands Every Developer Should Know

The article discusses ten essential terminal commands for Unix-like systems that enhance developer productivity, including `grep`, `ls`, `cat`, `head`, `awk`, `sed`, and `tail`, with practical usage examples.

Read original articleLink Icon
Essential Terminal Commands Every Developer Should Know

The article by Trevor Indrek Lasn outlines ten essential terminal commands that can enhance productivity for developers working with Unix-like systems such as Linux and macOS. It emphasizes the efficiency of the command line in automating tasks that would otherwise be time-consuming through graphical interfaces. The commands discussed include `grep`, which is used for searching specific patterns in files; `ls`, for listing files and directories; `cat`, for displaying and combining file contents; `head`, for previewing the first few lines of a file; `awk`, for data manipulation and extraction; `sed`, for text processing; and `tail`, for viewing the last lines of a file. Each command is accompanied by practical examples demonstrating its usage, such as searching logs with `grep`, merging files with `cat`, and replacing text with `sed`. The article serves as a guide for developers to streamline their workflows and improve their command line skills.

- The command line can significantly enhance productivity for developers.

- Essential commands include `grep`, `ls`, `cat`, `head`, `awk`, `sed`, and `tail`.

- Each command has specific functionalities, such as searching, listing, and manipulating files.

- Practical examples illustrate how to use these commands effectively.

- Familiarity with these commands can lead to more efficient coding and troubleshooting.

Link Icon 9 comments
By @teddyh - 8 months
> 1. grep

> 2. ls

> 3. cat

> 4. head

> 5. awk

> 6. sed

> 7. tail

> 8. chmod

> 9. xargs

> 10. find

Seems like a pretty good list. I wonder if there is anything obvious missing?

  awk '{ print $1 }' "$HISTFILE"|sort|uniq -c|sort -rn|head -15
     4887 cd
     3699 ssh
     2461 man
     1987 ls
     1558 top
     1141 less
      981 su
      905 dc
      807 pwd
      779 while
      750 find
      601 apt-cache
      529 echo
      462 cat
      426 emacs
(The above list has been cleaned from my system-specific commands which would not be generally useful for others.)

Ah, of course. They forgot the most useful command of all, namely man.

By @Zhyl - 8 months
This article is such a ride. `grep`, `ls` and `cd` then BAM - `awk`.

"Here's a hammer, here's a chisel, here's a hand saw aaaand... here's a petrol powered jackhammer with a circular saw attached."

By @TheRealPomax - 8 months
Counter argument: most of these commands are great if you want to do shell scripting (including one-offs that you never save to a file), where you chain commands to do work for you. But I've never needed anything except for `ls` and (rarely) `chmod` for my actual day job, especially since everything I write needs to work cross-platform. Shell script has been the bane of "and folks on Windows should also be able to contribute" open source developers. I consider these great commands to know for personal automation, or when doing Unix(like)-only dev work, but they're the complete opposite of essential for cross-platform development. Not intimately knowing them means you literally can't be tempted to integrate them into a team-wide/project-wide workflow.

Maybe if Windows had grown up with the same Unix tools from day one, the story would be different, but as it stands if I want to do cross-platform development, I'd much rather use the tools I know that Windows devs on my team (and community contributors) can also use, so that we're all using the same tooling and everyone can help everyone else when that tooling falls short.

A lot of things in this article are (for better or for worse) "just do X in VS Code" these days, with support for a "project-recommended extensions" file that you check into version control so that folks forking/cloning automatically get told which extensions they will want to get up to speed with the rest of the team. Because if there's a "common" unix command chain, good chance there's an equivalent cross-platform extension for VS Code for it. If it's not already built in of course.

The essential part is knowing how to do get the result you need for yourself, and how to automate the tasks of getting those results using tools that everyone will be able to use if you're doing dev work (paid or as volunteered) for someone else.

By @roughly - 8 months
`sort` and `sort --numeric`, `uniq` and `uniq -c`, and `cut` in its `cut -d' ' -f 3` are things I use far, far more often than sense or reason suggests I should. Pipe all that to `xargs` (or `xargs -n1 -IAB -p10 command --flag AB`) and baby, you got a stew going.

(as the saying goes, Unix gives you enough rope to shoot yourself in the foot.)

By @sys_64738 - 8 months
My most used keystroke in bash is control-r. The number of folks who don’t know that amazes me. My go to shell command is tmux.
By @analog31 - 8 months
Shout out to "sudo reboot"
By @greenbit - 8 months
'lsof' is another one that I can't do without.
By @sneed_chucker - 8 months
I'm sorry, but who is the intended audience of this post?

Is there really anyone who is messing around on the Unix command line who needs to be told about cat, head, and ls?

By @2OEH8eoCRo0 - 8 months
no tar?