BaSnake Mac OS

broken image


This article is part two in a series about using Linux skills when working in a mac operating system. Check out the other articles in the series:

As you now know from my introductory article, macOS is a flavor of UNIX, similar to Linux. But unlike Linux, macOS does not support virtual terminals by default. Instead, you can use the Terminal app (/Applications/Utilities/Terminal) to obtain a command line terminal and BASH shell.

Alternatively, you can type >console as the username at the macOS login prompt (no password needed) to obtain a login prompt that allows you to log directly into a command line terminal and obtain a BASH shell.

Prepare the Mac. Find a Mac that will work with the version of Linux we're using. There is no hard. It contains minimal booter files and kernel, and at /com.apple.recovery.boot/BaseSystem.dmg, a disk image with a stripped-down and tweaked copy of OS X. The booter mounts this volume (it attaches as /dev/disk1), and transfers to OS X running on it. This is the Mac OS X Base System.

After you obtain a BASH shell, you can run many of the same commands you've become accustomed to on Linux. It's also important to note that the same syntax rules that you used on Linux apply to BASH on macOS:

MacOS is a UNIX 03-compliant operating system certified by The Open Group. It has been since 2007, starting with MAC OS X 10.5. The only exception was Mac OS X 10.7 Lion, but compliance was regained with OS X 10.8 Mountain Lion. Amusingly, just as GNU stands for 'GNU's Not Unix,' XNU stands for 'X is Not Unix.'. Sample bash script to show how to parse the macOS version - osversion.sh.

  • All commands are case sensitive.
  • Regular options (-h) and POSIX options (--help) are listed for most commands.
  • The manual pages (man who) and the info pages (info who) list most command documentation. The help command displays BASH function help (help echo).
  • Commands may be chained using semicolons (date; who).
  • The Standard Output of one command may be sent to the Standard Input of another command using a pipe ( | ) symbol (ps aux | less).
  • The Standard Output and Standard Error of a command may be redirected to a file (ls –l /Users > usersfile 2> errorfile).
  • Single quotes protect all special shell characters, double quotes protect most shell characters (variables are one exception), backquotes perform command substitution (echo The date is `date`) and backslash protects the next character (echo You owe $4.50).
  • The ~ metacharacter represents the user's home directories.
  • Tab completes commands and file paths.
  • Ctrl+C cancels a command by sending a SIGINT kill signal to the foreground process.
  • Wildcard metacharacters may be used with commands, and regular expressions may be used within text utilities.
  • BASH control structures and functions may be used to create BASH shell scripts.

NOTE: If you wish to perform system administration as the root user, you must first enable the root user using the Directory Utility app (in /System/Library/CoreServices/Applications). Once you open this app, simply select Change Root Password from the Edit menu.

Common macOS Commands

Below are some common macOS commands, organized by general function. Bookmark this page so you can refer back to it often. Although most options to these commands are identical between Linux and macOS, be sure to view the manual page for commands that you will use in the future.

System Documentation Commands in macOS

  • man Displays/searches the manual page database
  • apropos Searches the manual page database by keyword
  • info Displays/searches the info page database
  • help Displays help on BASH functions

File Management Commands in macOS

  • pwd Displays the current directory
  • cd Changes the current directory
  • ls Lists files
  • file Displays file type
  • locate Finds files using a predefined database
  • which Searches the PATH variable for files
  • find Finds files on the filesystem based on certain criteria
  • cp Copies files and directories
  • mv Moves/renames files and directories
  • rm Removes files and directories
  • rmdir Removes empty directories
  • mkdir Creates empty directories
  • ln Creates hard links; the –s option is used to create symbolic links
  • chown Changes ownership for files and directories
  • chgrp Changes group ownership for files and directories
  • chmod Changes the permissions (mode) on files and directories
  • umask Changes the UMASK variable used to determine default permissions

