Quantcast
Channel: Linux CPanel / WHM
Viewing all 101 articles
Browse latest View live

Simple shell script to check if a Host is UP

$
0
0
If you work on multiple servers and want to check what hosts are up/down then you can use the below shell script to  test multiple servers  connectivity ::
#!/bin/bash
# test1.txt should contain a list of IP's to be tested
for i in `cat test1.txt`;
do
ping -c 1 -W 1 $i &> /dev/null
if [ $? -ne 0 ]; then
#use if [ $? -eq 0 ]; then to test the up IP's
echo "$i is down"
fi
done

How to enable mod_deflate globally in cPanel/WHM

$
0
0
This will be a quick one folks.  The Apache module mod_deflate helps in reducing the size of the information sent to a user, by compressing things prior.  It seems to work very well.  To test if your site already has mod_deflate installed and working, you can go here:

http://www.whatsmyip.org/http_compression/

To enable mod_deflate on your WHM / cPanel server, make sure you run EasyApache through WHM, and select to install mod_deflate.  Once done, you’ll notice that it is not active globally.  In your cPanel control panel for your domain, you should notice that under “Software / Services” an icon called “Optimize Website” is now there.  This is how you control mod_deflate on a per user basis.

If however, you wish enable it globally, so that all websites on your server can benifit from this, you need to venture back into WHM, and this time go to:

Services Configuration >> Apache Configuration >> Include Editor >> Post VirtualHost Include, and select All Versions

Now, paste the following into this file, and hit Update:

SetOutputFilter DEFLATE

# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary


SetEnvIfNoCaseRequest_URI"\.(?:gif|jpe?g|png)$" no-gzip 

That’s it, now, go back to the site I gave you at the start, load up your website, and verify that compression is now functioning.

For you command line users, you can achieve this my running the easy apache command line build (/scripts/easyapache), and select to include mod_deflate.  Once that is done, you can edit the “/usr/local/apache/conf/includes/post_virtualhost_2.conf” file, and paste the above code into it to achieve the same results.  Remember to restart apache once you’ve edited the file. 

How do I disable SSH login for the root user?

$
0
0
Instructions

NOTE: In the following example, we are using admin for the username. This is just a example and can be replaced with any username you wish to use.

1. Add the user. In the following example, we will use the user name admin. The command adduser will automatically create the user, initial group, and home directory.

[root@root ~]# adduser admin
[root@root ~]# id admin
uid=10018(admin) gid=10018(admin) groups=10018(admin)

[root@root ~]# ls -lad /home/admin/
drwx------ 2 admin admin 4096 Jun 25 16:01 /home/admin/



2. Set the password for the admin user. When prompted, type and then retype the password.


[root@root ~]# passwd admin
Changing password for user admin.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

[root@root ~]#


3. SSH to the server with the new admin user and ensure that the login works.

[root@root ~]# ssh admin@my.ip.or.hostname
admin@my.ip.or.hostname's password:

[admin@admin ~]$

Adding the User to the Wheel Group

nano /etc/group
wheel:x:10:root,admin


4. Verify that you can su (switch user) to root with the admin user.

[admin@admin ~]$ su -
Password:
[root@root ~]$ whoami
root

5. Edit /etc/ssh/sshd_config with your favorite text editor.

[root@root ~]# nano /etc/ssh/sshd_config

Change this line:

#PermitRootLogin yes

Edit to this:

PermitRootLogin no


6. Ensure that you are logged into the box with another shell before restarting sshd to avoid locking yourself out of the server.

[root@root ~]# /etc/init.d/sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
[root@root ~]#

You will now be able to connect to your server via ssh with the admin user and then use the command su to switch to the root user.

How to whitelist your IP at CPHulk

$
0
0
cd/script
 
./cphulkdwhitelistxxx.xxx.xxx.xxx

Just don’t forge to replace xxx.xxx.xxx.xxx with your IP addres

How to solve: cPanel update failure: ***** FATAL: Cannot proceed. Needed system RPMs were not installed

$
0
0
On your VPS or dedicated server running CloudLinux (or CentOS switched to CloudLinux) you may find this problem while trying to upgrade your cPanel to the newest version:

