You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to use Terminal for Dummies

Does Apple offer any training resources on how to use Terminal ?

Would very much like to get started.


Many Thanks

Posted on Dec 20, 2019 3:00 AM

Reply
5 replies

Dec 20, 2019 5:46 PM in response to Granaghman

Backup, Backup, Backup.


If you are going to play in the Terminal, then keep current up-to-date backups, because commands executed in the Terminal do not have safety switches. There are few if any "Do Overs" if you fumble finger something.


A current backup is your life line.


 If you need a primer on using the macOS command line, I would suggest starting here: "macOS Command Line Primer". After that Google can be your friend, as well as your local bookstore computer section (focus on books in the Linux section, or maybe the old, but still useful macOS Command Line books from O'Reilly).

Dec 20, 2019 8:45 AM in response to Granaghman

Three of the best things to become familiar with when using Terminal are:


  1. Using the "man" command
  2. Using an editor like vim or nano or emacs
  3. How to use the "shell" (e.g. csh, or bash or zsh or ksh or tcsh -- bash is the default shell, but this changed to zsh in Catalina)


"man" contains documentation for hundreds of commands that are run from the command line in a Terminal window. It has a special mode that can list commands related to a topic, i.e.


man -k topic


this will return a list of all the commands that have the string "topic" in the man page documentation. So some real examples you could try are:


man -k vim


When you know the specific command, you can usually use "man command" to find all the gritty details, e.g.


man bash


would return details of how to use the "bash" shell -- some man "pages" (which is what all these man documents are referred to collectively) return a LOT of information (dozens and dozens of pages).


When you use "man" command you might get a lot of output returned (e.g. "man -k and" will return just about the entire set of man pages, so that's not really helpful - try and be as specific as possible), and if it contains more than a screen full, it will prompt you with a ":" and wait for you to read the current screen until you type one of four things - either a space key (continue on to the next screen of output) or a return key (continue to the next item in the list of topics - basically reads one line at a time rather than a screenful), and the third option is "q" (for quit) which aborts the output and returns you to the shell prompt (there are others but that's enough for this short intro), and the fourth common option is "b" for back - and goes back up one screen of output for each b you type.


I would recommend you get a copy of the "Take Control of the Mac Command Line with Terminal" by Joe Kissel -- it covers about everything you would want to know about Terminal. See https://www.takecontrolbooks.com/command-line/ for more information. Perhaps your local library has a copy?


Be patient as there is a lot to learn about this topic and you can always use Google or whatever your favorite search engine is to learn more.


Good luck...


ps -- one other really nice thing about learning more about Terminal is that this knowledge can be applied to many other systems that are Unix based, as many topics in Terminal (but not all) are common across all Unix based systems, but there is a lot of stuff that is Mac specific too, so try and keep that in mind as well.

Dec 21, 2019 9:39 PM in response to Granaghman

When editing a file on the command line it is best to make a backup copy first so you can easily restore to the original version. Use this template as an example to create a backup of the original file which will append ".orig" to the end of the file name of the copied file. Replace "<path-to-file>" with the actual path to the file you will be modifying:

cp  -pv  <path-to-file>{,.orig}


If you do use a Linux book as a guide keep in mind the Linux versions of many commands may have a lot more features and options than the macOS versions. Sometimes the Linux version of certain commands differ in how they behave in macOS even when using the same options. However, the basic information is still relevant.


When searching for help online make sure to review and understand the commands suggested to you. Don't always accept the first thing you stumble across. Sometimes people will suggest a quick & dirty method, but this can sometimes be risky in some situations. Keep reading since there can be a dozen different ways to accomplish one task and later posts in a thread may contain warnings about some earlier posts. Sometimes later posts can contain a simpler & more elegant solution. I have learned so much reading complete threads when searching for a solution or help with using a certain command.


Don't be afraid, but definitely respect the power and danger the command line has over your computer. Only use "sudo" when absolutely necessary as it will limit the damage you can inflict.


How to use Terminal for Dummies

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.