Resize a linux file system with resize2fs

On cloud servers, once you upgrade disk, you will need to resize the filesystem. On Linux ext4 file system, you can do this with command resize2fs.

To resize filesystem on /dev/sdb, run

Here the full disk is used as file system with NO partition. If you have partion, you need to specify partition number like /dev/sdb1

Plesk move vhosts folder

Plesk use /var/www/vhosts folder to store sites. On some servers this folder will be on smaller partition. Say you have all disk space on partition /home, in such cause, you can use following command to move web site files to /home folder with following command.

/home/ = you can replace this any any folder you wish. Plesk will move the site files, update the configuration as required.

NOTE: In this example, i used /var/www/vhosts instead of /home/ as the server was using non default folder for vhosts, i am moving all sites back to default location (/var/www/vhosts).

See Plesk

Bandwidth Limit on rsync

I wanted to transfer some files between two computers, but don’t want to use all bandwidth available on the network as it will affect other users on the network.

To limit bandwidth, use –bwlimit Option.

Here –bwlimit=1500 will limit bandwidth usage to 1.5 MB/s.

See rsync

Redirect a site to HTTPS using PHP

This PHP script will redirect web site visitor to HTTPS (SSL) url. You can add this in your index.php of the web site

You can also use Apache mod_rewrite .htacess to do the redirection.

Install x11vnc on Ubuntu

To install x11vnc on Debian/Ubuntu, run

To start vnc server, run

By default, there will be no password. To set password, run

To start x11vnc server with password, run

Upload all files to FTP server using lftp

lftp allow you to upload all files and sub folders using single command. With normal ftp command, you need to use put/mput command many times to do the same.

To download all files from FTP server, use “mirror” command. mirror command also allow you to upload files to remote server by specifying -R (reverse mirror) option.

This is very useful for uploading files from SSH shell account.

For help, use ? in lftp command prompt. To get help for specific command use

Exampe

To upload all files from local folder to remote server, run

Following will upload vshare2.7 folder to FTP root folder.

See lftp

Download all files from FTP server using lftp

lftp is a command line FTP client, that can be used to download all files from a remote FTP server to local folder.

This is useful when you want to move migrate site from one server to another.

To download all files from FTP server, create an empty folder and change to it.

Run lftp command to connect to remove FTP server.

This will connect you to FTP server. Run following 2 commands as needed. First command will disable SSL, this is required if remote FTP server have no SSL installed. Second command will enable active FTP mode, will be useful if passive FTP don’t work for you.

Change the folder that you need to download and run

This will download everything from remote FTP server to your local folder.

See lftp