The MAC Command line with terminal - Programming Ebook

Latest

Download Programming Ebook

Tuesday, December 15, 2020

The MAC Command line with terminal

The MAC Command line with terminal
The MAC Command line with terminal




Book Details 
             TitleThe MAC Command line with terminal
         Author: Joe Kissell
    Language: English
        SubjectSwift / Computers & Technology / Programming / Apple Programming
No. of pages: 346
         Format: PDF


Introduction

Back when I began using computers, in the early 1980s, user interfaces were pretty primitive. A computer usually came with only a keyboard for input—mice were a novelty that hadn’t caught on yet. To get your computer to do something, you typed a command, waited for some result, and then typed another command. There was simply no concept of pointing and clicking to make things happen.

When I finally switched from DOS to the Mac (without ever going through a Windows phase, I should mention!), I was thrilled that I could do my work without having to memorize lists of commands, consult manuals constantly, or guess at how to accomplish something. Everything was right there on the screen, just a click away. It was simpler—not in the sense of being less powerful, but in the sense of requiring less effort to access the same amount of power. Like most everyone else, I fell instantly in love with graphical interfaces.


Design Patterns by Tutorials Third Edition Update for Swift 5 Ray Wenderlich

Fast forward a few decades, and I sometimes find myself faced with some mundane task, such as deleting a file that refuses to disappear from the Trash or changing an obscure system preference. After wasting time puzzling

over how to accomplish my task—and perhaps doing some web searches—I discover that the Mac’s graphical interface does not, in fact, offer any built-in way to do what I want. So I have to hunt on the internet for an app that seems to do what I want, download it, install it, and run it (and perhaps pay for it, too), all so that I can accomplish a task with my mouse that would have taken me 5 seconds in DOS 30-odd years ago.

That’s not simple.

I’m a Mac user because I don’t have time to waste. I don’t want my computer to put barriers between me and my work. I want easier ways to do things instead of harder ways. Ironically, the Mac’s beautiful graphical interface, with all its menus, icons, and buttons, doesn’t always provide the easiest way to do something, and in some cases it doesn’t even provide a hard way. The cost of elegance and simplicity is sometimes a lack of flexibility.

Luckily, macOS isn’t restricted to the graphical realm of windows and icons. It has another whole interface that lets you accomplish many tasks that would otherwise be difficult, or even impossible. This other way of using macOS looks strikingly like those DOS screens from the 1980s: it’s a command-line interface, in which input is done with the keyboard, and the output is sent to the screen in plain text.

The usual way of getting to this alternative interface (though there are others) is to use an app called Terminal, located in the Utilities folder inside your Applications folder. It’s a simple app that doesn’t appear to do much at first glance—it displays a window with a little bit of text in it. But Terminal is in fact the gateway to vast power.

If you read TidBITS, Take Control books, Macworld, or any of the numerous other Mac publications, you’ve undoubtedly seen tips from time to time that begin, “Open Terminal and type in the following...”. Many Mac users find that sort of thing intimidating. What do I click? How do I find my way around? How do I stop something I’ve started? Without the visual cues of a graphical interface, lots of people get stuck staring at that blank window.

If you’re one of those people, this book is for you. It’s also for people who know a little bit about the command line but don’t fully understand what they can do, how to get around, and how to stay out of trouble. By the time you’re finished reading this book and trying out the examples I give, you should be comfortable interacting with your Mac by way of the command line, ready to confidently use Terminal whenever the need arises.

It’s not scary. It’s not hard. It’s just different. And don’t worry—I’ll be with you every step of the way!

Much of this book is concerned with teaching you the skills and basic commands you must know in order to accomplish genuinely useful things later on. If you feel that it’s a bit boring or irrelevant to learn how to list files or change directories, remember: it’s all about the end result. You learn the fundamentals of baking not because measuring flour or preheating an oven is intrinsically interesting, but because you need to know how to do those things in order to end up with cookies. And let me tell you, the cookies make it all worthwhile!

Speaking of food—my all-purpose metaphor—this book doesn’t only provide information on individual ingredients and techniques. In particular, the last chapter is full of terrific, simple command-line recipes that put all this power to good use while giving you a taste of some advanced capabilities I don’t explore in detail. Among many other things, this book shows you:

How to figure out what’s preventing a disk from disconnecting (unmounting or ejecting)

How to tell which apps are currently accessing the internet

How to rename lots of files at once, even if you’re not running Yosemite or later

How to change a number of hidden preferences
How to understand and change file permissions
How to automate command-line activities with scripts

Astute readers may note that some of these tasks can be accomplished with third-party utilities. That’s true, but the command line is infinitely more flexible—and Terminal is free!

I should be clear, however, that this book won’t turn you into a command-line expert. I would need thousands of pages to describe everything you can accomplish with the command line. Instead, my goal is to cover the basics and get you up to a moderate level of familiarity and competence. And, based on feedback from the first two editions of this book, I’ve expanded the scope of this revised third edition to include a number of topics that are a bit more advanced.

Most of my examples work with any version of macOS from 10.6 Snow Leopard on, although a few techniques require later versions; I point those out as we go along. 


No comments:

Post a Comment