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
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).
'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.
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.
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.
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.
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.
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.
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.
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.
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.
> 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.
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.
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.
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.
…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?
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.
Since macOS Catalina, zsh has been the default. bash switched to GPLv3 awhile back, and to avoid licensing issues, Apple never updated bash past 3.2, which was already well over a decade old at the time.
"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.
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.
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.
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.
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 !!
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.
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
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.
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.
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.
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.
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.
https://missing.csail.mit.edu/