Category Archives: Linux

Learn the macOS Command Line

(See my other macOS and Linux related posts) – While “Unix for the Beginning Mage” is not new (the sources I have found date back to 2005) it is still relevant today.

You may, or may not, know that by using a Mac with macOS, you are using a system based upon the Unix operating system. When Apple acquired NeXT in 1996, it also gained the use of the NeXTSTEP operating system. NeXTSTEP had its roots in an earlier Unix system, BSD. Apple released macOS (then called Mac OS X) in 2001.

Now one of the notable things about macOS is that instead of using the traditional user interface to the operating system, NeXT had infused NeXTSTEP with a number of innovative GUI (Graphical User Interface) features which made the system far more user-friendly. For most user operations, they rarely, if ever, need to open up a Terminal and interact with the system through the command line.

This short book is for anyone who wants to open up a terminal and give commands to their system through just the keyboard. The book is only 100 pages long, so it is not an in-depth look at using the command line. It is enough to get someone started and guide them through the essentials.

You can download the free PDF at Unix for the Beginning Mage. As you might expect from the name, the book takes a bit of a tongue-in-cheek approach to learning some of the basic features of the Unix shell.

If you found this of interest you might also be interested in my CLI (Command Line Interface) page.

 

macOS New App Release – Server Ranger 2.5

serverranger_screenshot.png

Product Announcements – LibertyApp Ltd of Belfast, United Kingdom has released Server Ranger 2.5, an update to their website and server monitoring solution for Mac, Windows, and Linux. The new version includes stability improvements, introduces Raspberry Pi support and, for the first time, offers the Mac version on and off the Mac App Store.

Server Ranger monitors your devices, websites, and servers so you don’t have to, automatically sending you alerts when things go wrong. Create alert policies for websites and servers that have a slow response or go offline. Get emails, SMS messages and other alerts automatically sent to you or your colleagues. Analyze the log files for server error messages.

Server Ranger is already in use around the world, from home offices to IT departments to schools. It has been in the Top 5 and Top 10 App Store charts in several categories and in several countries and won a Xojo Design Award in 2018.

Per-Device Policies:
Choose from Critical, Normal or Less important default policies. Or create a custom policy for each server.

Smart Interface:
Nodes performing properly are in green. Yellow indicates the node is online but slow. Red is for offline. Only interested in 1 device? Switch to Single Server Mode to reduce on-screen clutter.

Alerts:
Emails, SMS text messages (*), notifications, sound alerts and more. Decide if alerts should repeat or not. Only receive alerts after a timeframe of your choice. It’s all entirely customizable. (*) Optional SMS alerts use the Twilio service and costs may vary.

Not Just Ping:
Server Ranger can Ping any device to check if it is online and performing properly. But it’s possible for a server to be online yet still have website problems so Server Ranger does more than just Ping. Check HTTP headers are successfully downloaded and in a timely manner. Log in to email servers and test for availability. You choose the type of check that Server Ranger performs.

Statistics:
Server Ranger logs every response from your devices. Graphs show uptime and performance. Spot patterns of poor performance and print or export the log to a CSV file.

Big Screen Mode:
Open the Overview window and get a glance at all your servers. Airplay to a screen on the wall or another monitor.

Support:
Fast, friendly, professional support is just an email away. Stay up to date with a free newsletter with Server Ranger news and tips.

Release Notes:

  • Web server port setting is now always used
  • New info pane for detailed information when a log entry is selected
  • Email alert fixes for some email servers
  • Various bug fixes and optimizations
  • Now includes a built-in version checker

Updates: Server Ranger 2.5 is a free update for all current customers.

Pricing and Availability:
Server Ranger 2.5 for Windows, Linux and Mac ships today and costs $49.99 (USD). Visit the official website for more information.

Which Format Should You Choose For An External Drive?

Tech Tips– Most of us use some sort of external USB attached storage on a regular basis. It is important to keep in mind that media can be formatted in many different ways. Which filesystem you format an external drive with depends on the system(s) you plan to use it with. That said, there are many different filesystems to choose from

