Ask HN: I want to learn to use the terminal, where do I start
as the title states, i want to become familiar/proficient in using the terminal on my mac, and just in general the code used in terminal/CLI. any tips on where to get started, like some online free course to follow? tips/help appreciated
56 comments
[ 2.6 ms ] story [ 120 ms ] threadThe Linux Documentation Project (TLDP) is a great resource generally
https://tldp.org/guides.html
`man` will tell you the usage of most commands `man cp` for example will give you an explanation on the command `cp`.
Learn to use `grep` and `find`. And you'll also want to learn bash (the programming language).
i'll also suggest trying to automate smaller tasks by leveraging scripts and terminal
best way to learn is to do
and their "Shell Scripting Primer" looks fairly comprehensive: https://developer.apple.com/library/archive/documentation/Op...
https://missing.csail.mit.edu/
Any problem you come up with, solve it by seaching or asking GPT.
Of course, this presupposes that you do have the basic understanding of how file system is structured, have basic knowledge of shell commands (cd, ls, cp, gzip, etc...). If not, those are not difficult (at a begginer level) and just google "how to use command line" as there are countless resources out there. This is just one them: https://developer.mozilla.org/en-US/docs/Learn/Tools_and_tes...
But I would actually suggest one particular course, that is actually not targeted at begginers (in my opinion). That course is Destroy All Software (https://www.destroyallsoftware.com/screencasts/catalog) and it will teach you to really appreciate the beauty of the shell/terminal (yes, those are different but it really doesn't matter at this point). The course is not only about the terminal, but you will find gold nuggets in that series of screencast that are about the terminal and the philosophy of using it. There are few free episodes and one that I can specifically point to regarding learning the concepts is "Tar, Fork, and the Tar Pipe" (https://www.destroyallsoftware.com/screencasts/catalog/tar-f...).
If you want to be proficient in the shell wizardry, it will take time. But it's worth it.
If that's too daunting, then still have Finder open, but try to match the operations with above and more.
Look into specific tools for whatever you need or are interested in doing. grep is really good to know. If you're into networking/internet stuff dig, whois, ping, and traceroute are too. wget curl and youtube-dl are great and provide all kinds of opportunities to automate some of the things you do online which can make you want to dig more into shell scripting and keep you going back to your terminal. ffmpeg and ImageMagick too. Maybe pick up some python.
That is not their shell. OP is on macOS, meaning their shell is Zsh. They should not be reading a comprehensive (and frankly very boringly structured, it starts with sections and sections of details irrelevant to a curious beginner) guide on Bash 5.2, which isn’t available on macOS by default.
The point is precisely that the OP likely has no idea what their shell is. I wasn’t lobbying a criticism, but a correction so they are aware.
Regarding the example guide, I do think it’s not a great one for total beginners. someone with interest in learning the Terminal should be given an interesting resource that let’s them play a bit with commands and understand what it’s about before drowning them in theory and technical information.
Currently, probably trying to run a LLM locally is easiest to do in CLI, so just try that.
Alternatively, buy yourself a server, like 5$/month single core, ther eare budget friendly options, Linode is one. Once you have that, try to run something there. I.d.k. a miniecraft server. Open TTD server. Whatever you want. Not something too critical because you are learning and some automated bot could i.d.k. guess your password (don't use passwords) and turn your box into bitcoin miner ... but you will learn stuff.
You'll get used to the commands and using the man pages. It's not really focused on bash coding.
Meanwhile, I read the beginning half of "The Linux Command Line" [1]. I highly recommend it. Looking back, I might have read it until part 2 and skimmed the rest, and read it as I needed it.
Try to do everything through the terminal. File creation, reading, managing stuff, changing wifi, configuring editors, writing files. Try to find the conversion tools with the rest of the "world". Some examples of what I mean are pandoc for md->docx conversion, python pandas for csv -> xlsx. Build small scripts for your tasks. For example, I work in a multilingual company and I have a tool for translation which at first used Google Translate and now uses gpt. At some point in the journey I even had my own custom dwm build. Fun times. Do read about suckless software, a fun philosophy with some genuine principles, and a nice (but not friendly) ecosystem.
So my recommendation is to read something to give you breadth on linux/terminal knowledge so you can navigate around and stick to it as your main driver.
Another book one I recommend is the "Unix and Linux system administration handbook"[2]. It will tell you more about the history and inner workings when compared to the previous one.
1: https://www.linuxcommand.org/tlcl.php
2: https://admin.com/
Short: csh -s /bin/bash
Others: system settings or terminal settings.
[1] https://support.apple.com/en-gb/guide/terminal/trml113/mac
[2] https://www.howtogeek.com/444596/how-to-change-the-default-s...
You may want to update bash via homebrew, or install the full set of Xcode command line tools. (But not full Xcode environment)
xcode-select --install
[3] https://www.macobserver.com/tips/how-to/install-xcode-comman...
Just start with the built-in zsh. Nearly everything you learn with zsh will work the same over on bash and Linux.
Also, I suggest resisting the urge of listening to those telling you to install oh-my-zsh. IMHO, it's a bloated plugins manager (no disrespect to robby <3) and introduces too much magic for beginners. Start basic.
Interesting! Got a pointer ?
https://thenextweb.com/news/why-does-macos-catalina-use-zsh-...
https://apple.stackexchange.com/questions/361870/what-are-th...
…but I’m still not sure there’s a material difference that would impact me, and I’ve been programming professionally since the mid 90s. If I can ask a side question, why would one switch back to bash from zsh?
Learn to program and you will be required to learn how to use the terminal.
hook: https://github.com/m1guelpf/plz-cli
If you are interested in text processing, I wrote interactive TUI apps for exercises on grep, sed, awk and coreutils: https://github.com/learnbyexample/TUI-apps
A good one to start with on mac is probably Finder.
Type 'man man' to learn about man pages.
Read the pages for 'cd', 'cp', 'rm', 'mv', 'find', 'cat'.
Try each one.
Move around the filesystem, move or rename some files.
That's all a good part of what you'll be doing on the cli.
for help on 'ls' use either:
ls --help
or
man ls
Not having a browser may come to annoy though.
I also recommend iTerm 2 I think was the terminal emulator we used at a former job. It was really nice, and helped you install gnu utilities which honestly doing command line work without is a pain.
For instance - say you're doing something repetitive and tedious in an AWS console, every day, and it's mostly the exact same task. Let's just say for the sake of argument you have to kick off some codebuild job every day at 8am first thing you go into work - so you log in, click through the UI, select account/region, find the job, etc. Takes you about 5 minutes.
But wait! The AWS CLI can do the same thing - write a simple script to do a repetitive task like that. Instead of spending 5 minutes every day, now you've got a script that you can run in 5 seconds or less, plus it could be possibly integrated into other automation.
Opening your mind to stuff like this will naturally get you to start using the terminal more often. I'd also suggest familiarizing yourself with a text editor like vim or emacs (or whatever flavor you prefer).