Often, I search for a function, most likely a wordpress function, within the PHP files. It is usually done within wordpress themes that contains a few other files too, particularly minified CSS file that results in seeing the entire minified CSS file in the output of the search result. This is pretty annoying to say the least.
Now, I started using an alias that finds only the PHP files and then pass the result to a grep command to find only what I really need. Here’s the alias…
alias findinphp='find * -type f -name '*.php' -print | xargs grep -inr'
I could have used the built-in -exec option too. However, it doesn’t play well when we search thousands of files. Moreover, using xargs is safe and faster.
- Ensure systemd services restart on failure by Jon Archer
- php-fpm systemd unit with auto-restart by Juan Luis Boya García
- systemd Project Web Page
systemd is a system and service manager that runs as PID 1 and starts the rest of the system and services. The main command used to introspect and control systemd is systemctl.
Basically do the following to let a service restart automatically…
- Edit /lib/systemd/system/name.service file
- Insert “Restart=on-failure” under the section “Service”. Save the file
- Execute the command… systemctl daemon-reload
- Execute the command… systemctl restart name_of_the_service
- (optional) try killing the process now
See https://wiki.archlinux.org/index.php/Systemd#Examples for more examples.
For those who still can’t understand…
Open up your PhpMyAdmin’s config.inc.php file and then add the following line in it…
$cfg['ServerLibraryDifference_DisableWarning'] = true;
Now, log out and then log in to PhpMyAdmin. Do you still see the warning?
After analyzing all the possible options, the following works great for me. I hope it works for you too…
find /path/ -type d -print0 | xargs -0 chmod 0775 # For directories
find /path/ -type f -print0 | xargs -0 chmod 0664 # For files
At times, apt may try IPv6 to resolve a domain name. In which case, it may not be desirable and sometimes, it just doesn’t work for that particular server. So, to let apt to use only ipv4 for DNS resolution…
uncomment the following line…
precedence ::ffff:0:0/96 100
If the above line doesn’t exist, just insert it at the bottom or at the top of the file!
Verify the changes with the command (before and after the changes)…
UFW, Uncomplicated Firewall, was created for Ubuntu, then ported to other distributions as well, primarily to Debian. So, it’s no wonder, there are some incompatibilities when running UFW under Debian, at times. Those incompatibilities or errors are usually fixed in the stable releases. However, due to the difference between how things work and how we expect things to work, there may be some errors with the default configuration.
In Debian 7, UFW was installed lately. And, in the end of deploying it, the following command was run…
sudo ufw --force enable
Immediately, it provided the following error…
ERROR: problem running ufw-init
Upon digging through the issue, I noticed that IPv6 address wasn’t available in that server and UFW meant to complain about it. So, the solution is to disable IPv6 in UFW, by editing
and then comment out the line
Recently, had a look at MySQL slow log to see what’s happening in a particular site. MySQL logged the unix timestamps that is good for many reasons. In order to convert this, here’s a one-liner…
date -d @1382734106
# output - Fri Oct 25 20:48:26 UTC 2013
Some people try to test out an application, a site, a contact form and may use an email like firstname.lastname@example.org that would never be delivered by the local email delivery system and would be in the queue forever, or until it is deleted.
Here’s a trick to delete such emails from postfix. Similar commands may be available with other similar tools too.
# to see the mail queue
# to delete all the deferred emails
postsuper -d ALL deferred
# verify that queue is empty
# for more info, check out the *man* pages of these commands
Fedora 19 seems to have changed the way one can setup the hostname and fully qualified domain name. By making this change, it streamlined the setup similar to how things work in Debian derivatives, including Ubuntu. Here’s how it’s done…
# as 'root' cat 'hostname' >> /etc/hostname sed '1i127.0.1.1 hostname.domainname.com hostname' -i /etc/hosts hostname -F /etc/hostname # verification hostname hostname -f
In Amazon Linux AMI, one still has to set it up only in
I use logwatch in almost all the places. So, here is a little piece of template that I use all the time. A little explanation, though. Whenever I setup a new server, I setup a daily logwatch. Once, the server becomes stable, I move it to weekly logwatch. So, during the transition period, it is just a matter of commenting out certain lines and un-commenting certain other lines. Anyway, here, we go…
# global / common directives
MailFrom = email@example.com
MailTo = firstname.lastname@example.org
# Un-comment the following two lines, to enable weekly logwatch
# Range = between -7 days and -1 days
# Subject = "Weekly Log from Pothi Inc"
# Comment out the following two lines, to disable nightly logwatch
Subject = "Nightly Log from Pothi Inc"
Detail = High