Linux

For Linux systems, the most common format is ext3 or ext4. But neither of those formats of disks can be natively read by your Mac. You can, with the use of the third party software such as “FUSE for Mac” or “extFS for Mac by Paragon Software“, read ext3 or ext4 disks. 

macOS

Our current Macs use disks with either the “Mac OS Extended” (HFS+) or the more modern “Apple File System” (APFS) filesystem.

You may be able to mount and read an HFS+ disk on your Linux system without additional software. Or maybe you will need to install some additional software. That depends on what was included in the installation. The same is true for APFS formatted disks – install apfs-fuse to read these. There is also a Paragon product for Linux that allows Apple disks to be mounted.

If you want to read either HFS+ or APFS disks on a Windows systems there is third party software you can get to do that. For HFS+ disks, install HFSExplorer, Paragon’s HFS+ for Windows, or Mediafour’s MacDrive. For APFS disks you can buy “APFS for Windows by Paragon Software“. The MacDrive package can also be purchased to read your macOS drives on a Windows system. The article “How to Read a Mac Formatted Drive in Windows: 6 Methods” covers these and more.

Windows

There are four different filesystems common to Windows – FAT16, FAT32, exFAT, and NTFS. The exFAT filesystem was created in 2006 for use with USB flash drives and SD cards, so it is not directly associated with a version of Windows.

Reading a drive formatted in any of these filesystems is easy on your Mac. Just plug the drive into your Mac and it will mount it. If the drive is formatted with FAT16, FAT32 or exFAT data can be read as well as written to the drive. If the drive is NTFS, data can only be read. If you want to write to an NTFS disk, then purchase either “Microsoft NTFS for Mac by Paragon Software” or “Microsoft NTFS for Mac by Tuxera“.

Making it easy

Usually, we know in advance where we are going to want to use an external drive. The simplest thing to do is to format the drive for use across as many systems as is possible. That means that for cross-platform compatibility, the best filesystem to use is FAT16, FAT32 or exFAT. Both FAT16 and FAT32 are readable on Windows, Mac, and Linux without any additional software needed.

The exFAT filesystem can be accessed by the Mac without additional software. Linux systems will need exfat-fuse, but that is easily installed.

Most Thumb drives or external disks come pre-formatted with FAT32. That makes them useable anywhere out of the box. The only reason you would want to go to exFAT is if the data you wanted to store on the media was larger than 4 GB. FAT32 has a limit of 4 GB on files. With exFAT, files can be up to 16 EB in length. That is 16 Exabytes or 1018 bytes (see “What Do Those Terms of Storage Mean?” for more on data storage) – sufficient large for any storage need.

Formatting Media on Your Mac

Screen Shot 2019-03-28 at 3.51.16 PM

External media can easily be formatted (these examples are on macOS High Sierra 10.13.6) on your Mac. Connect the drive to your Mac and open Disk Utility (Finder ==> Go ==> Utilities ==> Disk Utility). On the left side you will see all the connected external drives listed (red arrow in image above). Choose the one you want to format and then click on the Erase button (orange arrow in the image). NOTE: Formatting a disk permanently erases all data on the disk!

Screen Shot 2019-03-28 at 3.51.42 PM

This will drop down a window that allows you to give the drive a new name and pick the format you want used on the drive.

Screen Shot 2019-03-28 at 3.51.53 PMIf you click on the Format window, a drop down menu will appear giving you a list of the format options available to you. While the Mac lists MS-DOS (FAT) this is really FAT32. You also have the option of formatting a drive as exFAT.

 

Disk Filesystem Summary

Filesystem Native to Journaled[1] Max File Size When Introduced
ext3 Linux Yes 16 gigabytes 2001
ext4 Linux Yes 16 tebibytes 2008
FAT16B (BigFAT) DOS 3.1 of later No 4 gigabytes 1987
FAT32 Windows 95 or later No 4 gigabytes 1996
NTFS Windows NT or later Yes 16 exabytes 1993
exFAT Windows CE 6.0 No 16 exabytes 2006
HFS+ macOS 8.1 or later Yes (as of 2002) 8 exabytes 1998
APFS macOS High Sierra (10.13) or later No, more modern methods 8 exabytes 2017

 

