4 ms·
Essential Terminal Commands Every Developer Should Know
- 2OEH8eoCRo0 2y agono tar?
- ochronus 2y agowell they never said _all_ the essential commands ;)
- teddyh 2y agoYou know, I used to extract and create tar files all the time, but have not done so in ages. I think it ended when software stopped being distributed as tar files. I mean, there are tar files, but you often don’t use that way to install them. For source code, you you use git clone or apt-get source. For already-compiled software, you use apt, snap, or some other package manager. General data files are usually made available as a .zip file.
- 2OEH8eoCRo0 2y agoMost of the upstream sources that I deal with come as tarballs. https://www.kernel.org/ https://www.kernel.org/
- greenbit 2y agoI sometimes use tar when I need to transfer a bunch of files using a USB stick. Most USB sticks I encounter are FAT (or rarely, NTFS) and the permissions get trashed if bare files are copied. Tar saves me from having to repair the perms on the other end. (Admittedly this isn't something you're going to need to do unless you find yourself working with air-gapped systems, but .. I do)
- BenjiWiebe 2y agoTar with -a (automatic) is awesome. tar -xaf foo.tar.gz Will auto-un-gzip based on the extension. Also works with compressing: tar -caf bar.tar.xz bar/
- ahartmetz 2y agoI just use tar xf file. The a option is probably only required when creating a tarball.
- Ringz 2y agoTar? I‘m so sorry! https://xkcd.com/1168 https://xkcd.com/1168
- 2OEH8eoCRo0 2y ago$ tar --help
- Zhyl 2y agoThis 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."
- benterix 2y agoI think it might have been generated by AI. A human would have noticed huge discrepancy between simple examples with grep and ls and the magic AWK script that would basically deserve a separate article just to grasp how it works.
- roughly 2y agoI think a lot of people underestimate awk or aren't aware of its capabilities - I used it quite a lot when I was new in my career before really understanding it. There's enough awk snippets floating around that you'll see it in folks' toolkits next to sed & grep even though they're just using a couple preset scripts. I didn't really understand what it was capable of until I had a colleague use it to parse the output a CLI tool with no actual reasonable machine-readable output - something like a 100 line awk script to turn some hardware vendor's joke of a config tool into output that could be piped into another script. That's when I understood what awk was, and that my colleague might have been the devil.
- alecsm 2y agoI don't think anyone is arguing otherwise but that command is out of place there. Way more complex than the rest and poorly explained. Anyway, TIL the existence of grep -e.
- deafpolygon 2y agoAwk is powerful, but I find it more portable/easy to understand implementing much of it in Python or Perl 5 these days.
- TheRealPomax 2y agoCounter 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.
- theamk 2y agoIt's 2024, why are we still caring about windows native development? Sure, if you have unlimited resources, or your target audience is predominantely Windows (gaming or non-web large enterprise apps), you can worry about Windows. Otherwise, tell them to install WSL and do all you day-to-day work in *nix environment. No one but your CI have to touch Windows.
- TheRealPomax 2y agoI didn't say "native Windows", I said cross-platform. The kind where the tooling you use works on every OS. Cross platform is literally the opposite of "anything-native": you workflows and tooling are OS-agnostic, even if the end results are binaries specific to all major OSses (and of course, a lot of dev work never involves generating binaries)
- teddyh 2y ago> 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.
- analog31 2y agoShout out to "sudo reboot"
- greenbit 2y ago'lsof' is another one that I can't do without.
- roughly 2y agolsof I find I'm using primarily for debugging stuff. strace and tcpdump fit into the same general category - "What the hell is this program actually _doing_ right now?".
- greenbit 2y agoIt's especially useful when you have several processes that communicate with TCP or UDP. 'lsof -i :<port>' will quickly show if you have the connections you expect to have.
- roughly 2y ago`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.)
- sneed_chucker 2y agoI'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?
- Novosell 2y agoI'm not sure I'd say I'm "messing around on the Unix command line", but I've been using Linux for about 3 years on my desktop and do some hobbyist development. Have never seen head before.
- schwartzworld 2y agoNew developers? Many are uncomfortable on the command line
- sys_64738 2y agoMy 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.
- temeya 2y agoAs someone who was also recently taught this, it's amazing. Props to the GNU Readline library [1] as well as Tmux as they are certified game-changers for the occasional context swap. [1] https://en.m.wikipedia.org/wiki/GNU_Readline https://en.m.wikipedia.org/wiki/GNU_Readline
- fragmede 2y agohttp://atuin.sh http://atuin.sh for ctrl-r on steroids