[HN Gopher] Essential Terminal Commands Every Developer Should Know
___________________________________________________________________
Essential Terminal Commands Every Developer Should Know
Author : todsacerdoti
Score : 20 points
Date : 2024-08-21 15:26 UTC (3 days ago)
(HTM) web link (www.trevorlasn.com)
(TXT) w3m dump (www.trevorlasn.com)
| 2OEH8eoCRo0 wrote:
| no tar?
| ochronus wrote:
| well they never said _all_ the essential commands ;)
| teddyh wrote:
| You 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 wrote:
| Most of the upstream sources that I deal with come as
| tarballs.
|
| https://www.kernel.org/
| greenbit wrote:
| I 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 wrote:
| Tar 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/
| Ringz wrote:
| Tar? I'm so sorry!
|
| https://xkcd.com/1168
| 2OEH8eoCRo0 wrote:
| $ tar --help
| Zhyl wrote:
| 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."
| benterix wrote:
| I 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 wrote:
| I 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 wrote:
| I 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.
| TheRealPomax wrote:
| 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.
| theamk wrote:
| It'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.
| teddyh wrote:
| > _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_.
| chunkyks wrote:
| I'm not the only person who uses "dc" for throwaway
| calculations all the time? Woo!
|
| The thing that I find has the biggest useful-to-popularly-known
| ratio is "tee".
| analog31 wrote:
| Shout out to "sudo reboot"
| greenbit wrote:
| 'lsof' is another one that I can't do without.
| roughly wrote:
| lsof 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 wrote:
| It'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 wrote:
| `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 wrote:
| 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?
| Novosell wrote:
| I'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.
___________________________________________________________________
(page generated 2024-08-24 23:02 UTC)