linux

How to easily determine the blocksize of a filesystem

I just saw that this is a way you can easily determine the blocksize of a filesystem, at least a Mac/Unix/Linux filesystem:

$ echo foo > foo

$ du -h foo
4.0K    foo

I tried to do the same thing with touch foo, but that didn’t work. Without digging into it more, the key seems to be in having very little text in the file, at which point the du command shows the minimum block size for the file.

A large collection of Unix/Linux ‘find’ command examples

Linux/Unix FAQ: Can you share some Linux find command examples?

Sure. The Unix/Linux find command is very powerful. It can search the entire filesystem to find files and directories according to the search criteria you specify. Besides using the find command to locate files, you can also execute other Linux commands (grep, mv, rm, etc.) on the files and directories you find, which makes find extremely powerful. 

How to use the Linux ‘scp’ command without a password to make remote backups

Summary: How to create a public and private key pair to use ssh and scp without using a password, which lets you automate a remote server backup process.

Over the last two years I've ended up creating a large collection of websites and web applications on a variety of Linux servers that are hosted with different companies like GoDaddy and A2 Hosting. I recently embarked on a mission to automate the backup processes for all these sites, and as a result of this effort, I thought I'd share what I've learned here.

Unix find command: How to move a group of files into the current directory

I just bought a bunch of MP3 music files from Amazon, and when I downloaded the zip file they provide onto my Mac, it was a bunch of files in a bunch of subdirectories; not really convenient to work with when you’re trying to import them into iTunes. So I used this Unix find command to move all of the music files from the subdirectories they were scattered in into the root directory that was created when I expanded the zip file:

cd Amazon-Music-Folder
find . -type f -exec mv {} . \;

If you ever need to either copy or move a bunch of files with a single command, I hope this example shows the correct find command syntax for your needs. (If you need to copy the files, use the cp command instead of the mv command.)

A Play Framework 2.6 startup script example (Scala)

Play Framework FAQ: Can you share an example of a Play Framework 2.6 startup script, i.e., a shell script that shows the commands and parameters you use to run a Play Framework application?

Sure. Assuming that you created a production mode version of your application with the sbt dist command, deployed that zip file to a production server, and have a Play Framework 2.6 application named “myapp,” you can put a command like this in a Unix/Linux shell script to start your Play application:

My vi/vim tutorial goes over 200,000 views

Way back when I lived in this low-income apartment complex in Wasilla, Alaska — technically I had no income at the time, and it’s ridiculously hard to find a place to live in Alaska in the summer — and spent as much time as I could meditating in the mountains, I created a vi/vim editor video tutorial and put it on YouTube. I just noticed that video has now exceeded 200,000 views. It feels a little weird to think that over 200K people have started to learn vi/vim from that video.

A funny thing about making that video is that the walls in that apartment complex were paper-thin. I could hear everything my neighbors did in their apartments (use your imagination and you won’t be wrong), and they could hear me, so I intentionally tried not to talk too loud in the video. I had to edit the video at several points to crop out some of my neighbors yelling at each other.

Format of the Linux crontab date and time fields

I’ve written several things about the Linux cron command and crontab file format before, and as a quick note, here’s some information on the format of the crontab date and time fields.

Crontab date/time fields

First, from the crontab man page documentation:

A Scala “Word of the day” shell script

I have a 19" monitor on the counter between my kitchen and living room, and it’s powered by a Raspberry Pi. I use the Linux Phosphor screen saver to show a scrolling “news and stock ticker” on the display, which I’ve programmed to show news from several different sources (Atom and Rss feeds, along with other news and data sources). An old version of the display looks like this:

My Raspberry Pi news ticker display

Today I added a new “Word of the day” feature to the display, and as with all of the other code, I wrote a Scala shell script to generate the output.