[20130322.110359] Error: Protected multilib versions: libwmf-lite-0.2.8.4-22.el6.i686 != libwmf-lite-0.2.8.4-22.el6.centos.x86_64
[20130322.110359] You could try using --skip-broken to work around the problem
[20130322.110400] ** Found 5 pre-existing rpmdb problem(s), 'yum check' output follows:
[20130322.110400] bandmin-1.6.1-5.noarch has missing requires of perl(bandmin.conf)
[20130322.110400] bandmin-1.6.1-5.noarch has missing requires of perl(bmversion.pl)
[20130322.110400] bandmin-1.6.1-5.noarch has missing requires of perl(services.conf)
[20130322.110400] exim-4.80-5.x86_64 has missing requires of perl(SafeFile)
[20130322.110400] frontpage-2002-SR1.2.i386 has missing requires of libexpat.so.0
[20130322.110400] Prelinking shared libraries and binaries: /usr/sbin/prelink -av -mR
[20130322.110405] E Sysup: Needed system RPMs were not installed: libwmf
[20130322.110405] ***** FATAL: Cannot proceed. Needed system RPMs were not installed.
[20130322.110405] The Administrator will be notified to review this output when this script completes
[20130322.110405] E Detected events which require user notification during updatenow. Will send iContact the log
=> Log closed Fri Mar 22 11:04:05 2013
[20130322.110405] E Running `/usr/local/cpanel/scripts/updatenow --upcp --log=/var/cpanel/updatelogs/update.1363968224.log --force` failed, exited with code 4608



To resolve this issue, run these commands:
yum remove libwmf-lite lvemanager
yum install lvemanager
Then /scripts/upcp will work fine

How can I reboot my VPS from SSH?

$
0
0
To reboot your VPS using SSH, run as root the following command: 

reboot

Outlook - Update to enable TLS 1.1 and TLS 1.2 as a default secure protocols

$
0
0
Due to the recent version changes, cPanel software uses a secure version of TLS, v1.2 and will prevent email clients from accessing secure email with older, less secure ones such as TLS v.1.1 , TLS v.1.0 and SSL 2 and 3 . It is possible that the version of the mail client being used or the version of windows is the major reason for the recent issues. For example, if on Windows 7, Windows 7 may not be fully up to date or may not offer appropriate support for the minimum required version of TLS cpanel now support. Microsoft itself has published methods of allowing this to work:

It is better to try configuring your  operating systems and web browsers to use TLS v1.2 according to sites such as these:
 

Follow the instructions below:

a) Update Windows 7/8 using Windows Update and download/install all important updates. For windows 7 is important that you install Service Pack 1.

b) Install KB3140245 and reboot: http://catalog.update.microsoft.com/v7/site/search.aspx?q=kb3140245

c) Execute the EasyFix and reboot: https://support.microsoft.com/en-us/help/3140245/update-to-enable-tls-1-1-and-tls-1-2-as-a-default-secure-protocols-in

d) Start > Search for Execute, Type Regedit and press Enter to access Windows Registry.

Check this registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\Schannel\Protocols

Under the Protocols key, add two new keys, if not already there: One called “TLS 1.1” and one called “TLS 1.2“. Inside both of these keys, add another key called “Client“. Now create a DWORD value in each Client key called “DisabledByDefault” whose value is 00000000.

Reboot and start Outlook.

If Outlook is still not able to send or can't connect to port 465, change to port 25.

Do check the url at:

https://support.microsoft.com/en-us/help/3140245/update-to-enable-tls-1-1-and-tls-1-2-as-a-default-secure-protocols-in

How to Restore a Full cPanel Backup to VPS

$
0
0
Backup restoration is one of the essential tasks every server administrator must know how to perform. Under cPanel it is really simple to restore full backup of one account. In this tutorial we are going to show you two very easy methods about how to restore a full cPanel backup to a Linux VPS.

Restore Full cPanel Backup via WHM

 

The first method is to restore the full cPanel backup via WHM. Of course, in order to be able to restore the backup using this method you need to have root access to WHM which is listening on port 2087. So if your domain is example.com, you can access WHM via web browser at https://example.com:2087.
Once you log in to WHM, navigate to Backups and then select Restore a Full Backup/cpmove File. This WHM feature will allow you to restore specific backup by choosing one of the two possible methods, Restore with Username or Restore with File.
To restore with username, you must upload the full cPanel backup file to one of the following directories:

/home
/home2
/home3
/root
/usr
/usr/home
/web

Additionally, the filename of the full cPanel backup must use one of the following formats:

cpmove-{USER}
cpmove-{USER}.tar
cpmove-{USER}.tar.gz
{USER}.tar
{USER}.tar.gz
backup-{BACKUP-DATE_TIME}_{USER}.tar
backup-{BACKUP-DATE_TIME}_{USER}.tar.gz
 
