Category Archives: Linux

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
Advertisements

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


 

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.

Official Raspberry Pi Beginner’s Guide

BeginnersGuideLinux – I recently saw that the Raspberry Pi Press has just released its official “Raspberry Pi Beginner’s Guide”. This 244-page book is intended to get the reader started with their Raspberry Pi. As they say:

From setting up your Raspberry Pi on day 1 to taking your first steps into writing coding, digital making, and computing, The Official Raspberry Beginner’s Guide is great for users from age 7 to 107!

You can order a hard copy of the book through the Raspberry Pi Press store (£10.00) with free international delivery. If you are willing to settle for an electronic copy, you can download the PDF for free. I have downloaded the PDF and look forward to reading it on my iPad.

Just in case you have been living in a cave somewhere, the Raspberry Pi is:

a small, clever, British-built computer that’s packed with potential. Made using the same technology you find in a smartphone, the Raspberry Pi is designed to help you learn to code, discover how computers work, and build your own amazing things.

One of the great things about the Raspberry Pi is that they are very inexpensive. If you search Amazon, you will find various kits and versions of the Raspberry Pi starting from $27. They are also available in Fry’s Electronic Stores if you are lucky enough to have one of those close by.

The book and the hardware would be a great Christmas present for the clever kid (of any age) in your family.

CLI – file

serveimage

CLI – If you encounter a file and are not sure what type of file it is (often because the extension is missing), the the file command is what you are looking for.

This command allows you to lets you see the type of file you’re dealing with. The description of file in the macOS man page is:

file tests each argument in an attempt to classify it.  There are three sets of tests, performed in this order: filesystem tests, magic tests, and language tests.  The first test that succeeds causes the file type to be printed.

The type printed will usually contain one of the words text (the file contains only printing characters and a few common control characters and is probably safe to read on an ASCII terminal), executable (the file contains the result of compiling a program), or data meaning anything else (data is usually “binary” or non-printable).  

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


See my other CLI and macOS articles


 

CLI – whatis

serveimage

CLI – As mentioned before, every command line command has a descriptive man page entry that you can access. That is often a very long and detailed description of the command and all of the possible options available to it.

Sometimes you just want a quick explanation as to what a command does. This is where the whatis command is useful. It will return a one line description of the command being referenced.

The description of whatis in the macOS man page is:

whatis searches a set of database files containing short descriptions of system commands for keywords and displays the result on the standard output.  Only complete word matches are displayed.

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


See my other CLI and macOS articles