Text Tools in macOS

  • cat Views (concatenates) the contents of text files to the terminal screen
  • more Views the contents of text files page by page
  • less Views the contents of text files page by page with advanced text features
  • head Displays the beginning of a text file
  • tail Displays the end of a text file
  • sort Sorts lines in text files
  • wc Counts the number of lines, words and characters in a text file
  • grep Searches text files for regular expressions
  • egrep Searches text files for regular expressions (including extended ones)
  • sed Edits text files using search-and-replace functions
  • awk Edits and formats text using predefined functions
  • ·vi (vim) The vi text editor (common to all UNIX systems)
  • emacs The GNU Emacs text editor
  • ·nano A small easy-to-use text editor based on the UNIX pico editor

Filesystem Administration in macOS

  • mount Mounts a filesystem to a mount point directory – alternatively, you can use the mount_filesystem commands (where filesystem is the name of an appropriate filesystem) – see man mount for details.
  • umount Unmounts a filesystem from a mount point directory
  • pdisk May be used to create Apple disk partitions
  • newfs_type Creates a new filesystem on a device (type = apfs, hfs, udf, exfat, msdos)
  • fuser Determines the users accessing a certain file, directory or terminal
  • df Displays disk free space by filesystem
  • du Displays disk free space by directory
  • quota Displays quotas for a certain user
  • edquota Edits user quotas
  • repquota Displays a report on quotas by user
  • quotacheck Updates quota limits on the filesystem

Disk quotas are configured differently in macOS. In Linux, you enable quotas using the appropriate option in /etc/fstab. However, /etc/fstab is not available in macOS. Instead, you must create two files in the root of the filesystem that you wish to enable quotas on (.quota.ops.user and .quota.ops.group).

Shutdown and System State in macOS

  • shutdown Shuts down or reboots the system at a specified time
  • halt Shuts down the system immediately
  • reboot Reboots the system immediately

Compression, Backup and Software in macOS

  • compress Compresses files using a Lempel-Ziv algorithm
  • gzip Compresses files using a standard Lempel-Ziv algorithm
  • bzip2 Compresses files using a block-sorting algorithm
  • tar Used to create small tar archives and tarballs
  • cpio Used to create full filesystem backups using a variety of options
  • make Manages software compiling using gcc and Makefile settings
  • gcc The GNU C compiler used to compile software

BASH Management in macOS

As in Linux, macOS stores its variables in environment files. The /etc/profile and /etc/bashrc files are used by default on the system. Each user can also create their own ~/.bash_profile and ~/.bashrc files. In addition, ~/.bash_logout may be used to perform tasks at shell exit. Here are more BASH management commands for macOS.

  • set Displays all variables in your shell
  • env Displays exported variables in your shell
  • alias Creates special alias variables
  • unalias Removes special alias variables
  • export Creates and exports variables
  • ulimit Sets BASH limits for users (e.g., maximum number of user processes)

Process Management in macOS

  • ps Displays system and user processes (supports BSD-style options only)
  • top Displays top processes and system statistics
  • kill Sends kill signals to processes by process identification number (PID)
  • killall Sends kill signals to processes by name
  • jobs Displays background processes
  • fg Moves a background process to the foreground
  • bg Moves a foreground process to the background
  • nice Changes the priority of a process as it is started
  • renice Changes the priority of a running process
  • at Schedules commands to run at a later time
  • atq Views at jobs
  • atrm Removes an at job
  • crontab Edits user cron tables (used to repetitively schedule commands)

User and Group Administration in macOS

