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

33 points | by macterminalnewb 11 days ago

43 comments

  • Do123 11 days ago
    The missing semester of your cs education

    https://missing.csail.mit.edu/

    • hchak 8 days ago
      This has been a huge help. Thanks for putting this out here!
  • JohnMakin 10 days ago
    In addition to the other good advice - I would suggest opening your mind to possibilities.

    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).

  • gorjusborg 10 days ago
    Stop using one of the GUI applications.

    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.

    • pan69 10 days ago
      'ls' is probably the most fundamental command as it let's you list the files in a file system, then 'cd' (move in/out of directories). Then go from there.

      for help on 'ls' use either:

      ls --help

      or

      man ls

  • selectnull 11 days ago
    The best way to learn the terminal is to use it. Whatever is that you do in your working day, do it from inside the terminal.

    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.

  • serial_dev 10 days ago
    It's hard to give advice without knowing what you do, and why you want to learn to use the terminal... But:

    Learn about the command line tools that exist, and actually use the ones that match what you regularly do.

    Take small steps, first move a file from the command line. Then, compile your stuff, launch an application. Then use git to commit, pull, push, drop changes. Then learn more git, cherry pick, interactive rebase, stash, diff.

    If something feels tedious, and you think "there must be a better way", take a moment to Google if there is a better way. Even if you might not save time (for the first time) , give it a try, and see how long it takes to solve something new.

    Make your terminal yours and a joy to use. It might just be me, but I like when my terminal looks and feels great.

    Don't make learning an overwhelming experience. It's a marathon, so if on the beginning, you only learn 2-3 tools, that's okay, you'll learn the others when you need them. I picked up Vim (Helix) and tmux only years after I was proficient on the command line.

    It's okay to forget stuff... When I worked on the backend, I was good at grep, log tools, etc, but today, I need some time to get things working.

    Watch videos about other people's set up, it's great inspiration on what's possible.

    Write your own tools, learn what makes an intuitive interface, learn to handle different kinds of flags, arguments.

    Learn to type. Practice typing faster.

    Learn "terminal adjacent" skills. Learn how to navigate your OS with the keyboard (close tabs, windows, search, lock the screen, launch an app).

    Don't be afraid to "toss things out". Some tools are just trash, some tools just don't click for you. If it hurts, stop doing it. If the tool is actually good, you'll hear about it later, at which point, you can give it another go.

  • GianFabien 11 days ago
    A useful first step is to stop using Finder. Instead perform the required operations from the terminal. When you don't yet know how, Google it. The first couple of useful commands are ls: list files (lots of options); cd: change directory; cp:copy; mv:move -- aka rename; vi:edit text file; file: what type of file is it? ... etc.

    If that's too daunting, then still have Finder open, but try to match the operations with above and more.

  • wryoak 11 days ago
    This is a nice little course that seems to get bigger every time I reference it: https://effective-shell.com/
  • TechSculptor89 9 days ago
    Hey macterminalnewb,

    It's great to see your interest in learning to use the terminal. It's a powerful tool that can significantly improve your efficiency once you get the hang of it. Here are a few resources that you might find useful:

    1. Codecademy's Learn the Command Line Course: It's an interactive course that covers the basics of command-line interfaces (CLI). It's beginner-friendly and allows you to practice as you learn.

    2. Learn Enough Command Line to Be Dangerous: This is a part of the 'Learn Enough to Be Dangerous' series by Michael Hartl. It's a great resource for beginners and covers the basics and beyond.

    3. OverTheWire's Bandit Wargame: This is a fun and engaging way to learn terminal commands. It's a series of capture-the-flag style challenges where you use terminal commands to solve puzzles.

    4. man pages: Don't forget about the built-in manual pages in the terminal. You can access them by typing 'man' followed by the command you want to learn about. They can be a bit hard to read at first, but they're incredibly detailed and useful once you get used to them.

    5. Practice: The best way to get comfortable with the terminal is to use it regularly. Try to incorporate it into your daily workflow as much as possible. Even simple tasks like navigating directories or managing files can be good practice.

    Remember, like any other skill, it takes time and practice to become proficient at using the terminal. Don't get discouraged if it feels overwhelming at first. Stick with it, and you'll get there.

  • asicsp 10 days ago
    I have a list of learning resources here: https://learnbyexample.github.io/curated_resources/linux_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

  • jerng 10 days ago
    Don't start in the obvious places, because you can get stuck there for a decade before figuring out what else is going on ( I did, you shouldn't ) ( quick dive ; quick dip )

    1. do a quick read on how UNIX and Linux kernels were designed, particularly what "file handlers" and "sockets" are ( day 1 ; 30 minutes )

    2. do a quick read on the difference between "command prompts" (1-dimensional) and "pseudo-teletype terminals" (2-dimensional) ( day 2 ; 15 minutes ) ... note that both are varieties of "shell" ; shells are opposed to kernels

    3. do a quick read on what "display managers vs window managers" are ... and if possible ( now this is quite hard, as the docs are messy ) ... how the kernel, talks to the shell, which talks to a pseudo-teletype terminal, which is a display client to the display server, which talks to the display server, which talks to the window manager ( it may not be exactly like that, but this is a good assumption to make until you get a clearer view ) ( day 3 ; 2 hours )

    4. then learn a shell scripting language

    5. then do something like "espeak 'oh hi there'"

    Alternatively, do this in reverse numerical order.

  • scop 10 days ago
    The Linux Command Line: A Complete Introduction by William Shotts.

    In my own learning I found this to be the single greatest resource for getting to know the terminal. It has the perfect balance of overview/detail, allowing you to cover an immense amount of ground while feeling like you have a grasp on what's going on when you do something. From there you can then consult reference material as needed.

  • hiAndrewQuinn 9 days ago
    Personally, I only really got into working at the shell once I started exploring all of the wonderful new programs that people have been writing to make it easy as pie to work with. I ended up collecting them all together into scripts I can `curl | bash` on any new Ubuntu machine: https://github.com/hiAndrewQuinn/shell-bling-ubuntu

    Obviously these scripts won't work on Mac. But I do list the programs I install in it right in the README, including what I consider the "Holy Trinity": `rg` (really fast line searching), `fd` (really fast file finding), and `fzf` (best described with examples: see https://andrew-quinn.me/fzf). These all work on my wife's Mac identically to how they work on my own Linux box, and they make the experience of working at a shell much more pleasant.

    Second rec: Install fish! https://mmazzarolo.com/blog/2023-11-16-my-fish-shell-setup-o... You can get back to Bash once you've gotten used to using the shell and find a reason to. Fish is much more pleasant, IMO, and I try to use it wherever I can these days.

    And final rec: If you really want to learn the command line, you will be very well served by investing a few weeks into Vim - vanilla Vim, not the LazyVim Shell Bling Ubuntu installs. Athletes talk about mind-body connection; devs should be aware of terminal-editor connection. When you can confidently open up, make a small edit, and close a text file right in the same terminal you're doing other things in, your fluency will improve greatly, and `vim` is probably the most portable set of keyboard shortcuts you will ever learn for doing just that.

  • autoexec 11 days ago
    Start with the basics of your shell. The internet is full of good info (like here for example https://www.gnu.org/software/bash/manual/html_node/) to get you started. Once you're at the point where you've customized your shell, and tried a bit of scripting move on from just playing around with tutorials and documentation and start doing something useful/entertaining.

    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.

    • latexr 11 days ago
      > Start with the basics of your shell. The internet is full of good info (like here for example

      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.

      • autoexec 11 days ago
        As I said, it was only an example. I had no idea what shell they'd be using or that macOS apparently left them with Zsh and no other option. Apple's website suggests otherwise https://support.apple.com/guide/terminal/change-the-default-...
        • latexr 10 days ago
          It’s not “no other option”, they can switch to Bash but it’s an old version, or they could install a newer version with Homebrew or similar. But none of those steps should be taken by someone just starting.

          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.

  • k310 11 days ago
    Aside: zsh is standard on macs now, thanks to Apple's lawyers freaking out over bash license terms. If you want to change to industry standard bash (I did) then there are three ways to do it.

    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...

    • runjake 11 days ago
      OP, I don't suggest you do this until you know what you're doing -- if ever.

      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.

    • listenfaster 10 days ago
      I was curious as to why someone would prefer bash over zsh i.e. what are the salient differences, and a brief search led me to this thorough answer:

      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?

      • ksherlock 10 days ago
        I prefer bash because I'm more used to it and I feel like zsh gets in the way. One example would be tab completion. When there are multiple matches, zsh will cycle through all possible matches (like cmd.exe, but slightly less annoying). Do Not Want.
    • euroderf 10 days ago
      > Apple's lawyers freaking out over bash license terms

      Interesting! Got a pointer ?

  • gxonatano 10 days ago
    "The terminal" is a terminal emulator: just a program that runs a shell. It's easy to learn the MacOS terminal emulator, called Terminal—just read the user guide accessible in the Help menu, under Terminal Help.

    But what you really want to learn, I'm guessing, is not just the terminal emulator, but a shell. For that, you'll need to pick a shell and read about it. ZSH is the one that comes standard on MacOS, so you can start with that. ZSH is also just a superset of BASH, so you could learn BASH commands and they'd be mostly applicable to ZSH. Try reading The Linux Command Line: https://www.linuxcommand.org/lc3_learning_the_shell.php.

  • cinntaile 11 days ago
    If you want a game. Try https://overthewire.org/wargames/bandit/

    You'll get used to the commands and using the man pages. It's not really focused on bash coding.

  • tonymet 10 days ago
    Tell us more about what you do during the day so we can help you automate it.

    I would start with MacOS Shortcuts.app . It is an accessible approach to automation / scripting that works across all of your apple devices.

    Some general "unix" tools found on MacOS Terminal

      * bc -- desk calculator
      * tr -- replace text (translate)
      * grep -- filter text
      * nano -- edit files
      * convert (imagemagick) -- resize images
      * ping / tracert / mtr / iperf3 (advanced) -- network testing
      * top / free -- activity monitor
      * open (macos) -- open current file in Finder
      * pbcopy / pbpaste -- copy / paste stdout
    
    You may need homebrew to install some if they are missing.
  • t-3 11 days ago
    Apple's own documentation seems decent: https://support.apple.com/guide/terminal/toc

    and their "Shell Scripting Primer" looks fairly comprehensive: https://developer.apple.com/library/archive/documentation/Op...

  • jerojero 11 days ago
    Learn basic commands, use Youtube.

    `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).

  • a-saleh 11 days ago
    I usually need a project.

    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.

  • maCDzP 10 days ago
    I learned a ton from doing “Over the wire”.

    After that I read “The Unix programming environment” and after that it clicked.

    Story time - a thing I learned from TUPL.

    I did an interview at the and they had a bunch of programming questions. One was to write a the shortest script to count lines in n a script ext file. I asked - can I choose language, ANY language?

    From the book I remembered the command wc -l in Bash. The interviewer looked at the his colleague gave a small smirk. I felt right at home.

  • chenning 10 days ago
    When you say "terminal" I think what you really mean is a "shell" which runs within the Terminal. Googling for "bash", "shell scripting", "beginner" and "hello world" are likely to lead you to more useful content.

    Also, as much as it's helpful to write code, it's also helpful to read code and try to understand what it's doing. Ask lots of questions.

  • sciencesama 11 days ago
    Terminal is a tool, it is to make you reach a destination. Chrome for a lot of folks is a browser, but for some it is a job to develop and for some it is a job to use it to test !! You have to figure out what your goal is, then use the tool to get there !! So small things like opening files, try doing text manipulation like copy paste vs replace some text using terminal and you are almost golden !!
  • giancarlostoro 10 days ago
    Learn how to find files without Finder using the terminal. Basically think of things you do outside of the Terminal and ask yourself “can I do this specifically in the terminal” a lot of times, yes, yes you can.

    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.

  • verdverm 11 days ago
    I originally learned much from the bash programming guide and advanced bash programming guide. While Mac uses zsh, you can still learn quite a bit that will carry over, and you can always run bash scripts with the `#!/bin/bash`

    The Linux Documentation Project (TLDP) is a great resource generally

    https://tldp.org/guides.html

  • EricRiese 10 days ago
    GameShell

    https://github.com/phyver/GameShell

    If you have issues with the install, try using the devcontainer via Codespaces on my PR branch

    https://github.com/er2/GameShell/tree/devcontainer

  • darkhorse222 10 days ago
    Well, one option is to boot into the terminal. Being forced to use it is by far the best way to learn.

    Not having a browser may come to annoy though.

  • Quinzel 11 days ago
    There’s a pretty basic course on code academy for how to use the terminal with basic commands etc.It’s super easy. And then from there if you need to do something, but don’t know how/don’t know the command - Google it.
  • idontwantthis 11 days ago
    Is there any point in just learning to use a tool without making something with it? You won’t learn to use a saw until you build something with it.

    Learn to program and you will be required to learn how to use the terminal.

    • themadturk 11 days ago
      There certainly is. I've been using Linux/Mac terminal off and on for a couple of decades and have never "built" anything with it. Certainly no programming or even shell scripting leaves out some of the usefulness of the command line, but knowing the commands to get individual tasks done is very useful.
      • idontwantthis 11 days ago
        I think my point still stands. You didn’t just learn it. You learned how to do things with it.
  • kordlessagain 10 days ago
  • ncclporterror 10 days ago
    LLMs such as ChatGPT are very useful to craft or explain command lines for you. It doesn't replace knowing the tools and reading the man pages, but great to get started.
  • nomadiccoder 10 days ago
    pick an open source software, like nextcloud or a game and follow the instructions for "build from source" youll get a bunch of errors for some dependency not installed and that will lead you down a rabbit hole of installing and downloading tools and show you commands like make, mv, cd, ls, curl, etc. error messages usually contain a lot more information that people expect.
  • adamsiem 11 days ago
  • csours 10 days ago
    Read shell scripts. Install shellcheck. Try things try things try things try things.
  • imwally 10 days ago
    Manual pages will be your best friend. Run the following command.

        man man
  • ThrowawayTestr 10 days ago
    Think of a problem you want to solve, Google how to do it in the terminal.
  • shivc 11 days ago
    a great place to start would be to take a few smaller tasks that you do everyday and use terminal to do those

    i'll also suggest trying to automate smaller tasks by leveraging scripts and terminal

    best way to learn is to do

  • in9 11 days ago
    Let me tell you how I did it. I remember I wanted to start using Linux full-time no BS and have had some exposure to the terminal. I took the opportunity of a new position, I said I had to use Linux for the day-to-day activities and they bought it. So I had to use the terminal/Linux without disrupting any of the necessary activities.

    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/

  • breakfastduck 10 days ago
    you're starting at the wrong end.

    What problem are you trying to solve? Start there, and choose the terminal as a tool of choice.

    You will find learning much easier if there is a clear goal to complete using it.

  • brudgers 11 days ago
    Just start because it is a years long process. Maybe set up a Linux VM so you don't break anything...good luck.
  • swah 11 days ago
    Another is to watch a streamer on Twitch and try to get that you would like to do.
  • haolez 10 days ago
    My playbook for a total beginner would be:

    - start using Ctrl-r

    - learn how to make custom lists and actions with fzf

  • xtiansimon 8 days ago
    cd, dir, mv, cp, rm, mkdir, rmdir, touch, vim, lol