For example, if the username for the account you want to restore is example_user you should select the username from the drop down list. See the screenshot below for more details.

If there is no full cPanel backup uploaded in one of the above directories for that username, it will not be available for selection. Therefore, make sure that the full cPanel backup is properly uploaded on your cPanel server.
Once you are ready to restore the backup, hit the Restore button and let cPanel do its work.
In case you want to restore a full cPanel backup using a file, select Restore with File, then click on Choose file and select the backup file from your local filesystem. The backup file will be uploaded on the server and restored.

Restore Full cPanel Backup via command line

Yes, this is another method which some server admins find much easier than the first one. For this method you need to have SSH access to the server. Connect to your Linux server via SSH and run the following command as root:

/scripts/restorepkg example_user

Of course, you need to replace example_user with the actual username for the account you want to restore. Also, make sure that the full cPanel backup is properly uploaded in the /home directory on your server before starting the restoration process.





Basic Linux Commands

$
0
0
In this article, I am going to provide you a brief overview of some of the most commonly used and essential Linux Commands. Becoming familiar with these commands will help you get far in a fairly short amount of time.


  • ls Displays everything in the current directory
  • ls -a Displays all files, including hidden
  • ls -l Displays all files, along with the size and timestamp
  • tar -zxpf Uncompresses tar.gz files
  • tar -xpf Uncompresses .tar files
  • gunzip Uncompresses .gz files
  • cp /path/to/old /path/to/new Copies a file to a new file
  • mv /path/to/old /path/to/new Moves a file to a new file, or rename
  • mkdir Creates a directory
  • rmdir Deletes a directory
  • rm Deletes a file
  • rm -rf Deletes a directory
  • cd /path/to/dir Moves to a directory
  • cd .. Move up one directory
  • cd ~ Moves to your home directory
  • cd – Moves to the previous directory
  • pwd Displays the present working directory (the one you’re in)
  • pico Edits a file
  • ftp Connect to a FTP server
  • lynx View a webpage
  • df Displays the hard drive stats
  • quota Displays your quota
  • uptime Displays the uptime of the server
  • uname -a Displays the operating system stats
  • whoami Displays your info
  • who Displays others connected to the server
  • last Displays the last login
  • whereis Tells where a file is located
  • BitchX IRC Client
  • mail Check your email
  • ps -x Displays processes your running
  • ps -a Displays all processes running
  • ps -ux Displays running processes, with CPU/Memory usage
  • kill pid# Kills a process
  • kill -9 pid# Kills an eggdrop process
  • killall proc_name Kills all running process of the same type
  • whatis Description of commands
  • man command Displays help on the command (manual)
  • nano Same as Pico (Use yum install nano if it doesn’t first work)
  • Top – gives an overall view of what is going on with the server including memory usage, serve load and running processes “q” to exit top
  • sar -q gives a report of the process list, 1 minute and 5 minute average load every 10 minutes since midnight server time
  • tar -zcf filename.tar.gz file Tars up the file or directory of your choice, replace filename.tar.gzwith the name you want your tar file to have…with the tar.gz extension on the end and replace file with the file or directory you want to tar up. Can also use a path/to/file for both.
  • updatedb – Updates the locate/search DB.
     

netstat -n -p
Useful to see who is connected to your server, this also resolves hostnames to IP addresses and the -p switch shows you what each person connected is doing and provides a PID for it if there is one… useful if you need to kill something
find / -user username
Replace username with a username of one of your account to find all the files that belong to them. Also useful to add the |more switch so you can scroll one screen at a time. Ever have a client who seems to show a lot more files than are actually in their home directory? This is how you find those files and fix them. Common problem is cpmove files that don’t get properly deleted and get added to a users account.
/scripts/pkgacct2 username
Replace username with a user on your system. This should be done from the home directory. Useful for manually backing up an account if whm copy account doesn’t work. Then just move (mv) the file to a home directory accessible via the web and
chown user.user filename
and chmod to 750 or 755 and you can wget it from a different server if need be.
/scripts/restorepkg username
Once you’ve got the file and need to unpack it you use this command. The file should be in the /home directory to use this though. Remember folks…. username…. not cpmove-username.tar.gz
crontab -e
edit the crontab file and see what is set to run in there.
–help (add to end of the command following a single space)
Such as tar –help, similar to man it digs up info on any given command.
tail -10 filename
gives you the last 10 lines of a file. Can change the # to whatever you want.
cp -R FileOrDirectory path/to/destination
the -R allows you to copy an entire directory to somewhere else.
kill -9
not just for eggdrops… it’s called a “hard kill” and handy for killing off any stubborn process that refuses to die.
whereis filename (use the * as a wildcard or for broader search)
can also use locate or find (although locate is faster)
killall
not just for killing programs.. you can also killall to kill all processes being run by a user. Handy if you have an abuser eating up system resources.

