Search text recursively in gz files

Macbook Coffee @danielcgold

Part of administering web servers is looking through log files for clues whenever you come across issues with your web server or web applications. The logs most often will tell you exactly what went wrong. However, log files can be separated into multiple files and compressed to save space.

To search for a particular text through these compressed files easily, use the following command:

find . -name "*.gz" | xargs -n 1 zgrep -H "[text to search]"

 

Tags

Copy files with rsync in Linux

Copy files with rsync in Linux

Rsync (remote sync) is a linux utility to synchronize local and remote files and directories, mainly used in terminal.

I use this mainly in downloading/uploading files and directories from and to remote servers or even local files. I use rsync as well with shell scripts for backups that are ran automatically daily using the crontab utility.

Correct file permissions for WordPress

Person wearing WordPress shirt in front of computer

File and folder permissions can be a problem sometimes and can cause errors when not set properly on your server.

For WordPress installations, you can set the proper permissions with the following commands:

Set all directory permissions:

find . -type d -exec chmod 755 {} \;

Set all file permissions:

find . -type f -exec chmod 644 {} \;

 

Encrypt files using GnuPG (GPG)

Matrix code on laptop screen

GnuPG is a complete and free implementation of the OpenPGP standard encryption. 

Installing GPG

GPG is available in Windows and many distributions of Linux, including a graphical user interface (GUI) that is easy to use. However, I prefer using the command line tools instead.

Red Hat / CentOS

sudo yum install gnupg

Ubuntu / Debian

sudo apt-get install gnupg

Note: Use gpg2 (version 2.x)