Posts Under Category: SSH

In this tutorial I will explain how to mass change permission of all files and folders/directory on a Linux server.
Login to server via SSH as root and execute following commands.

To change permission of all files and folders to 644 in /home/username/pulic_html

chmod 644 /home/username/public_html -R

To change permission of all files to 644 in /home/username/pulic_html

cd /home/username/pulic_html
find . -type f -exec chmod 644 {} \;

To change permission of all folder to 755 in /home/username/pulic_html

cd /home/username/pulic_html
find . -type d -exec chmod 755 {} \;

Our Recommended Dedicated Server

Login to your server as root via SSH and run below command:

To start Apache

service httpd start

To stop Apache

service httpd stop

To restart Apache

service httpd restart

Our Recommended VPS Hosting

In this tutorial I will show you how we can transfer / restore a cPanel website using full cPanel backup from SSH.
Sometimes, cPanel to cPanel transfer may not work as expected. So, in this case you can manually create full cPanel backup, transfer to new server and restore on new server.

Step 1:

Create a full cPanel backup from cPanel >> Files >> Backup
Name of backup file will be something like backup-username.tar.gz

Step 2:

Upload the full cpanel backup file on new server in /home directory.
You can do server to server transfer from SSH using wget or scp command.

Step 3:

When you have uploaded the full cPabel backup file in /home directory of new server, login as root via SSH and run following command:

/scripts/restorepkg username

In above command, change username to your actual cPanel username which you are transferring.
It will take sometime to restore the account depending on size of the backup file.

You can also restore account from:

WHm Home >> Backup >> Restore a Full Backup/cpmove File

Our Recommended VPS Hosting

Server root MySQL password can be different from server root password. Here is how you can get root MySQL password.

Login as root via SSH and execute following command

tail /root/.my.cnf

OR

cat /root/.my.cnf

This will show you the root MySQL password of your server.

Our Recommended Dedicated Server

If you have many websites / accounts on your server, and you want to make backup of all mySQL via a single command, here is how you can do. Creating regular full mySQL backup of all accounts is a very good practice. Creating full MySQL backup is also recommended before performing any mysql upgrade.

How to create full MySQL backup

Login as root via SSH and execute following command:

mysqldump --add-drop-table --all-databases | gzip > /home/alldatabases.sql.gz

This will create a SQL-based backup of everything in MySQL and save it into your /home directory. The name of your backup file will be alldatabases.sql.gz

You may change the backup file name and location where it will be saved.

How to restore full MySQL backup

To restore a full MySQL backup file, you will need root MySQL password. Run following command to get root mySQL password

tail /root/.my.cnf

The above command will show the root MySQL password. When you have password, run following command:

gunzip < /home/alldatabases.sql.gz | mysql -u root -p

If your saved full mysql backup is at different location, change the path in above command. If the name of your full mysql backup file is different, please change in above command.

You will be asked to enter password. So, enter the password that you have got above from tail /root/.my.cnf command.

Done!! It will take sometime to restore all database depending on size of database file.

Our Recommended Dedicated Server

If any script which requires perl is not working properly on your server, you may wish to check if perl is installed or not on your server.

Login in your server as root via SSH and execute following command:

perl -v

If perl is installed on your server, it will show you the version that is installed. If its not installed, it will show some error message.

How to List installed Perl modules on server

Enter following command

instmodsh

After this enter l, this will show you all installed perl modules on your server.

How to check perl version installed on server

Following command will display the perl version installed on server:

perl -v

Our Recommended VPS Hosting

CentOS is most popular operating system on Linux servers. If you want to check the CentOS version installed on your server, please refer to our following tutorial page:
How to find CentOS version installed

If you want to check centOs installed on your server is 32-bit or 64-bit, here is how you can find.
Login in your server via SSH as root and execute following command.

uname -a

If the output shows i686 or i386, this means its a CentOS 32-bit.
And if the output shows x86_64, this means its a CentOs 64-bit.

Screenshot on a 32-bits centOS server

centos-32-bits

Screenshot on a 64-bits centOS server

centos-64-bits

Our Recommended VPS Hosting

chown command is used to change owner of a file on a Linux server.

Syntax of chown command is:

chown user:group filename

Suppose you want to change owner of following file to a new user whose username is lophost

/home/mywebsite/public_html/filename.zip

Login to your server as root via SSH, and execute following command:

chown lophost:lophost /home/mywebsite/public_html/filename.zip

You can also use user ID of the user. Let’s say you want to change ownership of file to user ID 526. So, our SSH command will be:

chown 526:716 /home/mywebsite/public_html/filename.zip

Where 526 is user ID of that user.
And 716 is usergroup of that user.

Our Recommended VPS Hosting

eAccelerator is a popular PHP accelerator and optimizer. It improves and increases the performance of PHP scripts by caching them. eAccelerator can typically reduces server load and increases the speed of your PHP code by 1-10 times.

By default eAccelerator saves cache in /var/cache/eaccelerator directory. But eAccelerator cache directory can be different on some server. Like it may can be /tmp/eaccelerator

Sometimes, you may need to clear eAccelerator cache to free up some space in /var or /tmp directory.

Here is how you can delete / clear / flush eAccelerator cache.
Login in server as root via SSH, and execute following command.

If eAccelerator cache directory is /tmp/eaccelerator, use below command to delete all cache older than 24 hours.

tmpwatch --mtime --all 24 /tmp/eaccelerator

If eAccelerator cache directory is /var/cache/eaccelerator, use below command to delete all cache older than 24 hours.

tmpwatch --mtime --all 24 /var/cache/eaccelerator

Our Recommended Dedicated Server

Error_log file saves the error logs of a account / user / website. There can be multiple error_log file under one user / account / website.

These error_log files may consume lots of space on your server. Sometimes the size of error_log files are in GB. So, you may want to delete all error_log files to free up some space on server.

Login in server via SSH as root and execute following command:

find /home -type f -name error_log -exec rm -f {} \;

The above command will search for error_log files in /home directory and delete them. Thus it will delete all error_log files under all users / accounts / cPanel accounts / websites.

Note:

1) This command can take lots of time to complete depending on size of your /home directory. Sometimes it may take 10-30 minutes to complete.

2) If required server will automatically create new error_log files.

Our Recommended Dedicated Server