RESTART SERVICES:

service servicename restart
Stop a service:
service servicename stop
Start a service:
service servicename start
Status (doesn’t work on all):
service servicename status
On a RedHat CPanel server, here are the useful services: (CentOS, x10′s default OS for VPSs, is a stripped-down RedHat OS.)
bandmin
chkservd
cpanel
crond
exim
httpd
mysql
named
proftpd

CRON INFO:

Root crontab: (can be used by any user with crontab permissions to edit their crontab. If you are running this as “root” it will edit root’s crontab, and the same goes for any other user. When “bob” runs crontab -e, he will edit his own crontab and not root’s, though he can only edit his own crontab if he has permissions.)
crontab -e
To edit a users cron jobs: (run as a super-user, such as root. not available to regular users.)

crontab -u username -e

Replace username with the actual username of the client you want to edit.
(We’re still talking about RedHat [CentOS] that is running cPanel below. You can do most, if not all, of this from the WHM, so feel free to skip ahead a bit.)
  • /scripts/adddns Add a Dns Entry
  • /scripts/addfpmail Install Frontpage Mail Exts
  • /scripts/addservlets Add JavaServlets to an account (jsp plugin required)
  • /scripts/adduser Add a User
  • /scripts/admin Run WHM Lite
  • /scripts/apachelimits Add Rlimits (cpu and mem limits) to apache.
  • /scripts/dnstransfer Resync with a master DNS Server
  • /scripts/editquota Edit A User’s Quota
  • /scripts/finddev Search For Trojans in /dev
  • /scripts/findtrojans Locate Trojan Horses
  • Suggested Usage:
  • /scripts/findtrojans < /var/log/trojans
  • /scripts/fixtrojans < /var/log/trojans
  • /scripts/fixcartwithsuexec Make Interchange work with suexec
  • /scripts/fixinterchange Fix Most Problems with Interchange
  • /scripts/fixtrojans Run on a trojans horse file created by findtrojans to remove them
  • /scripts/fixwebalizer Run this if a user’s stats stop working
  • /scripts/fixvaliases Fix a broken valias file
  • /scripts/hdparamify Turn on DMA and 32bit IDE hard drive access (once per boot)
  • /scripts/initquotas Re-scan quotas. Usually fixes Disk space display problems
  • /scripts/initsuexec Turn on SUEXEC (probably a bad idea)
  • /scripts/installzendopt Fetch + Install Zend Optimizer
  • /scripts/ipusage Display Ipusage Report
  • /scripts/killacct Terminate an Account
  • /scripts/killbadrpms Delete \”Security Problem Infested RPMS\”
  • /scripts/mailperm Fix Various Mail Permission Problems
  • /scripts/mailtroubleshoot Attempt to Troubleshoot a Mail Problem
  • /scripts/mysqlpasswd Change a Mysql Password
  • /scripts/quicksecure Kill Potential Security Problem Services
  • /scripts/rebuildippool Rebuild Ip Address Pool
  • /scripts/remdefssl Delete Nasty SSL entry in apache default httpd.conf
  • /scripts/restartsrv Restart a Service (valid services: httpd,proftpd,exim,sshd,cppop,bind,mysql)
  • /scripts/rpmup Syncup Security Updates from RedHat/Mandrake
  • /scripts/runlogsnow Force a webalizer/analog update.
  • /scripts/secureit Remove non-important suid binaries
  • /scripts/setupfp4 Install Frontpage 4+ on an account.
  • /scripts/simpleps Return a Simple process list. Useful for finding where cgi scripts are running from.
  • /scripts/suspendacct Suspend an account
  • /scripts/sysup Syncup Cpanel RPM Updates
  • /scripts/ulimitnamed RH 6 only. Install a version of bind to handle many many zones.
  • /scripts/unblockip Unblock an IP
  • /scripts/unsuspendacct UnSuspend an account
  • /scripts/upcp Update Cpanel
  • /scripts/updatenow Update /scripts
  • /scripts/wwwacct Create a New Account

Delete MRTG

rpm -e –nodeps `rpm -qa|grep mrtg`

Empty /tmp folder

