Cygwin Mac

Speaking UNIX

Cygwin provides a complete UNIX shell—from awk to zcat—on Windows

Cygwin terminal free download - ZOC Terminal, Telconi Terminal, MacPilot, and many more programs. Welcome to the P7ZIP Home. P7zip is a port of 7za.exe for POSIX systems like Unix (Linux, Solaris, OpenBSD, FreeBSD, Cygwin, AIX.), MacOS X and also for BeOS and Amiga. Cygwin.command(for Mac) For Mac, we do not rely on the UNIX functionality of Cygwin. In fact, the Mac is already based on BSD UNIX. You need to first start up the Terminal application from Finder/Applications/Utilities. Cygwin provides some basic Unix functionality for Windows and an environment to install a lot of Unix applications. While Mac OS X includes a lot of this already there are additional packages like.

Content series:

This content is part # of # in the series: Speaking UNIX

Cygwin mac commands
http://www.ibm.com/developerworks/library?series_title_by=speaking+unix

This content is part of the series:Speaking UNIX

Stay tuned for additional content in this series.

If you're a regular reader of this column, you've likely now mastered much of the UNIX lingo. Colloquialisms such as 'pipe the output,' 'kill the process,' and 'use a wildcard'—strange phrases to the uninitiated—should be familiar and comfortable.

Alas, UNIX isn't the only tongue spoken in the machine room. IBM® mainframe folks speak cants of 'z,' such as IBM z/OS® and System z9 Virtual Machine (z/VM); harried embedded systems developers jabber in eCos; and still others chit-chat in various argots of UNIX, such as Linux®, FreeBSD, Sun Solaris, and Mac OS X. Modern information technology is a latter-day Babel.

Of course, a great many also speak the Windows vernacular, although most are versed only in Windows' point-and-click patois. After some 20-odd years of revisions, the predominance of Windows users have forgotten the arcane DOS dialect.

Indeed, compared to a UNIX shell, the Windows COMMAND utility is woefully underpowered; hence, UNIX users typically find Windows a frustrating platform. Moreover, Windows can be especially vexing for UNIX software developers accustomed to an expansive and rich set of command-line tools. To UNIX developers, using Windows is akin to visiting a strange and foreign land.

Luckily, Cygwin (see Related topics) provides a familiar destination within Windows, like finding a McDonald's in France. (Royale with cheese, anyone?)

Cygwin is a UNIX-like shell environment for Windows. It consists of two components: a UNIX API library to emulate many of the features that the UNIX operating system provides, and adaptations of the Bash shell and a plethora of UNIX utilities to provide the familiar UNIX command-line interface. The former component is provided as a Windows Dynamic Link Library (DLL). The latter component is a collection of individual programs —many built from source code unchanged from UNIX—based on the Cygwin DLL. Combined, the two give you all the comforts of your UNIX home directory, sweet home.

In this month's Speaking UNIX column, you install Cygwin, explore its command-line interface (CLI), and build open source software not included in the standard Cygwin distribution to experience how easy it is to port (at least some) UNIX applications to the emulation environment.

Installing Cygwin

Unlike other software presented here, Cygwin uses the Windows Installer. The Cygwin setup.exe file installs the software anew and is re-used any time you want to add, change, or upgrade components of your Cygwin configuration.

