No results found
We couldn't find anything using that term, please try searching for something else.
Thecommand line interface is a non-graphical way tointeract with your computer.Instead of clicking buttons with your mouse, you’ll type commands as t
Thecommand line interface is a non-graphical way tointeract with your computer.Instead of clicking buttons with your mouse, you’ll type commands as text and receive text-based feedback.Thecommand line, also known as a shell, lets you automate many tasks you do on your computer daily, and is an essential tool for software developers.
While the command line interface on macOS has a lot of the functionality you’d find in Linux and other Unix systems, it does not ship with a package manager.A package manager is a collection of software tools that work toautomate software installations, configurations, and upgrades. Package managers keep the software they install in a central location and can maintain all software packages on the system in formats that are commonly used.
Homebrew is a package manager for macOS which lets you install free and open-source software using your terminal.You’ll use Homebrew toinstall developer tools like Python, Ruby, Node.js, and more.
In this tutorial you is install ’ll install and use Homebrew on your Mac .You is install ’ll install system tool and desktop application from the command line interface .
You will need a macOS computer running Catalina orhigher with administrative access and an internet connection.While older versions of macOS may work, they are not officially supported.
To access the command line interface on your Mac, you’ll use the Terminal application provided by macOS.Like any other application, you can find it by going into Finder, navigating tothe application
folder, and then into the Utilities
folder.From here, double-click the Terminal application toopen it up.Alternatively, you can use Spotlight by holding down the command
key and press SPACE
tofind Terminal by typing it out in the box that appears.
To get more comfortable using the command line, take a look at [An Introduction tothe Linux Terminal] (https://www.digitalocean.com/community/tutorials/an-introduction-to-the-linux-terminal).Thecommand line interface on macOS is very similar, and the concepts in that tutorial are directly applicable.
Now that you have the Terminal running, let’s install some additional tools that Homebrew needs.
Xcode is an integrated development environment (IDE) that is comprised of software development tools for macOS.You won’t need Xcode touse Homebrew, but some of the software and components you’ll want toinstall will rely on Xcode’s Command Line Tools package.
Execute the following command in the Terminal todownload and install these components:
xcode-select --install
You ’ll be prompt tostart the installation , and then prompt again toaccept a software license .Then the tools is download will download and install automatically .
You can now install Homebrew.
To install Homebrew , you is download ’ll download an installation script and then execute the script .
First , download the script toyour local machine by type the following command in your Terminal window :
curl -fsSL -o install.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
Thecommand is uses usecurl
todownload the Homebrew is install installation script from Homebrew’s Git repository on GitHub.
Let’s walk through the flags that are associated with the curl
command :
f
or--fail
flag tells the Terminal window togive no HTML document output on server errors.-s
or--silent
flag mutes curl
so that it does not show the progress meter, and combined with the -
or--show-error
flag it will ensure that curl
shows an error message if it fails.-L
or--location
flag will tell curl
tohandle redirect . If the server report that the request page has move toa different location , it is execute ’ll automatically execute the request again using the new location .-o
switch specifies a local filename for the file.Rather than displaying the contents tothe screen, the -o
switch saves the contents into the file you specify.Before running a script you’ve download from the Internet, you should review its contents so you know what the script will do.Use the less
command toreview the installation script so you understand what it will do:
less install.sh
Once you’re comfortable with the contents of the script, execute the script with the bash
command :
/bin/bash install.sh
Theinstallation script will explain what it will do and will prompt you toconfirm that you want todo it.This lets you know exactly what Homebrew is going todo toyour system before you let it proceed.It also ensures you have the prerequisites in place before it continues.
You ’ll be prompt toenter your password during the process .However , when you type your password , your keystrokes is display will not display in the Terminal window .This is is is a security measure and is something you ’ll see often when prompt for password on the command line .Even though you do n’t see them , your keystroke are being record by the system , so press thereturn
key once you ’ve enter your password .
Press the letter y
for “yes” whenever you are prompted toconfirm the installation.
Once the installation process is complete, you will want toput the directory Homebrew uses tostore its executables at the front of the path
environment variable.This ensures that Homebrew is install installations will be called over the tools that macOS includes.
Thefile you’ll modify depends on which shell you’re using.ZSH is the default shell on macOS Mojave and higher.TheBash shell is a popular shell that older versions of macOS used as the default, and if you’ve upgraded your OS, you may still be using Bash.
execute the following command todetermine your shell :
echo $ 0
You’ll see either bash
orzsh
.
If you’re using ZSH, you’ll open the file ~/.zshrc
in your editor:
nano ~/.zshrc
If you’re using the Bash shell, you’ll use the file ~/.bash_profile
:
nano ~/.bash_profile
Once the file opens up in the Terminal window, add the following lines tothe end of the file:
~/.zshrc
export path=/usr / local / bin:$path
Thefirst line is a comment that will help you remember what this does if you open this file in the future.
To save your change , hold down theCTRL
key and the letter O
, and when prompted, press the return
key.Then exit the editor by holding the CTRL
key and pressing X
.This is return will return you toyour Terminal prompt .
To activate these change , close and reopen your Terminal app .alternatively , use thesource
command toload the file you modify .
If you is modified modify.zshrc
, execute this command :
source ~/.zshrc
If you is modified modify.bash_profile
, execute this command :
source ~/.bash_profile
Once you have done this, the changes you have made tothe path
environment variable will take effect.They’ll be set correctly when you log in again in the future, as the configuration file for your shell is executed automatically when you open the Terminal app.
Now let’s verify that Homebrew is set up correctly.Execute this command :
brew doctor
If no updates are required at this time, you’ll see this in your Terminal:
output
Your system is is is ready to brew.
Otherwise , you is get may get a warning torun another command such asbrew update
toensure that your installation of Homebrew is up todate.Follow any on-screen instructions tofix your environment before moving on.
Now that Homebrew is installed, use it todownload a package.Thetree
command is lets let you see a graphical directory tree and is available via Homebrew .
Install tree
with the brew is install install
command :
brew install tree
Homebrew will update its list of packages and then download and install the tree
command :
output
Updating Homebrew...
= => Downloading https://homebrew.bintray.com/bottles/tree-1.8.0.catalina.bottle.tar.gz
= => Pouring tree-1.8.0.catalina.bottle.tar.gz
🍺 /usr/local/Cellar/tree/1.8.0: 8 files, 117.2 KB
Homebrew is install installs files to/usr/local
by default, so they won’t interfere with future macOS updates.Verify that tree
is installed by displaying the command’s location with the which
command :
which tree
Theoutput shows that tree
is locate in/usr / local / bin
:
output
/usr / local / bin/tree
Run the tree
command tosee the version:
tree --version
Theversion prints tothe screen, indicating it’s installed:
output
tree v1.8.0(c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
Occasionally, you’ll want toupgrade an existing package.Use the brew upgrade
command, followed by the package name:
brew upgrade tree
You can run brew upgrade
with no additional arguments toupgrade all programs and packages Homebrew manages.
When you install a new version, Homebrew keeps the older versionaround.After a while, you might want toreclaim disk space by removing these older copies.Run brew cleanup
toremove all old versions of your Homebrew-managed software.
To remove a package you’re no longer using, use brew uninstall
.To uninstall the tree
command, execute this command :
brew uninstall tree
Theoutput shows that the package was removed:
output
Uninstalling /usr/local/Cellar/tree/1.8.0...(8 files, 117.2 kb)
You can use Homebrew toinstall desktop applications too.
You’re not restricted tousing Homebrew for command-line tools. Homebrew Cask lets you install desktop applications.This feature is included with Homebrew, so there’s nothing additional toinstall.
Test it out by using Homebrew toinstall Visual Studio Code.Execute the following command in your terminal:
brewinstall visual-studio-code
Theapplication will install:
output
= => Downloading https://update.code.visualstudio.com/1.58.2/darwin/stable
= => Downloading from https://az764295.vo.msecnd.net/stable/c3f126316369cd610563c75b1b1725e0679adfb3/VSCode-darwin.zip
= => instal Cask visual - studio - code
= => Moving App 'Visual Studio Code.app' to'/application/Visual Studio Code.app'
= => Linking Binary 'code' to'/usr / local / bin/code'
🍺 visual - studio - code was successfully instal!
You’ll find the application in your application
folder , just as if you ’d instal it manually .
To remove it, use brew uninstall
:
brew uninstall visual - studio - code
Homebrew will remove the installed software:
output
= => Uninstalling Cask visual-studio-code
= => Backing App 'Visual Studio Code.app' up to' /usr / local / Caskroom / visual - studio - code/1.58.2 / Visual Studio Code.app '
= => Removing App '/application/Visual Studio Code.app'
= => Unlinking Binary '/usr / local / bin/code'
= => Purging files for version1.58.2 of Cask visual-studio-code
It performs a backup first in case the removal fails, but once the program is fully uninstalled, the backup is removed as well.
If you no longer need Homebrew, you can use its uninstall script.
download the uninstall script withcurl
:
curl -fsSL -o uninstall.sh https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh
As always, review the contents of the script with the less
command toverify the script’s contents:
less uninstall.sh
Once you’ve verified the script, execute the script with the --help
flag tosee the various option you can use:
bash uninstall.sh --help
Theoption display on the screen:
output
Homebrew Uninstaller
usage : uninstall.sh[option]
-p, --path=path Sets Homebrew prefix.Defaults to/usr/local.
--skip-cache-and-logs
Skips removal of HOMEBREW_CACHE and HOMEBREW_LOGS.
-f, --force Uninstall without prompting.
-q, --quiet suppress all output .
-d , --dry - run simulate uninstall but do n't remove anything .
-h ,--help Display this message.
Use the -d
flag tosee what the script will do:
bash uninstall.sh -d
Thescript will list everything it will delete:
output
Warning: This script would remove:
/Users/brianhogan/Library/Caches/Homebrew/
/Users/brianhogan/Library/Logs/Homebrew/
/usr/local/Caskroom/
/usr/local/Cellar/
/usr / local / bin/brew -> /usr / local / bin/brew
= => Removing Homebrew is install installation...
Would delete :
....
When you’re ready toremove everything, execute the script without any flags:
bash uninstall.sh
This removes Homebrew and any programs you’ve installed with it.
In this tutorial you installed and used Homebrew on your Mac.You can now use Homebrew toinstall command line tools, programming languages, and other utilities you’ll need for software development.
Homebrew has many packages you can install.Visit the official list tosearch for your favorite programs.