rm -R -f /tmp/c*
rm -R -f /tmp/s*
rm -R -f /tmp/p*
rm -R -f /tmp/*_*
rm -R -f /tmp/*-*

WHM/Cpanel Increase The Size Of /tmp (/usr/tmpDSK) Partition

$
0
0
You may have noticed that cPanel’s default partition size for /tmp is
512 MB, which in some cases can be way too small. And sometime you probably get this report email:
Drive Critical: /usr/tmpDSK (/tmp) is 100% full
Although cPanel automatically deletes the unused files, the /tmp would be getting full very quickly on a busy server.
The /tmp partition on cPanel servers, assuming it was the one cPanel created and not one you did yourself, is a file-based partition that can easily be resized.
By default on most servers, /tmp is the temporary dumping place for a lot of things, for example:
  • PHP session files
  • PHP temporary file uploads
  • MySQL temporary files
  • Cache files for certain Apache modules


Most software that uses temporary files or sessions will automatically prefer to use /tmp – this folder is usually set to 777 permissions and therefore writeable by every user on the server. When your /tmp partition fills up, it can cause noticeable problems for your users. If you run a larger server, the /tmp folder can fill up quickly and be very annoying as far as maintenance is concerned. Fortunately there is a very easy way to increase the size of this partition on a standalone server.
  1. Stop MySQL, Apache, and cPanel to prevent writing to the /tmp partition
  2. Copy the contents of /tmp to another location, such as /tmp_backup (cp -rfp /tmp /tmp_backup)
  3. Unmount /tmp. If you’re unable to, you can do an lsof (lsof |grep /tmp) to see what processes are still writing to it, and kill them off. Or do a lazy unmount (umount -l /tmp) .
  4. Delete /usr/tmpDSK (rm -rf /usr/tmpDSK)
Now open /scripts/securetmp and look for this line:
my $tmpdsksize = 512000; # Must be larger than 250000
And change the value of “512000″ to your desired size in MB, and save the
file. Now run the following script to recreate /tmp:
[root@yohanes ~]# /scripts/securetmp
This will recreate your /tmp (tmpDSK) partition using the size you specified. While the securetmp script may be overwritten in a cPanel update, the size of /tmp will not be affected one you alter its size.

Install nginx as reverse proxy in cPanel

$
0
0
The web-hosting control panel’s default web-server is Apache. cPanel/WHM doesn’t have native support on Nginx, but we can install and configure it so that it will improve the server performance.

Why run Apache and Nginx together? Is there any advantage by using Nginx as reverse proxy on Cpanel?

Both Apache and Nginx are powerful and effective web-servers. Apache is the topmost webserver since it was released in 2006 and Nginx is now using top websites. The reason for using Apache and Nginx are clear, Apache’s power and Nginx’s speed. By setting Nginx as reverse proxy, we can increase the website’s speed and performance on the server. This is because, Nginx will take care of all static contents in the website such as CSS, images, SWF files, MP4 and more. Apache will manage the rest of requests (dynamic requests – php page). This is known as a Nginx reverse proxy setup. Nginx stand as a front end server with a powerful backend Apache server.

How to set up?


If you wish to install nginx as reverse proxy on Cpanel then, follow these steps:
1. SSH to server as root.
2. Change the directory to “/usr/local/src”
# cd /usr/local/src
Download the latest nginxadmin package & install
#wget http://nginxcp.com/latest/nginxadmin.tar 
#tar xf nginxadmin.tar
#cd publicnginx
#./nginxinstaller install
In WHM, Nginx Admin plugin will now be available under plugins section. After installing make sure Nginx process is running on the server, You can chcek this by using the following command.
# ps aux | grep nginx
If it is not showing any process, then kill httpd and restart httpd
#killall -9 httpd
#/etc/init.d/httpd restart
Nginx Admin Uninstall instruction:
#cd /usr/local/src 
#wget http://nginxcp.com/latest/nginxadmin.tar
#tar xf nginxadmin.tar
#cd publicnginx
#./nginxinstaller uninstall

P.S. Make sure that the Nginx is running on port 80 and Apache on different port (like 8080). Don’t forget to open the new port the server firewall.

Install Memcache onto cPanel

$
0
0
Memcached is a service that allows entire database tables to be stored in memory, drastically speeding up queries to those tables and alleviating database load. In WordPress and W3 Total Cache, the Memcached module allows you to store all cache tables in memory.
This guide can be used to set up Memcached on CentOS.

To install memcached on cpanel server, login to SSH as user root, run

   
yum install memcached
Enable memcached start on boot with
systemctl enable memcached
Start memcached with
   
systemctl start memcached

Enable memcached PHP module
For PHP applications to use memcached, we need PHP module installed. To install login to WHM as user root, go to
Home > Software > Module Installers









Click on Manage link for PHP Pecl. On next screen, search for memcache.





Click the link link right side of memcache and memcached.


Now check phpinfo() page, you will see memcache listed.





How to Install eAccelerator on cPanel Server

$
0
0
eAccelerator is a free open-source PHP optimizer & accelerator. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. Enhances execution of scripts. It typically reduces server load and increases the speed of your PHP code by 10 times. Stores compiled PHP scripts in shared memory and executes code directly from it. It creates locks for a short time, so one script can be executed at the same time by several engines. Files that can’t fit in shared memory are cached on disk.
Installing eAccelerator on your linux dedicated/VPS can be achieved by just one command.

 
# /scripts/phpextensionmgr install eAccelerator 

Un-installation of eAccelerator

/scripts/phpextensionmgr uninstall EAccelerator


Check with the command below if eAccelerator has been installed properly.


# php -v
Make sure that the eaccelerator.so file available on extensions directory after the eAccelerator installation.

/usr/local/lib/php/extensions/no-debug-non-zts-20090626

Add the following lines at the end of php.ini

extension=”eaccelerator.so”

Restart Apache web-server.

service httpd restart


How to check the Inode usage for an account in cPanel server

$
0
0
First of all, let me briefly explain about Inode. Index Node (inode) is a basic concept in Linux/Unix. Index node/number (inode) is a data structure which contain the information about a file in your server/hosting account.

Inode save the information such as user and group ownerships, access mode (read, write, execute permissions) and file type.
Number of inodes indicates the number of files and folders in your account. Every file like a webpage, image file, an email, cache file etc will count as 1 inode.
In a WHM server, you can view the inode usage of your account from left side of your cPanel which is denoted by the term “File Usage”.


Note, this feature must be enabled from the WHM's tweak settings (Display File Usage information in the cPanel stats bar (inode count)) to display in cPanel. [Default OFF]



100% Inode usage

If your account has reached/exceeded the Inode usage and you’re not sure about the reason for this. Don’t worry. Here’s the solution for this! If the account has reached the maximum inodes allocated for your account then it’ll affect your account, website and email performance.

You won’t be able to send/receive new emails, you won’t be able to upload a new file to your account. Hence it’ll affect the total performance of your account.
How to know what’s eating up the inodes?

If you have SSH access to your account the following commands will help you to understand the inode usage in your hosting account.

# find . | wc -l

This command will give you the total inode count of your account. To get the detailed inode usage that is which files/folders are consuming more inode you can use the following command.

# echo "Detailed Inode usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf "$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n"

This will give the Inode usage of your current working directory. If you need to find the Inode usage of your entire hosting account, execute this command in the location /home/user.

*Replace “user” with your username.

[root@vps datlinux]# ll
total 20
drwxr-xr-x 2 root root 4096 Oct 10 10:42 test1
drwxr-xr-x 2 root root 4096 Oct 10 10:24 test2
drwxr-xr-x 2 root root 4096 Oct 10 10:42 test3
drwxr-xr-x 2 root root 4096 Oct 10 10:24 test4
drwxr-xr-x 2 root root 4096 Oct 10 10:24 test5
[root@vps datlinux]#
[root@vps datlinux]#
[root@vps datlinux]# echo "Detailed Inode usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf "$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n"
Detailed Inode usage for: /home/datlinux
5               - test1
1               - test2
5               - test3
1               - test4
1               - test5
Total:          17

How to reduce Inode usage in your account?

Here’re some suggestions to reduce the inode usage in your account.
1. Remove all unnecessary files and folders from your account.

Using FileManager you can remove unnecessary files/folders from your account.If you have the backups stored in your root directory, that is /home/user; you can download it to your local machine using FTP or FileManager.
2. Remove cache files

Certain CMS like Joomla will store lot of cached files which are used to improve the performance of your website. If there’re large amount of cache files, you can use the purge functionality to clear the cache folders. This can be done via administrator panel.
3. Archive your emails

Emails will also add inode to your account. If you’re storing all emails in the server which you think as important emails you can archive emails like emails which are older than 6 months and you can download it your local machine.

If you have enabled Default Address (catch all) for your account, you should regularly check the mailbox and clear all the unwanted emails. You need to delete all the unusing email accounts. Also you should check your email accounts and need to delete spam emails.
4. Other usage

If your account still uses large number of files you can take a look at the “Disk Usage” from cPanel.

cPanel >> Files >> Disk Space Usage
This will give you the information regarding the disk used by your account.

That’s it!!

Common SSH Commands - Linux Shell Commands

$
0
0
Navigation

pwdShows the full path of the current directory
lsLists all the files in the current directory
ls -alLists all files and information
ls –alRLists all files and information in all subdirectories
ls -alR | moreSame as ls –alR, pausing when screen becomes full
ls -alR > filename.txtSame as ls –alR, outputs the results to a file
ls *.htmlLists all files ending with .html
cd [directory name]Changes to a new directory
cd ..Changes to directory above current one
clearClears the screen
vdirGives a more detailed listing than the "ls" command
exitLog off your shell

Moving, Copying, and Deleting Files

mv [old filename] [new filename]Move/rename a file
cp [filename] [new filename]Copies a file
rm [filename]Deletes a file
rm *Deletes all files in current directory
rm *.htmlDeletes all files ending in .html
Creating, Moving, Copying and Deleting Directories
mkdir [directory name]Creates a new directory
ls -d */Lists all directories within current directory
cp -r [directory] [new directory]Copies a directory and all files/directories in it
Searching Files and Directories
find . -name [filename] -printSearches for a file starting with current directory
grep [text] [filename]Searches for text within a file