Open a browser on your Windows system, and point to http://cygwin.com/setup.exe to download the Cygwin installer. The installer itself is very small (about 600KB), because the bulk of the Cygwin software is subsequently downloaded during the setup process. After your download succeeds, perform the following steps to install Cygwin:

  1. Run the Setup program. Figure 1 shows the Cygwin welcome screen.
    Figure 1. The first of many dialog boxes presented during Cygwin setup
  2. Click Next to advance to the next screen and choose the type of installation you want to perform.
  3. Click Install from Internet.
  4. Click Next, then choose an installation directory.

    The window in which you configure your installation is shown in Figure 2.

    Figure 2. Cygwin installation options

    In most cases, the recommended installation options are suitable, but you can customize with a few caveats:

    • Do not install Cygwin in the root directory of your Windows system, such as C: It's best to install Cygwin in its own subdirectory, such as the default—C:cygwin—or perhaps C:Program Filescygwin. (The target directory, whatever you choose, becomes the root directory—the /—of your emulated UNIX environment. For example, if you install to C:cygwin, the virtual /usr/bin can actually be found in C:cygwinusrbin.)
    • Do not choose Just Me for the Install For option.
    • Set the Default Text File type to Unix to maximize compatibility with existing files and files stored on other UNIX machines.
  5. Click Next.

    In the window that appears, choose a directory in which to store the data Cygwin requires. Do not choose the Cygwin directory you selected in the previous step. If possible, create or choose a directory on a drive with at least 1GB of free space.

  6. Click Next again, and choose the type of Internet connection you use. Direct Connection is typically apropos.
  7. Click Next again.

    In a moment, Cygwin downloads its list of current mirror sites and prompts you to choose one, as shown in Figure 3. When in doubt, choose a site within close proximity.

    Figure 3. Choose the installation site you feel is reliable or is in close proximity

    After a brief delay, the installer displays a complete list of available categories and packages. Figure 4 shows a partial catalog. Click on a plus sign (+) to expand the corresponding category; click a 'loop' to cycle between Skip (which omits the package) and all available versions of the respective package. If Cygwin provides multiple versions of a utility, pick the instance that meets your requirements. By the way, the B column, if selected, downloads the binary package; if the S is selected, the source is downloaded, too.

    Figure 4. Choose the packages and instances that best suit your needs

    More than 1,000 packages are available within Cygwin, so choose only the categories and packages you need. (Installing all of the Cygwin bundles takes up more than 800MB of disk space.) After all, you can always add an entire category or a single package in the future: Simply re-run the Cygwin installer. (You can also remove or update a package at any time with the same installer.) To quickly determine whether your favorite UNIX utility is available within Cygwin, search the Cygwin package list (see Related topics).

  8. When you've chosen the tools you want, click Next, and the download process begins!

    The status bars reflect each package download, overall download headway, and disk usage, respectively. Figure 5 is a snapshot taken during installation on my test machine.

    Figure 5. Cygwin downloads a great deal of software, so be patient

    Finally, the Setup application installs the software and (optionally) adds shortcuts to your Start menu and desktop. Click Finish.

  9. Launch Cygwin by using the Start menu or by double-clicking the Cygwin icon (if you installed those shortcuts), or you can execute the Cygwin script found in your Cygwin directory (such as C:cygwinCygwin.bat).

    Figure 6 shows Cygwin as it starts the first time: It creates your home directory, seeds shell startup files, and presents the prompt. You can now run UNIX commands!

    Figure 6. Presto! Now you can use UNIX commands in Windows!

    For example, try ls -a or type touch. The latter command indicates that touch is the executable /usr/bin/touch.

The best of UNIX in Windows (and vice versa)

Cygwin is a near-complete emulation of the UNIX shell within Windows. In fact, it marries the two operating systems quite nicely. For example, run the command df -h to display an inventory of free disk space on your 'UNIX' machine. Figure 7 shows the result.

Figure 7. Is that a UNIX file system on Windows or a Windows file system on UNIX? Yes!

As mentioned earlier, the Cygwin installation directory acts as the root directory of your virtual UNIX system. Cygwin simply maps subdirectories in its installation directory to familiar UNIX equivalents. It also provides the Windows drives as individual volumes, such as /cygwin/c. You can use such a virtual path to launch Windows programs. Try it: Type /cygwin/c/Program Files/Internet Explorer/IEXPLORE.EXE to launch Windows Internet Explorer® from the command line. (You can also use the Tab key to automatically expand elements of the path.)

By the way, if you want to convert a Windows path name to its UNIX equivalent or vice versa, try the built-in command cygpath. By default, cygpath produces the UNIX path name. Use the -w option to produce a Windows path.

