linux

Linux Mint: How to change the disk encryption password alvin August 17, 2017 - 10:26am

If you ever need to change the password you used to encrypt your Linux Mint hard drive — the full disk encryption of the entire hard disk you used when you installed Mint — I just found that the commands at this linuxmint.com page worked as desired.

In short, I used this command to see how my hard drive was encrypted:

How to list all services on an Ubuntu 16.04 system alvin July 23, 2017 - 1:13pm

Ubuntu FAQ: How do I list all of the services on my Ubuntu 16.04 system from the Linux command line?

Answer: Use this command:

Sorting ‘ls’ command output by filesize alvin July 14, 2017 - 11:15am

I just noticed that some of the MySQL files on this website had grown very large, so I wanted to be able to list all of the files in the MySQL data directory and sort them by filesize, with the largest files shown at the end of the listing. This ls command did the trick, resulting in the output shown in the image:

ls -Slhr

The -S option is the key, telling the ls command to sort the file listing by size. The -h option tells ls to make the output human readable, and -r tells it to reverse the output, so in this case the largest files are shown at the end of the output.

A Linux shell script to find large files alvin July 14, 2017 - 11:14am

I made a mistake in configuring logrotate on a new Linux system, and almost ran into a problem because of that. Fortunately I saw the problem before it became a BIG problem, but as a result, I decided to add a script to my Linux system to check for large files, typically log files that have grown out of control for one reason or another.

Here then is a simple Linux shell script I named LargeFileCheck.sh, which searches the filesystem for files that are larger than 1GB in size:

A Linux shell script to rename files with a counter and copy them

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

How to use curl to get headers from a URL

Curl FAQ: How do I use curl to get the headers from a website URL?

Short answer: Use curl's -I option, like this:

$ curl -I URL

Here's a specific example, including a real URL and results:

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 - Descriptions 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.

Functional Programming is Like Unix Pipelines alvin May 28, 2017 - 6:36pm

“Pipes facilitated function composition on the command line. You could take an input, perform some transformation on it, and then pipe the output into another program. This provided a very powerful way of quickly creating new functionality with simple composition of programs. People started thinking how to solve problems along these lines.”

Alfred Aho, one of the creators of the AWK programming language, in the book, Masterminds of Programming