References

  1. A journaling file system is a file system that keeps track of changes not yet committed to the file system’s main part by recording the intentions of such changes in a data structure known as a “journal”, which is usually a circular log. In the event of a system crash or power failure, such file systems can be brought back online more quickly with a lower likelihood of becoming corrupted.

Updating Your Raspberry Pi

serveimage

Raspberry Pi – Like all computers, you have to periodically update your Pi with the latest versions of the software. If you visit the Distrowatch site, you can see the date of the last Raspian release. To update your Pi follow these steps:

  1. open up the terminal
  2. update your system’s package list by entering the command [1-4]:
    sudo apt-get update
  3. upgrade all your installed packages (this may take several minutes and require user responses) to their latest versions by entering the command [1-4]:
    sudo apt-get dist-upgrade
  4. discard any unneeded files that have been downloaded as part of the upgrade by entering the command [2]:
    sudo apt clean
  5. reboot your Pi to complete the update by entering the command [1-4]:
    sudo reboot
  6. now verify the version of Raspian (9.8 at the time I write this) by opening the terminal again and typing the command [5,6]:
    cat /etc/debian_version
    or
    lsb_release -a

 

References

  1. Updating and Upgrading Raspbian
  2. How to Update Your Raspberry Pi to the Latest Raspbian OS
  3. Keeping your Raspberry Pi up-to-date
  4. How to update your Raspberry Pi to the latest version of Raspbian
  5. How to Check the Software and Hardware Version of a Raspberry Pi

CLI – find

serveimage

CLI – We all find ourselves searching our Mac looking for a particular file or files that satisfy certain criteria. Certainly, you can use Spotlight for that, but there are also methods of searching through the command line. Those options give you much better control over your search criteria. The find command is a very flexible way of searching your machine for files.

The description of find in the macOS man page is:

NAME

find — walk a file hierarchy

SYNOPSIS

find [-H | -L | -P] [-EXdsx] [-f path] path … [expression]

find [-H | -L | -P] [-EXdsx] -f path [path …] [expression]

DESCRIPTION

The find utility recursively descends the directory tree for each path listed, evaluating an expression (composed of the “primaries” and “operands” listed below) in terms of each file in the tree.

I didn’t attempt to list the switches, primaries and operands. There are nine switches and over 60 primaries. I suggest checking out the man  page for find on your macOS machine (or on the web) to see all of your options.

Screen Shot 2019-02-28 at 5.24.37 PM

One of the ways I have used find is to look for large files. In the example above, I searched a directory for all files larger than 10 megabytes. This could easily be used to search your entire disk for large files (use +1G instead of +10M to find files larger than 1 Gagabyte in length).

Screen Shot 2019-02-28 at 5.36.43 PM

You can also search for files older than (or newer than) a specific date. I have used this feature of the find command many times. In the example above I have used cd to move to a directory that contains Science Fiction images I use for one of my Desktops. I am searching that directory looking for files that were modified (in my use case this means added) more than 10 days ago.

Those ae just two simple examples of using the find command. There are many other examples of how find can be used in the references listed at the end of this article. Because of the flixibility of the find command, it can be put to use for many tasks by the SysAdmin as well as the macOS/Linux/UNIX user.

To learn a lot more about how to use find, take a look at “Finding Files On The Command Line“. Yes, this is a Linux article, but the find command as implemented on macOS is fundamentally the same.

Check the macOS man page for cd for all of the available options.

References

  1. 25 simple examples of Linux find command
  2. 14 Practical Examples of Linux Find Command for Beginners
  3. Finding Files On The Command Line

See my other CLI and macOS articles


Weather at Your Terminal Command Line

screen shot 2019-01-18 at 6.17.34 pm