File and Directory Permissions

There are three levels of file permissions: read, write and execute.  In addition, there are three groups to which you can assign permissions: file owner, user group and everyone.  The command chmod followed by three numbers is used to change permissions.  The first number is the permission for the owner, the second for the group and the third for everyone.  Here are how the levels of permission translate:

0 = ---No permission
1 = --XExecute only
2 = -W-Write only
3 = -WXWrite and execute
4 = R--Read only
5 = R-XRead and execute
6 = RW-Read and write
7 = RWXRead, write and execute

It is preferred that the group always have permission of 0.  This prevents other users on the server from browsing files via Telnet and FTP.  Here are the most common file permissions used:

chmod 604 [filename]Minimum permissions for HTML file
chmod 705 [directory name]Minimum permissions for directories
chmod 755 [filename]Minimum permissions for scripts & programs
chmod 606 [filename]Permissions for data files used by scripts
chmod 703 [directory name]Write-only permissions for public FTP uploadin

How do I unzip a file with telnet?

All of the below commands assume that you are within the same directory that the compressed file is in. To be sure type:

ls {enter}

If the file is there, you're ready to go. If not type:

cd /big/dom/xdomain/www/directory/ {enter}

replacing the path with the correct path to your file.

If a file ends in .zip (for example, file.zip) type:

