Tag Archives: unix

Unix / Linux: Sync Local Directories

unix linux

To sync files between two local directories on Unix or Linux, you can either choose to perform a soft link to the source directory or use rsync or lsyncd daemon.

MySQL: Export Each Database to Individual SQL File

database

MySQL backups are normally done using mysqldump – a MySQL database backup program. The problem is all the backups will be written to a single output SQL file. I prefer to dump each MySQL database to a separate SQL file.

Shell Script: Check If Weekday

shell script

There are two ways to perform a “is it a weekday” logic in shell scripts. One way is to use cron. The other is to get the day of week from the date command.

Unix / Linux: Generate MD5 Checksum

unix linux

The md5sum command can be used to generate MD5 checksums for a string or a file. This is installed by default on most Unix and Linux distributions.

Disable Nginx Version Number in HTTP Headers

security

By default, Nginx sends the version number in the HTTP response. Hackers can use this information to try and exploit any known vulnerabilities in Nginx, especially if you are running a version with known vulnerabilities. Security wise, it’s a good practice to not reveal versions numbers of the HTTP server.

Unix / Linux: Run Cron Jobs on Last Day of Month

unix linux

Cron jobs can be scheduled based on minute, hour, day of month, month or by the day of the week. Flexible as it may seem, there is actually no simple way to schedule a job to be run on the last day of every month.

Shell Script: Get Epoch Time

shell script

Unix time, POSIX time or Epoch time is defined as the number of seconds that have elapsed since 00:00:00 January 1, 1970 UTC. There are a few methods to retrieve the Epoch time on Unix and Linux.

UNIX / Linux: File Permissions in Octal

unix linux

To set file permissions using the chmod command, we can specify the permissions in either numeric mode or symbolic mode. But when we want to get the file permissions, most often with the ls -l command, we are normally only given a printout using the symbolic mode.