linux-unix

recent posts related to linux and unix

Free Unix/Linux and vi/vim cheat sheets alvin June 14, 2017 - 3:14pm

Way back in the 1990s I created some “cheat sheets” for Unix training classes that I taught. Somewhere in the 2000s I updated them to make sure they worked with Linux as well, Here then are two Unix/Linux cheat sheets I created (way back when) that you can print out if you’re just learning Linux and the vi/vim editor:

vi/vim editor tutorial has 175,000 views alvin June 6, 2017 - 9:55am

A funny thing about life is that the worst video I’ve ever made (about the vi/vim editor) now has over 175,000 views.

Linux crontab examples (every X minutes or hours)

Table of Contents1 - Linux crontab: How to run a command every minute2 - Meaning of the crontab date/time fields3 - Run a crontab command every hour4 - Run a crontab entry every day5 - Run a crontab entry every 5 minutes6 - Unix and Linux “crontab every” summary7 - Unix and Linux crontab reference information

Linux crontab FAQ: How do I schedule Unix or Linux crontab jobs to run at intervals, like “Every five minutes,” “Every ten minutes,” “Every half hour,” and so on?

Solution: I’ve posted other Unix and Linux crontab tutorials here before (How to edit your Linux crontab file, Example Linux crontab file format), but I’ve never included a tutorial that covers the “every” options, so here are some examples to demonstrate this crontab syntax.

How to install Java, Scala, and SBT on Linux Mint alvin May 19, 2017 - 7:27pm

Lately I’ve been in the process of “making the switch” from macOS to Linux Mint, and to that end, I just installed the Java 8 JDK/SDK, Scala 2.12, and SBT 0.13 on a new Linux Mint system, and I want to note here how I did that while it’s still fresh in my mind. Here are my notes in a compact form.

Teleport: The Unix/Linux ‘cd’ command, improved

Table of Contents1 - The Teleport command2 - Teleport command help3 - For basic use, tp is just like cd4 - Basic teleporting5 - Listing your teleport history6 - Teleport by number7 - Bash completion with Teleport8 - Teleport aliases9 - Adding/creating a teleport alias10 - Using a teleport alias11 - Listing your teleport aliases12 - Removing an alias13 - Teleport command - summary14 - Teleport command - download

Summary: By keeping a history of the directories you've visited, the Teleport command is an improvement on the Unix/Linux cd command. By having a memory, Teleport lets you jump from one directory to any previously visited directory, easily.

January, 2015 Update: The Teleport command now supports Bash completion. For more details on this, see the Github INSTALL.md file.

A Linux shell script to rename files with a counter and copy them alvin May 9, 2017 - 9:39am

As a quick note, I used this shell script to copy many files with the same name into a directory named tmpdir, giving them all new names during the copy process:

count=1
for i in `cat myfiles`
do
  fname=`basename $i`
  cp $i tmpdir/${count}-${fname}
  count=`expr $count + 1`
done

The way this works is that I have a file named myfiles that I created with a find command, and it contains a bunch of entries like this:

foo/bar/baz/filename.jpg
foo/baz/filename.jpg

When the shell script runs, it reads one line at a time from that file, gets the basename (filename) from that line, prepends that name with a counter, then copies the original file to the directory named tmpdir, giving it the new name, so the new filenames will be like this:

1-filename.jpg
2-filename.jpg
3-filename.jpg

I did this to copy all of the images I have under the Messages cache folder on my Mac. A friend accidentally deleted our text message stream, and I was able to recover 350+ images with this script.

You can also use it to copy iTunes music files, where it’s possible that many music files (MP3, M4A, etc.) will have the same filename.

Notes on how to configure HTTPS with Nginx alvin March 23, 2017 - 1:50pm
Table of Contents1 - Summary2 - New Linode Server3 - Update Everything4 - Ubuntu Firewall5 - Add a New User6 - Disabling Root Login7 - Limit Login Attempts8 - Install Nginx9 - Adjust Firewall10 - Nginx Configuration11 - NOT what I used: Let’s Encrypt on Ubuntu 16.0412 - (1) Create a cert (openssl)13 - (2) Create a strong Diffie-Hellman group14 - (3) Configure Nginx to Use SSL15 - Adjust the Nginx Configuration to Use SSL16 - (Alternative Configuration) Allow Both HTTP and HTTPS Traffic17 - Adjust the Firewall18 - Enable the Changes in Nginx19 - Test in Browser20 - Nginx "default_server"21 - Can change to a permanent redirect (301)22 - More Security: Preventing Information Disclosure23 - More Security: Fail2Ban24 - Restricting Access by IP Address25 - See also

Without any introduction or discussion, here are the notes I made while learning how to get HTTPS working with Nginx. These are just for me, but if something helps you, cool.

Cerebro, a Spotlight-like launcher for Linux alvin February 21, 2017 - 11:29am

I recently “made the switch” from MacOS to Linux Mint, and was lamenting the fact that I didn’t have Alfred on Mint. But then this morning I learned about Cerebro, which, if it’s not Alfred yet, at least it’s Spotlight for Linux. omgubuntu.co.uk has this good intro article on Cerebro.

Cerebro is written as an Electron app, and as a result it’s available not only for Linux, but Windows and MacOS as well.

Linux Mint (and Ubuntu): Suspend vs Hibernate (meaning) alvin February 16, 2017 - 2:05pm

When I put Linux Mint on a few of my computers recently I quickly encountered the words “suspend” and “hibernate” when attempting to put a laptop to sleep:

LInux Mint, Suspend vs Hibernate

“What the heck is the difference between Suspend and Hibernate,” I wondered. “I’m used to just having a ‘Sleep’ option on my MacBook Pro.”

How to install a ‘deb’ file on Debian Linux (dpkg, apt) alvin February 8, 2017 - 10:48am

As a quick note, this stackexchange.com page has some good background information on how to install a deb package file from the command line on Debian Linux (which in my case is Ubuntu 16.04). The short answer is that if you have a deb file named google-chrome-stable_current_amd64.deb, you’ll want to run these two commands, one after the other, as shown: