Category Archives: Linux

CLI – bzip2

CLI – If you have a file you want to compress, you have options as to how you will do it. The bzip2 command is one of the options that is open to you on a macOS system. Likewise, if you come across a previously compressed file with the .bz2 extension, you will want to use bzip2 to decompress it.

The description of bzip2 in the macOS man page is:

bzip2  compresses  files  using  the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than   that achieved by more conventional LZ77/LZ78-based compressors, and approaches the performance of the PPM family of statistical compressors.

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


See my other CLI and macOS articles


 

Advertisements

CLI – sed

Screen Shot 2018-08-06 at 7.16.16 PM.png

CLI – Sometimes you have a file that you wish to scan for every instance of a phrase and replace it with another phrase. The sed or stream editor command is just what you are looking for. In the above screen shot I first display a file with the cat command, then use se to replace all appearances of the word ‘Emma’ with the word ‘Bambi’. The sed command syntax for that is:

sed  ‘s/Emma/Bambi/g’ Review_Four\ Dominions\ copy.txt

The ‘s/Emma/Bambi/g’ says to do a global search and replace of Bambi for every instance of Emma. The name of the file being operated on is ‘Review_Four\ Dominions\ copy.txt’.

The description of sed in the macOS man page is:

The sed utility reads the specified files, or the standard input if no files are specified, modifying the input as specified by a list of commands.  The input is then written to the standard output.

A single command may be specified as the first argument to sed.  Multiple commands may be specified by using the -e or -f options.  All commands are applied to the input in the order they are specified regardless of  their origin.

This can be a very powerful and useful command when processing text files. In the SysAdmin world it can be very useful for updating configuration files.

To learn a lot more about how to use sed, take a look at “‘Sed’ Command In Linux: Useful Applications Explained“. Yes, this is a Linux article, but the sed command as implemented on macOS is fundamentally the same.


See my other CLI and macOS articles


 

CLI – zcat

Screen Shot 2018-07-24 at 11.06.57 AM

CLI – Sometimes you want to view the content of a compressed file. The zcat  Command Line  command allows you to do that. What does zcat do:

zcat uncompresses either a list of files on the command line or its standard
input and writes the uncompressed data on standard output.

The zcat command is like cat, but for compressed files.

To learn a lot more about how to use zcat, take a look at “Linux zcat Command Tutorial for Beginners (5 Examples)“. Yes, this is a Linux article, but the zcat command as implemented on macOS is fundamentally the same.


See my other CLI and macOS articles


 

Networking Cheatsheet for Linux (and macOS)

cheat_sheet_cover_sysadmin_networking

Whether you are a Unix/Linux/macOS Sys Admin or just a user, you often have to deal with various network issues. There are several ‘built-in’ utilities that can be used through the Command Line to help solve these issues. While this is not a full networking tutorial, the cheat sheet PDF file does give you some of the essential networking commands and examples of how you can put them to use.

While the cheat sheet is targeted at Linux, many of the commands listed will also work on your macOS system. This may be something you want to print out and add to your notes, or just download it and have it available for reference. I downloaded the PDF and put it in my iCoud Drive so that I can reference it from my Mac, MacBook or my iPad.

CLI – history

CLI – How often have you gone to the command line to run a command, one you just ran a few days earlier, but you don’t remember all of the options that gave you that perfect result? One way of being able to peer back at those commands you have entered at the command line is through the history command.

Just enter history at the command line and on a macOS system the last 512 commands entered will be shown in your terminal window from oldest to most recent. This is a command built into the default bash shell. With so many commands listed you will probably want to pipe the output of the history command into more or tail or grep to more easily find what you are looking for:

  • history | more
  • history | tail
  • history | grep <search term>

To learn a lot more about how to use apropos, take a look at “Linux history Command Tutorial for Beginners (8 Examples)“. Yes, this is a Linux article, but the history command as implemented on macOS is fundamentally the same.


See my other CLI and macOS articles


 

CLI – apropos

Screen Shot 2018-07-12 at 12.37.28 PM

You know what you want to do, but you are not sure what the command line command is that you should use. This is where the apropos command may help. While the man command gives you the details of a command, apropos searches the descriptions of all of the commands for the keyword used (in the example image above I used ‘apropos disk’ to obtain the list shown) and gives you a list of all commands that contain that keyword.

The macOS man page for apropos says:

apropos searches a set of database files containing short descriptions of system commands for keywords and displays the result on the standard output.

To learn a lot more about how to use apropos, take a look at “Linux apropos Command Tutorial for Beginners (5 Examples)“. Yes, this is a Linux article, but the top command as implemented on macOS is fundamentally the same.


See my other CLI and macOS articles


 

CLI – top

Screen Shot 2018-07-10 at 11.49.10 AM

If your system seems to be slow or there are running Apps (processes) that you want to know more about, you can enter top at the command line to see more. This command is part of almost every Unix, Linux, and macOS system.

This is similar to the Apple Utility “Activity Monitor”, though there are options you can invoke at the command line to give you more control over what you are seeing. This is a good tool to use if you are wanting to know why your Mac seems to bog down (which process is consuming CPU cycles and/or memory).

The macOS man page for top says:

The top program periodically displays a sorted list of system processes. The default sorting key is pid, but other keys can be used instead.  Various output options are available.

To learn a lot more about how to use top, take a look at “Linux top Command Tutorial for Beginners (8 Examples)” and “Tips for using the top command in Linux“. Yes, those are Linux articles, but the top command as implemented on macOS is fundamentally the same.


