Linux

Problems, solutions and everything in between.
Latest entries

Basic Potential SSH Compromise Test

This will show you all logins excluding your IP address. last | tac | grep -v YOUR-IP-HERE Check for password changes and cross reference with the login attempts history | grep passwd Finally run a whois based on the suspicious IP address. Now this isn't fool proof, it's very easy to fool your location however it should give you an idea if your system has accepted potentially dangerous connections. I recommend locking SSH down to IP address.

Check for any SSH password changes

history | grep passwd

cPanel EasyApache 4 Installing Redis and Redis PHP extension

Installing Redis is relatively straight forward on centos servers, however the Redis PHP extension proved a little more problematic. For CentOS 6 /RHEL 6 rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm yum -y install redis --enablerepo=remi --disableplugin=priorities chkconfig redis on service redis start For CentOS 7 /RHEL 7 rpm -ivh…

Logging Slow Loading Queries

You can do this VIA the command line: SET GLOBAL slow_query_log = 'ON'; SET GLOBAL slow_query_log_file = '/path/filename';

Import .sql.gz form the command line

zcat file.sql.gz | mysql -u user -p db_name

A Comprehensive list of Grep and its arguements

Grep if you don't know is a way of searching based on a given pattern. Grep basics To search type grep followed by some parameters (such as -R to recursively search) then the input you want to search. The below code will recursively loop the server and ignore all case for the word memory_limit. The * signals the fact you want to look all over the server however you can specify a specific path. grep -Ri "memory_limit" * This will achieve the same as above but instead of searching the server it…

Check the syntax of Nginx’s configuration file

I had a problem where I couldn't restart a server powered by Nginx after making a lot of startup configuration changes. The error I had was ==== AUTHENTICATION COMPLETE === Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. Simply run this command sudo nginx -t -c /etc/nginx/nginx.conf I was returned nginx: [emerg] a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/test:17…

Test a servers HTTP performance with apache benchmark

You can benchmark a servers performance using apache benchmark (ab). ab -n 100 -c 100 http://localhost:3000 ab = Apache Benchmark -n = number of requests to send -c = Concurrency requests (so in this case, 100 attempts performing each one at the same time) Followed by the host (and in this case, the port number)

How to uninstall Homebrew on a mac - one command

Run the following command whilst in the terminal /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

Check if NodeJS is installed

You can print out the version of node using the command below, if you have "command not found" returned, you don't have Node installed. You can download it here. node -v

How to install Homebrew on a mac - one command

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Homebrew's documentation is pretty good, you can find it here.

[SOLVED] Failed Homebrew “brew update”

After upgrading my Mac OS to "El Capitan" I'm returned the following error. Error: /usr/local must be writable! This isn't a problem with Homebrew, but during the upgrade the OS has reset the permissions on /local Solution To solve this problem, you can run the command "brew doctor" which will give you more details. I receive the following. You should probably change the ownership and permissions of /usr/local back to your user account. sudo chown -R $(whoami) /usr/local So run the command sudo…

Check what version of CentOS you’re running

cat /etc/*release* Or cat /etc/redhat-release

Install NCDU on your server

NCDU is an extension to "DU" Disk Usage, it provides a tree that you can traverse in to, listing each item by their size. Note: ensure you have yum installed (check the Linux page here) yum install ncdu

Remove logwatch emails on a server (Red Hat Enterprise Linux)

There's a symlink located here /etc/cron.daily/0logwatch which points to /usr/share/logwatch/scripts/logwatch.pl If you remove this file it will break the connection rm /etc/cron.daily/0logwatch To enable it again, just add the symlink back in. ln -s /usr/share/logwatch/scripts/logwatch.pl /etc/cron.daily/0logwatch Find out more about symlinks here

Turn off Cron summary reports

If you're constantly receiving updates about processed cron's (see below) Following files has been updated: /var/drweb/bases/drwtoday.vdb Plesk Servers Within the file /etc/drweb/drweb32.ini Change CronSummary = yes to CronSummary = no

How to install wget in Linux on a mac

Firstly, install homebrew, you can find a guide here. Then you'll be able to run the below command brew install wget And that't it

Install Homebrew on a mac through terminal

As quoted from the Homebrew website... "Homebrew installs the stuff you need that Apple didn’t." You can find everything you need on their