Other niceties provide helpful bridges between the two environments:

  • Cygwin provides its own lpr (/usr/bin/lpr rather than Windows' own LPR.EXE) to print from the UNIX emulation directly. Simply set the PRINTER environment variable to a Cygwin UNC such as serverprinter_name or //server/printer_name—either slash direction works, as in all other parts of Cygwin.
  • Symbolic links created with ln -s in Cygwin are interpreted as shortcuts in Windows. Reflexively, Windows shortcuts are interpreted as symbolic links. Further, you can use a Windows shortcut to launch a UNIX command with parameters.
  • And because you have a full Bash shell at your disposal, you can use all the aforementioned compatibility features (among others) to write UNIX shell scripts to maintain Windows!

    For example, you can use UNIX find to hunt for data on your drives. Here's a tip: it's common to use spaces in a Windows file name. To preserve an entire file name (remember, UNIX arguments are separated by white space), be sure to use find -print0 and its companion, xargs -0.

How to update and extend your Cygwin

As mentioned at the onset, you can add, remove, and update Cygwin categories and packages at any time by (re-)running the Cygwin installer. Let's add a few software development packages to prepare for building additional code from source, as you typically do on a traditional UNIX system.

Run the Cygwin setup.exe application again, and march through the initial dialogs until you return to the Select Packages window, shown in Figure 4. Expand the Devel category, and use the recycle control to select the highest-numbered versions of the following:

  • autoconf2.1
  • automake1.10
  • binutils
  • gcc-core
  • gcc4-core
  • gdb
  • pcre
  • pcre-devel

After making all selections (which may automatically choose additional packages to satisfy dependencies), click Next to start the update. As before, the download and installation process may take some time—the development packages tend to be quite large.

In the meantime, open a browser window and point to http://ftp.gnu.org/gnu/wget/wget-1.11.4.tar.gz to download the latest source code of the GNU wget utility. (If you haven't used it before, wget is a command-line tool to download virtually anything. For more information about this tool, see Related topics) Using Cygwin, copy the file to your home directory in Cygwin, and expand the tarball. Listing 1 shows the contents of the tarball.

Cygwin Mac
Listing 1. Contents of wget-1.11.4.tar

When the Cygwin download and installation process finishes, click Finish. You should now be ready to build the wget utility from source.

To test the new utility, run it within Cygwin and the download the wget source code:

In a moment, you should have a new source tarball. It's easiest to pull utilities from the Cygwin repository using the Cygwin installer, but you can build source you download—or your own source code—within Cygwin. The full suite of UNIX development tools, including the most popular scripting languages, are available within Cygwin.

You can even build native Windows WIN32 applications with the UNIX compilers and tools found in Cygwin if you don't have something like Microsoft Visual Studio®. (These applications will not run on UNIX. To build a Windows application to run on UNIX, consider WINE. See Related topics for more information.)

Familiar, powerful, and useful

Cygwin isn't a perfect emulation of UNIX, but it's a comforting surrogate. The documentation for the core components is good and especially forthcoming, describing limitations in the emulation DLL and security risks. If you want to port a complex UNIX package to Cygwin, consult the Developer's Guide (see Related topics) to measure Cygwin's support for your API needs.

Perhaps the best feature of Cygwin is its integration with Windows. To boost productivity, drop to Cygwin and use its UNIX-like command line to manipulate the system. One suggestion: Extend your shell PATH variable to include subdirectories in Windows' Program Files to launch any binary in your path by simply typing its name.

Better yet, Cygwin can manage multiple jobs in the same window. Press Control-Z to suspend a running job; type bg and fg to run a job in the background and foreground, respectively; and type jobs to manage the list of jobs. Of course, Cygwin also redirects input and output and pipes output from one command to another.

Cygwin mac iso

Cygwin: It's better than a Royale with cheese.

Downloadable resources

Related topics

  • Speaking UNIX: Check out other parts in this series.
  • Learn more about the features of Cygwin.
  • Read the official Cygwin User's Guide.
  • Check out the Cygwin package list.
  • Explore the Cygwin API Reference to learn more about compatibility with UNIX and how to port to Cygwin.
  • Learn more about UNIX shells.
  • Learn more about WINE, an open source implementation of the Windows API.
  • Download Cygwin installer for Windows.
  • Learn more about and download wget.

The Terminal app allows you to control your Mac using a command prompt. Why would you want to do that? Well, perhaps because you’re used to working on a command line in a Unix-based system and prefer to work that way. Terminal is a Mac command line interface. There are several advantages to using Terminal to accomplish some tasks — it’s usually quicker, for example. In order to use it, however, you’ll need to get to grips with its basic commands and functions. Once you’ve done that, you can dig deeper and learn more commands and use your Mac’s command prompt for more complex, as well as some fun, tasks.

Curated Mac apps that keep your Mac’s performance under control. Avoid Terminal commands, avoid trouble.

Download Free

How to open Terminal on Mac

The Terminal app is in the Utilities folder in Applications. To open it, either open your Applications folder, then open Utilities and double-click on Terminal, or press Command - spacebar to launch Spotlight and type 'Terminal,' then double-click the search result.

You’ll see a small window with a white background open on your desktop. In the title bar are your username, the word 'bash' and the dimensions of the window in pixels. Bash stands for 'Bourne again shell'. There are a number of different shells that can run Unix commands, and on the Mac Bash is the one used by Terminal.

If you want to make the window bigger, click on the bottom right corner and drag it outwards. If you don’t like the black text on a white background, go to the Shell menu, choose New Window and select from the options in the list.

If Terminal feels complicated or you have issues with the set-up, let us tell you right away that there are alternatives. MacPilot allows to get access to over 1,200 macOS features without memorizing any commands. Basically, a third-party Terminal for Mac that acts like Finder.

For Mac monitoring features, try iStat Menus. The app collects data like CPU load, disk activity, network usage, and more — all of which accessible from your menu bar.

Basic Mac commands in Terminal

The quickest way to get to know Terminal and understand how it works is to start using it. But before we do that, it’s worth spending a little time getting to know how commands work. To run a command, you just type it at the cursor and hit Return to execute.

Every command is made up of three elements: the command itself, an argument which tells the command what resource it should operate on, and an option that modifies the output. So, for example, to move a file from one folder to another on your Mac, you’d use the move command 'mv' and then type the location of the file you want to move, including the file name and the location where you want to move it to.

Let’s try it.

  1. Type cd ~/Documentsthen and press Return to navigate to your Home folder.

  2. Type lsthen Return (you type Return after every command).

You should now see a list of all the files in your Documents folder — ls is the command for listing files.

Cygwin Mac

To see a list of all the commands available in Terminal, hold down the Escape key and then press y when you see a question asking if you want to see all the possibilities. To see more commands, press Return.

Unix has its own built-in manual. So, to learn more about a command type man [name of command], where 'command' is the name of the command you want find out more about.

Terminal rules

There are a few things you need to bear in mind when you’re typing commands in Terminal, or any other command-line tool. Firstly, every character matters, including spaces. So when you’re copying a command you see here, make sure you include the spaces and that characters are in the correct case.

Cygwin 64bit

You can’t use a mouse or trackpad in Terminal, but you can navigate using the arrow keys. If you want to re-run a command, tap the up arrow key until you reach it, then press Return. To interrupt a command that’s already running, type Control-C.

Commands are always executed in the current location. So, if you don’t specify a location in the command, it will run wherever you last moved to or where the last command was run. Use the cdcommand, followed by a directory path, like in Step 1 above, to specify the folder where you want a command to run.

There is another way to specify a location: go to the Finder, navigate to the file or folder you want and drag it onto the Terminal window, with the cursor at the point where you would have typed the path.

Cygwin Mac Bootable

Here’s another example. This time, we’ll create a new folder inside your Documents directory and call it 'TerminalTest.'

  1. Open a Finder window and navigate to your Documents folder.

  2. Type cd and drag the Documents folder onto the Terminal window.

  3. Now, type mkdir 'TerminalTest'

Go back to the Finder, open Text Edit and create a new file called 'TerminalTestFile.rtf'. Now save it to the TerminalTest folder in your Documents folder.

Cygwin mac catalina

In the Terminal window, type cd ~/Documents/TerminalTest then Return. Now type lsand you should see 'TerminalTestFile' listed.

To change the name of the file, type this, pressing Return after every step:

  1. cd~/Documents/Terminal Test

  2. mv TerminalTestFile TerminalTestFile2.rtf

That will change the name of the file to 'TerminalTestFile2'. You can, of course, use any name you like. The mv command means 'move' and you can also use it to move files from one directory to another. In that case, you’d keep the file names the same, but specify another directory before typing the the second instance of the name, like this:

mv ~/Documents/TerminalTest TerminalTestFile.rtf ~/Documents/TerminalTest2 TerminalTestFile.rtf

More advanced Terminal commands

Terminal can be used for all sorts of different tasks. Some of them can be performed in the Finder, but are quicker in Terminal. Others access deep-rooted parts of macOS that aren’t accessible from the Finder without specialist applications. Here are a few examples.

Copy files from one folder to another
  1. In a Terminal window, type ditto [folder 1] [folder 1] where 'folder 1' is the folder that hosts the files and 'folder 2' is the folder you want to move them to.

  2. To see the files being copied in the Terminal window, type -v after the command.

Download files from the internet

You’ll need the URL of the file you want to download in order to use Terminal for this.

  1. cd ~/Downloads/

  2. curl -O [URL of file you want to download]

If you want to download the file to a directory other than your Downloads folder, replace ~/Downloads/ with the path to that folder, or drag it onto the Terminal window after you type the cd command.

Change the default location for screenshots

If you don’t want macOS to save screenshots to your Desktop when you press Command-Shift-3, you can change the default location in Terminal

  1. defaults write com.apple.screencapture location [path to folder where you want screenshots to be saved]

  2. Hit Return

  3. killall SystemUIServer

  4. Hit Return

Cygwin Machine

Change the default file type for screenshots

By default, macOS saves screenshots as .png files. To change that to .jpg, do this:

Cygwin Mac Iso

  1. defaults write com.apple.screencapture type JPG

  2. Press Return

  3. killall SystemUIServer

  4. Press Return

Delete all files in a folder

The command used to delete, or remove, files in Terminal is rm. So, for example, if you wanted to remove a file in your Documents folder named 'oldfile.rtf' you’d use cd ~/Documents to go to your Documents folder then to delete the file. As it stands, that will delete the file without further intervention from you. If you want to confirm the file to be deleted, use -i as in rm -i oldfile.rtf

To delete all the files and sub-folders in a directory named 'oldfolder', the command is rm -R oldfolder and to confirm each file should be deleted, rm -iR oldfolder

Just because you can use Terminal to delete files on your Mac, doesn’t mean you should. It’s a relatively blunt instrument, deleting only those files and folders you specify.

Mac
Another way to free up space

If your goal in removing files or folders is to free up space on your Mac, or to remove junk files that are causing your Mac to run slowly, it’s far better to use an app designed for the purpose. CleanMyMac X is one such app.

It will scan your Mac for files and recommend which ones you can delete safely, as well as telling you how much space you’ll save. And once you’ve decided which files to delete, you can get rid of them in a click. You can download CleanMyMac here.


As you can see, while Terminal may look scary and seem like it’s difficult to use, it really isn’t. The key is learning a few commands, such as those we’ve outlined above, and getting to know the syntax for those commands.

However, you should be careful when using Terminal, it’s a powerful tool that has deep access to your Mac’s system files. Check commands by googling them if you’re not sure what they do. And if you need to delete files to save space, use an app like CleanMyMac X to do it. It’s much safer!

These might also interest you: