SSH Commands

Problems, solutions and everything in between.
Latest entries

[FIXED] Composer Install Fails Due To PHP-CLI Version Different To That Of cPanels Multi PHP

If you're receiving an error similar to This package requires php >=7.0.0 but your PHP version (5.6.39) does not satisfy that requirement. this may be down to the fact you're running cPanel's / Easy Apaches Multi PHP. A simple composer install won't suffice, you will need to run the following command. composer install -d .

Find Files And Folders On Linux

Look for the term "domlogs" from the root directory. find / -name "domlogs" Search within the current and all sub-directories for a file called "name.txt" find . -name name.txt Search all directorys "/" for files "-type f" ignore case "-iname" for files that begin with "test" find / -type f -iname 'test*' -maxdepth X Search the current directory and how many levels deep you want to search -not Return only results that do no match our case -type f Return files -type d Return directories

Check high CPU usage on Apache [dump to file]

mysql -e "show full processlist\G" > /root/processlist-`date +%F-%T`.txt This will dump the query list to a file in /root beginning with processlist, with the date and time, ending in txt.

Monitor the ACCESS LOGS in order to see who and what bots are hitting you

First we need to isolate our access-logs. We can do that with a quick find. find / -iname 'access-logs' This should print out a list of access-logs (usually per domain). Hypothetically "/home/test-domain/access-logs" Let's search within out logs now. grep "<Date/Here>" /file-location | grep "bot"|less -N The above command looks for a date (22/Sep) within the file for all instances of "bot" we then "less" that and print the line numbers out (-N). We "less" as these files can become quite…

Monitor the DOMLOGS in order to see who and what bots are hitting you

grep "<a date here>" /usr/local/apache/domlogs/|grep "bot"|less -N -g grep "20/Jun" /usr/local/apache/domlogs/ACCOUNTNAMEHERE |grep "bot"|less -N NOTE: less, makes this a little more managable to read so pressing spacebar will reveal the next chunk of results. -N adds line numbers (I like to see a visual of how far down I am)

MySql commands - SHOW FULL PROCESSES in addition to watch

The below commands show what's going on with SQL processes, -e is to execute the following command and then quit. Below I also include the use of "Watching" the process list so it's not what's happening at that moment. mysql -e "show full processlist" mysql -e "show full processlist\G" Or watch the process list watch 'mysql -e "show full processlist\G"' Alternatively, dump the process list into a .txt file mysql -e "show full processlist\G" > ~/processlist.txt

Command Line command to list the current PHP Handlers on the server

/usr/local/cpanel/bin/rebuild_phpconf --current

Make your life easy with SSH config speeding up your SSH login

If you're like me logging in and out of various SSH accounts on a day to day basis gets a bit laborious and it's easy to forget the credentials, even with a password/notes program it can become tedious going in and finding all details. Let's assume our user is harambe and we've changed the standard SSH port for a little extra security to 2020. A conventional connection would look like so. ssh -p 2020 password: ***** No, if you're like me and hate passwords you will have gone…

How to locate your PHP.INI file

Simply change directory to your folder and run php --ini

Make an empty directory (folder)

mkdir folder-name To make a folder and enter it at the same time. mkdir folder-name && cd $_

How to unzip/extract a tar file

tar -xvzf zipped-file.tgz z: Decompress the archive x: Extracted the files v: Verbose output - shows you the current files being output (print what's happening to the screen) f: This must be last, tells tar the name and location of the file Click here to see how to create the backup.tgz

Secure copy files from one server to another (including port number)

This is whilst you're on the server waiting to receive the file scp -P 2020 username@address:/file/to/send/old/location/ /where/to/save/new/location Note: it uses a uppercase 'P' scp username@address:/file/to/send/old/location/ /where/to/save/new/location If you're on the server in and you're sending the file somewhere else, flip it around scp /file/to/send/old/location/ username@address:/where/to/save/new/location

Access MySql without knowing the password on Plesk servers

This command will allow grant you access to MySql without the need for a password (from the command line) providing you're running on a server powered by Plesk. I've categorised this as "Maintenance" however you can use this in conjunction with backing up / importing databases to bypass the need for a password. Use the below command to backup a .sql dump of your database mysqldump -uadmin -p`cat /etc/psa/.psa.shadow` database_name > database_backup.sql Equally, use the below command to import…

How to upgrade to HTTP2 on Ubuntu 14.04

This post doesn't cover the fact you need a working SSL certificate on your server (delivering over HTTPS). Run the below commands, one at a time to download apache2, update packages and finally enable the http2 mod. sudo -i apt-get install python-software-properties add-apt-repository -y ppa:ondrej/apache2 apt-key update apt-get update apt-get --only-upgrade install apache2 -y a2enmod http2 Edit your virtual hosts file, on some systems you'll be able to find them here…

[Solved] - phpmyadmin 403 forbidden with apache2 https

A Problem I faced when adding my SSL certificate was I didn't check whether phpmyadmin was working. I figured out what was going on by working my way back through the rabbit hole. Firstly, when you see the 403, forbidden error. Run the following command tail -20 /path/to/your/error-logs I noticed I was getting the following error, AH01797: client denied by server configuration Solving AH01797: client denied by server configuration There was clearly a miss configuration somewhere so I needed to…

Import or restore a database backup

Make sure you have a created a blank database and you have details to hand. mysql -u database_user -p database_name < backup_name.sql NOTE: the only difference between this and the backup command is "mysql" as opposed to "mysqldump" and the angled bracket "

Backing up a mysql database in Linux

Run the below command to perform the backup - you will be prompt for your database password after submitting your command mysqldump -u database_user -p database_name > backup_name.sql The -p flag stands for password

Find the php.ini file in Linux

You can find the php.ini file by viewing a phpinfo() page. If you don't have a phpinfo page, create a new file called "info.php" add in the following