Web Tools – There are lots of way of getting the weather on your computer. Most of those will open in your browser with lots of content, animations, and probably advertisements. But wttr.in is different. It is text only. What is wttr.in? From their website:

wttr.in is a console-oriented weather forecast service that supports various information representation methods like terminal-oriented ANSI-sequences for console HTTP clients (curl, httpie, or wget), HTML for web browsers, or PNG for graphical viewers

screen shot 2019-01-18 at 6.11.46 pm

I used curl wttr.in from the terminal command line to get the image shown at the top of this page. This should work on any Linux or macOS system. When I enter http://wttr.in into my Safari browser I get similar output as shown in the image immediately above.

This site provides many options to choose from in their weather report. While it takes your current location as the default, other locations around the world can be specified. Queries from the US appear in USCS units, while most of the rest of the world get values in the Metric System. Optionally you can specify the units.

Reports can be returned in ANSI for the terminal, HTML for the browser, or as a .PNG image. All of the options are explained on their GitHub site.

I like this minimalist weather report and have added the URL to my Safari Favorites.

CLI – dd

serveimage

CLI – If you are wanting to copy a file from one place to another then you may want to look at the dd command. This command is particulary useful when you want to copy the file while making edits to it on the fly.

The command is also useful when copying a disk image to other media. This can be very useful in creating a bootable SD card for a Raspberry Pi. The Wikipedia page on the dd command gives a good overview of how the command can be used.

The description of dd in the macOS man page is:

The dd utility copies the standard input to the standard output.  Input data is read and written in 512-byte blocks.  If input reads are short, input from multiple reads are aggregated to form the output block.  When finished, dd displays the number of complete and partial input and output blocks and truncated input records to the standard error output.

To learn a lot more about how to use dd, take a look at “Linux dd command explained for beginners (8 examples)“. Yes, this is a Linux article, but the dd command as implemented on macOS is fundamentally the same. Check the macOS man page for dd for all of the available options.


See my other CLI and macOS articles


 

Download a Free Raspberry Pi Cheat Sheet

serveimage

Raspberry Pi – I came across this quick start beginner’s cheat sheet for the Raspberry Pi from Opensource.com. This isn’t an exhaustive set of information but is intended to get you going with your first Raspberry Pi.

If you want more information about your Pi, you might want to look at the “OFFICIAL RASPBERRY PI BEGINNER’S GUIDE“.

CLI – time

serveimage

CLI – Have you ever run a command from the command line and afterwards wondered how long it took to run? If so, the time command will give you that answer.

This command measures the real, user, and system time used by a command during its execution.

The description of time in the macOS man page is:

The time utility executes and times utility. After the utility finishes,
time writes the total time elapsed, the time consumed by system overhead,
and the time used to execute utility to the standard error stream. Times
are reported in seconds..

As an example I ran a three ping against the site capmac.org and timed it.

Screen Shot 2019-01-02 at 9.45.13 AM

To learn a lot more about how to use time, take a look at “Linux time Command Tutorial for Beginners (with Examples)“. Yes, this is a Linux article, but the time command as implemented on macOS is fundamentally the same. Check the macOS man page for time for all of the available options.


See my other CLI and macOS articles


 

SciFi Inspired Desktop UI

Screen Shot 2018-12-13 at 10.44.13 AM

I came across the edexui a few days ago and had to try it. What is it? The edex-ui is:

a science-fiction inspired desktop “heavily inspired by DEX-UI and the TRON Legacy movie effects,” which gives you a terminal and live telemetry from your system

Screen Shot 2018-12-13 at 10.35.09 AM

You can download it from here just click on the link indicated by the arrow in the image above.

There is really no productivity gain with this app, just something fun to try. It does give you a full shell access just like the Terminal App does. It also gives you some data about your system in real time. The site provides some tips for customizing the App further if you scroll down to the FAQ section and click on the “repo’s Wiki” link.

Versions of this App are available for Linux and Windows in addition to macOS.