User and group administration differs slightly in macOS from Linux. There are no useradd or userdel commands. Instead, you must use the System Preferences utility to create user accounts properly. User information is stored in a directory database under the /var/db directory. The /etc/shadow file does not exist and the /etc/passwd and /etc/group files exist only to provide information to apps.

  • whoami Displays the current user name
  • who am i Displays your username and computer information
  • groups Displays the current user's group memberships
  • id Prints the User ID (UID) and Group IDs (GIDs) for the current user
  • chfn Changes the user description used by the finger command
  • finger Displays user description information
  • chsh Changes the shell for a user account
  • passwd Changes the password for the current user (the root user may change other user's passwords by specifying the username as an argument)
  • who Displays who is on the system
  • w Displays who is on the system and what they are doing
BaSnake Mac OS

Common Unix Printing System (CUPS) Printing in macOS

  • lp Prints a file (lpr is supported for BSD compatibility)
  • lpstat Views print jobs and printer status (lpq and lpc are supported for BSD
  • compatibility)
  • cancel Removes a print job from the print queue (lprm is supported for BSD
  • compatibility)
  • cupsaccept Allows jobs to enter a print queue
  • cupsreject Prevents jobs from entering a print queue
  • cupsenable Allows jobs to be sent to the printer from the print queue
  • cupsdisable Prevents jobs from leaving the print queue

Network- and Security-Related Commands in macOS

Network devices have different names in macOS. The first ethernet adapter is called en0 (typically wired ethernet), and the second is called en1 (typically wireless ethernet). Ensure that you use System Preferences to change any network parameters, as they are not stored in text files as they are on Linux systems. For example, the /etc/resolv.conf file still exists in macOS and lists DNS servers configured in System Preferences, but it is not used by the system – it is merely there in case an app queries it. The only network-related file that is used actively and may be edited is /etc/hosts (for local host name resolution). Here are more network- and security-related commands in macOS.

  • ifconfig Displays and configures TCP/IP network interfaces
  • ping Tests connectivity between hosts
  • whois Queries domain name registration information
  • arp Views and manages the address resolution protocol (ARP) cache
  • netstat Views TCP/IP network statistics and the routing table
  • route Manages the TCP/IP routing table
  • traceroute Traces an IP packet across routers
  • hostname Sets the system host name
  • host Resolves host names to IP addresses and vice versa
  • nslookup Resolves host names to IP addresses and vice versa
  • dig Resolves host names to IP addresses and vice versa
  • su Switches your user account to another account
  • sudo Performs tasks as another user via entries in the /etc/sudoers file
  • last Displays a detailed list of previous user logins
  • tcpdump Captures packets on a network interface

System and Miscellaneous Commands in macOS

  • date Displays the current date and time
  • exit Exits out of the shell (logout)
  • echo argument Displays the argument to the terminal screen
  • clear Clears the screen
  • uname option Displays system information specified by the option; –a specifies all information
  • uptime Lists system statistics and uptime
  • cal Lists the calendar for the current month
  • banner Prints an ASCII banner
  • iostat Displays input/output (I/O) statistics for the system

Now you've got the macOS basics down, and you know the common commands. In the next installment, I'll be discussing apps. Stay tuned!

Round out your IT skillset with CompTIA Linux+.
BaSnake

Common Unix Printing System (CUPS) Printing in macOS

  • lp Prints a file (lpr is supported for BSD compatibility)
  • lpstat Views print jobs and printer status (lpq and lpc are supported for BSD
  • compatibility)
  • cancel Removes a print job from the print queue (lprm is supported for BSD
  • compatibility)
  • cupsaccept Allows jobs to enter a print queue
  • cupsreject Prevents jobs from entering a print queue
  • cupsenable Allows jobs to be sent to the printer from the print queue
  • cupsdisable Prevents jobs from leaving the print queue

Network- and Security-Related Commands in macOS

Network devices have different names in macOS. The first ethernet adapter is called en0 (typically wired ethernet), and the second is called en1 (typically wireless ethernet). Ensure that you use System Preferences to change any network parameters, as they are not stored in text files as they are on Linux systems. For example, the /etc/resolv.conf file still exists in macOS and lists DNS servers configured in System Preferences, but it is not used by the system – it is merely there in case an app queries it. The only network-related file that is used actively and may be edited is /etc/hosts (for local host name resolution). Here are more network- and security-related commands in macOS.

  • ifconfig Displays and configures TCP/IP network interfaces
  • ping Tests connectivity between hosts
  • whois Queries domain name registration information
  • arp Views and manages the address resolution protocol (ARP) cache
  • netstat Views TCP/IP network statistics and the routing table
  • route Manages the TCP/IP routing table
  • traceroute Traces an IP packet across routers
  • hostname Sets the system host name
  • host Resolves host names to IP addresses and vice versa
  • nslookup Resolves host names to IP addresses and vice versa
  • dig Resolves host names to IP addresses and vice versa
  • su Switches your user account to another account
  • sudo Performs tasks as another user via entries in the /etc/sudoers file
  • last Displays a detailed list of previous user logins
  • tcpdump Captures packets on a network interface

System and Miscellaneous Commands in macOS

  • date Displays the current date and time
  • exit Exits out of the shell (logout)
  • echo argument Displays the argument to the terminal screen
  • clear Clears the screen
  • uname option Displays system information specified by the option; –a specifies all information
  • uptime Lists system statistics and uptime
  • cal Lists the calendar for the current month
  • banner Prints an ASCII banner
  • iostat Displays input/output (I/O) statistics for the system

Now you've got the macOS basics down, and you know the common commands. In the next installment, I'll be discussing apps. Stay tuned!

Round out your IT skillset with CompTIA Linux+.

So, you've decided to download an older version of Mac OS X. There are many reasons that could point you to this radical decision. To begin with, some of your apps may not be working properly (or simply crash) on newer operating systems. Also, you may have noticed your Mac's performance went down right after the last update. Finally, if you want to run a parallel copy of Mac OS X on a virtual machine, you too will need a working installation file of an older Mac OS X. Further down we'll explain where to get one and what problems you may face down the road.

A list of all Mac OS X versions

We'll be repeatedly referring to these Apple OS versions below, so it's good to know the basic macOS timeline.

Cheetah 10.0Puma 10.1Jaguar 10.2
Panther 10.3Tiger 10.4Leopard 10.5
Snow Leopard 10.6Lion 10.7Mountain Lion 10.8
Mavericks 10.9Yosemite 10.10El Capitan 10.11
Sierra 10.12High Sierra 10.13Mojave 10.14
Catalina 10.15

STEP 1. Prepare your Mac for installation

Given your Mac isn't new and is filled with data, you will probably need enough free space on your Mac. This includes not just space for the OS itself but also space for other applications and your user data. One more argument is that the free space on your disk translates into virtual memory so your apps have 'fuel' to operate on. The chart below tells you how much free space is needed.

Note, that it is recommended that you install OS on a clean drive. Next, you will need enough disk space available, for example, to create Recovery Partition. Here are some ideas to free up space on your drive:

  • Uninstall large unused apps
  • Empty Trash Bin and Downloads
  • Locate the biggest files on your computer:

Go to Finder > All My Files > Arrange by size
Then you can move your space hoggers onto an external drive or a cloud storage.
If you aren't comfortable with cleaning the Mac manually, there are some nice automatic 'room cleaners'. Our favorite is CleanMyMac as it's most simple to use of all. It deletes system junk, old broken apps, and the rest of hidden junk on your drive.

Download CleanMyMac for OS 10.4 - 10.8 (free version)

Download CleanMyMac for OS 10.9 (free version)

Download CleanMyMac for OS 10.10 - 10.14 (free version)

STEP 2. Get a copy of Mac OS X download

Normally, it is assumed that updating OS is a one-way road. That's why going back to a past Apple OS version is problematic. The main challenge is to download the OS installation file itself, because your Mac may already be running a newer version. If you succeed in downloading the OS installation, your next step is to create a bootable USB or DVD and then reinstall the OS on your computer.

Ba Snake Mac Os X

How to download older Mac OS X versions via the App Store


If you once had purchased an old version of Mac OS X from the App Store, open it and go to the Purchased tab. There you'll find all the installers you can download. However, it doesn't always work that way. The purchased section lists only those operating systems that you had downloaded in the past. But here is the path to check it:

  1. Click the App Store icon.
  2. Click Purchases in the top menu.
  3. Scroll down to find the preferred OS X version.
  4. Click Download.

This method allows you to download Mavericks and Yosemite by logging with your Apple ID — only if you previously downloaded them from the Mac App Store.

Without App Store: Download Mac OS version as Apple Developer

If you are signed with an Apple Developer account, you can get access to products that are no longer listed on the App Store. If you desperately need a lower OS X version build, consider creating a new Developer account among other options. The membership cost is $99/year and provides a bunch of perks unavailable to ordinary users.

Nevertheless, keep in mind that if you visit developer.apple.com/downloads, you can only find 10.3-10.6 OS X operating systems there. Newer versions are not available because starting Mac OS X Snow Leopard 10.7, the App Store has become the only source of updating Apple OS versions.

Purchase an older version of Mac operating system

You can purchase a boxed or email version of past Mac OS X directly from Apple. Both will cost you around $20. For the reason of being rather antiquated, Snow Leopard and earlier Apple versions can only be installed from DVD.

Buy a boxed edition of Snow Leopard 10.6
Get an email copy of Lion 10.7
Get an email copy of Mountain Lion 10.8

Ba Snake Mac Os Catalina

The email edition comes with a special download code you can use for the Mac App Store. Note, that to install the Lion or Mountain Lion, your Mac needs to be running Snow Leopard so you can install the newer OS on top of it.

How to get macOS El Capitan download

If you are wondering if you can run El Capitan on an older Mac, rejoice as it's possible too. But before your Mac can run El Capitan it has to be updated to OS X 10.6.8. So, here are main steps you should take:

1. Install Snow Leopard from install DVD.
2. Update to 10.6.8 using Software Update.
3. Download El Capitan here.

Ba Snake Mac Os Download

'I can't download an old version of Mac OS X'

If you have a newer Mac, there is no physical option to install Mac OS versions older than your current Mac model. For instance, if your MacBook was released in 2014, don't expect it to run any OS released prior of that time, because older Apple OS versions simply do not include hardware drivers for your Mac.

But as it often happens, workarounds are possible. There is still a chance to download the installation file if you have an access to a Mac (or virtual machine) running that operating system. For example, to get an installer for Lion, you may ask a friend who has Lion-operated Mac or, once again, set up a virtual machine running Lion. Then you will need to prepare an external drive to download the installation file using OS X Utilities.

After you've completed the download, the installer should launch automatically, but you can click Cancel and copy the file you need. Below is the detailed instruction how to do it.

STEP 3. Install older OS X onto an external drive

The following method allows you to download Mac OS X Lion, Mountain Lion, and Mavericks.

  1. Start your Mac holding down Command + R.
  2. Prepare a clean external drive (at least 10 GB of storage).
  3. Within OS X Utilities, choose Reinstall OS X.
  4. Select external drive as a source.
  5. Enter your Apple ID.

Now the OS should start downloading automatically onto the external drive. After the download is complete, your Mac will prompt you to do a restart, but at this point, you should completely shut it down. Now that the installation file is 'captured' onto your external drive, you can reinstall the OS, this time running the file on your Mac.

  1. Boot your Mac from your standard drive.
  2. Connect the external drive.
  3. Go to external drive > OS X Install Data.

Locate InstallESD.dmg disk image file — this is the file you need to reinstall Lion OS X. The same steps are valid for Mountain Lion and Mavericks.

How to downgrade a Mac running later macOS versions

Ba Snake Mac Os 11

If your Mac runs macOS Sierra 10.12 or macOS High Sierra 10.13, it is possible to revert it to the previous system if you are not satisfied with the experience. You can do it either with Time Machine or by creating a bootable USB or external drive.
Instruction to downgrade from macOS Sierra

Instruction to downgrade from macOS High Sierra

Instruction to downgrade from macOS Mojave

Instruction to downgrade from macOS Catalina

Before you do it, the best advice is to back your Mac up so your most important files stay intact. In addition to that, it makes sense to clean up your Mac from old system junk files and application leftovers. The easiest way to do it is to run CleanMyMac X on your machine (download it for free here).

Visit your local Apple Store to download older OS X version

If none of the options to get older OS X worked, pay a visit to nearest local Apple Store. They should have image installations going back to OS Leopard and earlier. You can also ask their assistance to create a bootable USB drive with the installation file. So here you are. We hope this article has helped you to download an old version of Mac OS X. Below are a few more links you may find interesting.





broken image