A collection of frequently used commands on servers or command line interfaces.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md

README.md

Frequently used on CLI

This is a collection of Dude's frequently used commands on servers or command line interfaces by Digitoimisto Dude Oy developer team.

Table of contents

  1. Let's Encrypt test - test for whether all the certs renew correctly
  2. Find all projects with gravityforms installed
  3. Quick backup entire site
  4. Check WordPress versions in composer.json
  5. Replace WordPress versions in composer.json (macOS)
  6. Optimize video for web
  7. Lowercase all in a directory
  8. Rename all in a directory

SSL

Let's Encrypt test - test for whether all the certs renew correctly
/opt/letsencrypt/certbot-auto renew --dry-run
Find all projects with gravityforms installed
grep -R "gravityforms" --include "composer.json" Projects/
Quick backup entire site
wget --cache=off -U "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36" --cookies=on --glob=on --tries=3 --proxy=off -e robots=off -x -r --level=1 -p -H -k --quota=100m http://www.example.com/
Check WordPress versions in composer.json
grep -R "johnpbloch/wordpress" ~/Projects/*/composer.json

In ~/.bashrc:

alias wpversions='grep -R "johnpbloch/wordpress" ~/Projects/*/composer.json'

Restart terminal or run . ~/.bashrc for changes to take effect. Then you can just type wpversions to see WordPress versions.

Replace WordPress versions in composer.json (macOS)

find ~/Projects/ -name composer.json -maxdepth 2 -exec sed -i "" 's/4.2.3/4.2.4/g' {} +

Bash alias in ~/.bashrc:

alias updateversion='find ~/Projects/ -name composer.json -maxdepth 2 -exec sed -i "" 's/$1/$2/g' {} +'

Then you can update any version by typing updateversion oldversion newversion, for example WordPress 4.2.3 to WordPress 4.2.4: updateversion 4.2.3 4.2.4.

Optimize video for web

For web optimized mp4:

HandBrakeCLI -i input.mp4 -o output.mp4 --encoder x264 --vb 900 --ab 128 --maxWidth 640 --maxHeight 480 --two-pass --optimize

For web optimized webm:

ffmpeg -i input.mp4 -acodec libvorbis -vcodec libvpx output.webm

Lowercase all in a directory

Useful for example after downloading a pack of fonts that are capitalized

rename -f 'y/A-Z/a-z/' *

Rename all in a directory

Useful for example after downloading a pack of fonts that have useless -webfont appended, or in any case that lots of files are in wrong format.

LC_ALL=C find ./ -type f -exec sed -i '' -e 's/foo/bar/g' {} \;

Or dry run:

rename -nvs searchword replaceword *

And the real thing:

rename -vs searchword replaceword *

Footnotes

Under construction, will update constantly.