unzip file.zip

If a file ends in .tar (e.g., file.tar) type:

tar -xvf file.tar

If a file ends in .gz (for example, file.gz) type:
gzip -d file.gz

If a file ends in .tar.gz (e.g. file.tar.gz) type:

gzip -d file.tar.gz
and then

tar -xvf file.tar
If a file in .tgz (e.g. file.tgz)
zip [options] [zipfile] [files]
The zip command compresses a file or list of files into a zip format archive file. This command is compatible with pkzip on a PC. Simply type "zip zipfile file1 file2 file3" at a telnet command prompt and replace zipfile with the name you want to use for your compressed zip archive file, and replace fileX with the name of the file(s) you want to compress into the zip archive.
For example, type "zip backup.zip home.html index.html" at a telnet command prompt to compress and archive the files called home.html and index.html into the file called backup.zip.
unzip [options] [zipfile]
The unzip command extracts a zip format archive file. This command is compatible with pkunzip files from a PC. Simply type "unzip zipfile" at a telnet command prompt and replace zipfile with the name of your zip format archive file.
For example, type "unzip -aL old.zip" at a telnet command prompt to extract files contained in the archive called old.zip. The "-aL" are options that are generally useful when unzipping files created on a PC.

Creating a Welcome message for SSH logins

$
0
0
Did you ever want to change or create a new login message anytime someone logs into SSH? We'll show you how it's done.

First off login to the server as root. Then type in the following:
pico /etc/motd

Now type in the security login message you wish all users to see once they login to your server through SSH. Try something like this as a start:

This computer system is for authorized users only. All activity is logged and regulary checked by systems personal. Individuals using this system without authority or in excess of their authority are subject to having all their services revoked. Any illegal services run by user or attempts to take down this server or its services will be reported to local law enforcement, and said user will be punished to the full extent of the law. Anyone using this system consents to these terms.

