Category Archives: Linux

Installing composer on KeyHelp control panel

I’ve been trying to figure this out for the last 2 hours. But I have finally managed to install it.

From offical composer page copy paste first two lines

https://getcomposer.org/download/

like:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'c31c1e292ad7be5f49291169c0ac8f683499edddcfd4e42232982d0fd193004208a58ff6f353fde0012d35fdd72bc394') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Then, since KeyHelp makes users folders as root you will need to use i.e. files folder for installing Composer with command above. Then use this command:

COMPOSER_HOME=/home/users/someuser/files/ php composer-setup.php

What this command does?! COMPOSER_HOME is var and enables you to write composer.phar inside different home path.

All this without root. That was the point in the first place. Root and composer are not good option.

Problem was with the permissions in the first place. Users are from root. And Composer wanted to use $cd to access home folder. It poined to /home/users/someuser (someuser is current logged in user).

Error: Unable to create Composer home directory “/home/users/someuser/.config/composer”: mkdir(): Permission denied

Backup script – simple

If you want to make backups all of your server files (home dir or whatever) you should first make connection without passwords (using ssh).

First choose username you will be using like user981129, make it in server A (with backups). Then do this:

ssh-keygen -t rsa

You have now .ssh folder with public key (id_rsa.pub). Now go to the second server (server B) where backups will be transferred. Go to the /home/someuser and type:

mkdir .ssh; vi authorized_keys;

and then copy .ssh/id_rsa.pub from server A to authorized_keys.

Then on server B chmod .ssh 700; chmod .ssh/authorized_keys 640;

Then on server A make file with chmod a+x something like in /home/user981129:

vi backup.sh

and then paste this:

#!/bin/bash
NOW=$(date +"%m-%d-%Y")
SER="ip of the server where you are transfering files or nameserver"
FILE="backup.$NOW.tar.gz"
echo "Backing up data, please wait..."
rsync -avz /home/user981129/admin_backups/admin.root.admin.tar.gz someuser@ipofserverforbackup:/home/someuser/backups/$SER/$NOW/

Then open crontab -e and paste this:

0 3 * * * /home/user981129/backup.sh >/dev/null 2>&1

YOU ARE READY TO GO

edit: this post is for me, to speed things up when needed

Copy from folder to folder preserving everything

Either use

sudo cp -rp /home/folder /media/backup/folder

sudo cp -a /home/folder /media/backup/folder (UPDATE: use this one!!!preserves everything)

Or use:

 rsync -avz
-p     same as --preserve=mode,ownership,timestamps

 --preserve[=ATTR_LIST]
          preserve the specified attributes (default: mode,ownership,timestamps),
          if possible additional attributes: context, links, xattr, all

Source: https://unix.stackexchange.com/questions/43605/how-do-i-copy-a-folder-keeping-owners-and-permissions-intact