Linux

Open Source Operating System

Optimizing Images using command line

The images uploaded by users may not be of ideal size and may require compression to manage server space. There are some tools available for compressing JPG and PNG files.
Please note that the owner changes to the current username for the file after compression. Please remember to change ownership if required of the file or per folder post compression.

jpegoptim :
Optimize a jpg image with the same name

jpegoptim image.jpg

Optimize all jpg images in a folder

SSL Certificate Using Let's Encrypt for Ubuntu

Automated creation, renewing of certificates is provided by software called certbot.

To view a list of the certificates Certbot knows about, run the certificates subcommand:

$> certbot certificates

Deleting certificates

$> certbot delete --cert-name example.com

Install Certificates Using Apache

Server Certification

Technologies: 

Checking Passphrase for private key:  openssl rsa -check -in keyfilename
Changing Passphrase: openssl rsa -des3 -in keyfilename -out newkeyfilename

Installing or trusting certificates:
Extensions .crt, .pem and .cer are interchangeable, just change the file name extension, they have the same form. Try this:

sudo cp mycert.cer /usr/share/ca-certificates/mycert.pem
sudo dpkg-reconfigure ca-certificates
sudo update-ca-certificates

Getting the RSA public and private key from conf file.

Memcached Config For Drupal On Ubuntu

Memcached is a free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load

Memcached is used in Drupal mostly for caching Database queries in memory to improve authenticated user experience and reduce load on database. Primarily cache tables are swapped to have a memcached backend.

Handy Linux Commands

Technologies: 

Split: Split a text file in half (or any percentage) on Ubuntu Linux

The following command splits access.log files into multiple files with 6000 lines each

split -l 6000 access.log

Split files into size of 5M each

split --bytes 5M --numeric-suffixes --suffix-length=3 foo.mysql  last_part.mysql

Diff : Get Difference between files and folders
Following command provides recursive difference

Using Drush Alias

drush aliases allow you to run a drush commands on your local server but actually execute the command on a remote server.

One can create aliases in a folder that drush recognizes, mostly inside the .drush folder for Linux Based Systems. For a mysite example, we can create a file called as mysite.aliases.drushrc.php inside the .drush folder (Or any folder which Drush goes through before executing). All aliases in a site can also be combined in a single file called as aliases.drushrc.php

Example data that can be added to mysite.aliases.drushrc.php

<?php

Batch Process Images in Linux

Sometimes its a pain when you want to modify, resize multiple files at once in Linux. Fortunately ImageMagick comes with a handy command called convert that makes the work simpler

Install ImageMagick in Ubuntu

sudo apt-get install imagemagick

Batch Process set of files in a folder and resize them to 1024X768

for file in *.jpg; do convert "$file" -resize 1024x768 "$file"; done

You may also try an app called as phatch for GUI related batch processing of images.

Snippet to bulk rename files by replacing strings in filename