See my other CLI articles


CLI – Netstat

If you are having problems with your network or just want to learn a little more about it, the netstat command is a good way to start. The netstat command lets you print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.

The macOS man page for netstat says:

The netstat command symbolically displays the contents of various net-work-related data structures.  There are a number of output formats, depending on the options for the information presented.  The first form of the command displays a list of active sockets for each protocol.  The second form presents the contents of one of the other network data struc- tures according to the option selected. Using the third form, with a wait interval specified, netstat will continuously display the information regarding packet traffic on the configured network interfaces.  The fourth form displays statistics for the specified protocol or address family. If a wait interval is specified, the protocol information over  the last interval seconds will be displayed.  The fifth form displays per-interface statistics for the specified protocol or address family. The sixth form displays mbuf(9) statistics.  The seventh form displays routing table for the specified address family.  The eighth form displays routing statistics.

To learn a lot more about how to use netstat, take a look at “Linux netstat Command Tutorial for Beginners (8 Examples)“. Yes, this is a Linux article, but the netstat command as implemented on macOS is fundamentally the same.

See Apple’s Mac OS X Manual Pages for further command details.


See my other CLI articles


 

World Backup Day 2018

Saved Image 2018-03-31 at 11.39.26 AM.png

I can’t really say much more than I did last year, so I am reposting the article I wrote for Backup Day 2017.

If you have an electronic device (computer, phone, tablet), chances are that it can be backed up. Today, World Backup Day, serves as a reminder that you should be backing up those devices on a routine basis.

Backing up your data means making a second (and a third copy is recommended) of all of the data on your device. The 3-2-1 strategy is best – always three copies of your data, data stored on two different media, and one copy off-site.

You should backup because losing data is not as uncommon as you might think. Devices can be lost or stolen. Or they may simply suffer a hardware failure. Increasingly too there is the threat of the data on your device being held for ransom.

Start a habit today of making routine backups. You can even go to the World Backup Day website and take the pledge to back up your data.

One new thing I would like to add is this quick video by Bob “Dr. Mac” Levitus:

macOS New App Release – Mailspring

hero_graphic_mac@2x

Product Announcements – Foundry376 of San Francisco, California has released Mailspring, a desktop email client designed for macOS High Sierra. With modern features like unified inbox, snoozing, reminders, templates, offline search, and support for Gmail labels, Mailspring will breathe life back into your tired inbox! A clean, modern interface and six built-in themes make Mailspring a perfect fit for macOS High Sierra, and mail rules and customizable keyboard shortcuts bring inbox zero within reach. Say goodbye to Apple Mail and discover a better way to manage your email.

Mailspring is absolutely free and supports all IMAP providers, including Gmail, Office 365 and iCloud. Rich integration with macOS makes Mailspring shine: swipe to triage mail, see Quicklook thumbnails for attachments, and reply to emails directly from Notification Center! Mailspring’s email sync has been built from the ground up to use macOS features like App Nap, ensuring it keeps your mailbox up to date without draining your battery.

Pro Pricing:
If your work revolves around email, Mailspring Pro adds even more features, supercharging the app with read receipts, link tracking, send later, reminders, contact profiles, email analytics and more. At $8/mo, Mailspring Pro is an affordable alternative to sales and business email extensions and the first tool to bring all these powerful features to any IMAP providers. Leave the confines of webmail and Chrome extensions behind! Mailspring Pro is your unstoppable email sidekick for sales and business.

Open Source:
Mailspring builds on years of open source development and combines the innovative interface of Nylas Mail with a sync engine built on Sparrow’s Mailcore2 framework. Since 2012, thousands of contributors have helped drive innovation around email in these projects, and Mailspring brings it all together in beautiful, refined desktop experience for macOS that is also open source! See the GitHub link below for more.

Mailspring features include:

  • Unified Inbox – See all your email in a single view
  • Powerful Search – Use Gmail-style search syntax across all your accounts
  • Swipe Gestures – Swipe to archive right from the thread list
  • Signatures – Create as many signatures as you like and set defaults per-account
  • Aliases – Send email from aliases you’ve configured with your providers
  • Quicklook Integration – See previews of attachments and PDFs right inside the app
  • Notifications – Get rich notifications and reply directly from Notification Center
  • Drag and drop – Move emails, add attachments, and more with drag and drop supported everywhere
  • Gmail Labels – Label threads and add, remove, and manage labels right within the app
  • Customizable Keyboard Shortcuts – Choose from popular presets or create custom keyboard shortucts
  • Message Templates – Save emails as templates-complete with variables-and quickly autofill replies and new messages

Mailspring Pro brings even more:

  • Snooze – Dismiss messages until you’re ready to handle them
  • Reminders – Be reminded when emails you send haven’t received replies
  • Tracking – See when recipients open your messages and click links to send timely follow-up
  • Contact Profiles – See bios, profile pictures, and more for people you email
  • Scheduling – Schedule emails to be sent at a particular date and time
  • Undo Send – Never accidentally send an email again
  • Company Info – View company size, location, local time and more at a glance
  • Pre-send Checks – Warns you about omitted attachments, incorrect salutations, and more
  • And many more – see the Mailspring website for a full list of Pro features

Availability:
Mailspring is free and is available exclusively through the Mailspring website. For more information, visit the Mailspring website.