Now type Ctrl+Xthen hitYandenter.
Logout of SSH then log back in, you will receive your new greeting!

Changing Server Hostname

$
0
0
To change your hostname, enter the following command as root:

$ hostname servername.yourdomain.com

If you are using cPanel, you will need to resync your license with the cPanel license server.  To do this, use the following command:

$ /usr/local/cpanel/cpkeyclt

dd command to migrate VPS on linux platform

$
0
0
First create new vps with same configuration on another node. It doesn't matter new vps is having os or not or you can choose any OS.

Once same configuration VPS setup done then use below command to migrate VPS.

    dd if=/dev/guestos/kvm2351_img | ssh 10.10.10.10 "dd of=/dev/guestos/kvm2520_img"

Once migration is completed then try starting VPS on new node.

Kill restore process in new cpanel

$
0
0

In new cpanel/WHM when we try to kill restore process it is still showing in WHM >> restore full backup. Below are the steps to remove that process from WHM.

You can manually mark the transfer as completed using the following instructions:

Ensure the transfer is no longer running by clicking on the “View” option under "Sessions in Progress" for this transfer. In the new window, there will be a line that looks like this:

    You may close this window and view the transfer on the command line: /usr/local/cpanel/bin/view_transfer 1071601843quick20141013154952IAZhRro

Access your server via SSH and run that command (the transfer name will be different on your server):

    /usr/local/cpanel/bin/view_transfer 1071601843quick20141013154952IAZhRro

As an example, you might see output like this:

    Transfer running with pid: paused
    [795 ][MASTER ]: Start Session
    [795 ][MASTER ]: Version: 1.9

You will note that the master PID for this transfer is xxx. If the process still exists, and the transfer has failed, then you can kill that process:

    kill -9 xxx

The next step requires you to change the entry for this transfer in the whmxfer.sessions table in MySQL. Find the entry with the session ID for your migration. In the example we have been using, it's ' 1071601843quick20141013154952IAZhRro .' It will look like this:

    mysql -e "select * from whmxfer.sessions where sessionid='1071601843quick20141013152137YIVT7Ze'"
    +--------------------------------------+--------------+-------+---------+-----------------------+-------------+-------+---------------------+---------+
    | sessionid | initiator | pid | version | target_host | source_host | state | starttime | endtime |
    +--------------------------------------+--------------+-------+---------+-----------------------+-------------+-------+---------------------+---------+
    | 1071601843quick20141013152137YIVT7Ze | quickrestore | 21295 | 1.9 | vps1.insurancedxb.com | localhost | 50 | 2014-10-13 08:21:37 | NULL |
    +--------------------------------------+--------------+-------+---------+-----------------------+-------------+-------+---------------------+---------+

You will need to change the 'state' field to 100, and change the 'endtime' field from NULL to a time after the 'starttime' field:

    mysql -e "update whmxfer.sessions set state='100', endtime='2014-10-14 09:37:52' where sessionid='1071601843quick20141013152137YIVT7Ze'"

If you check it again then you will notice that process ended.

    +--------------------------------------+--------------+-------+---------+-----------------------+-------------+-------+---------------------+---------------------+
    | sessionid | initiator | pid | version | target_host | source_host | state | starttime | endtime |
    +--------------------------------------+--------------+-------+---------+-----------------------+-------------+-------+---------------------+---------------------+
    | 1071601843quick20141013152137YIVT7Ze | quickrestore | 21295 | 1.9 | vps1.insurancedxb.com | localhost | 100 | 2014-10-13 08:21:37 | 2014-10-14 09:37:52 |
    +--------------------------------------+--------------+-------+---------+-----------------------+-------------+-------+---------------------+---------------------+

The transfer should then no longer appear under "Sessions in Progress."

You can reconfirm the same by login into WHM.

How to upgrade ubuntu 16.04 to ubuntu 18.04

$
0
0
Check Ubuntu version before upgrading.

    lsb_release -a

First, we have to run an update

    sudo apt update

Then run upgrade command

    sudo apt upgrade

After that dist-upgrade

    sudo apt dist-upgrade

Then update core manager

    sudo apt install update-manager-core

Then edit below file

    sudo vim /etc/update-manager/release-upgrades

At the end of the file set

    Prompt-lts

Then save this file

Then do a release upgrade

    sudo do-release-upgrade -d

Once done, Then restart the machine and check again.
Viewing all 101 articles
Browse latest View live