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

DMARC

DMARC is used to protect your email from email spoofing. DMARC use SPF and DKIM record to validate your email.

DMARC is a TXT record added in your domain DNS.

DMARC record look like

p=POLICY_HERE

This specifies what to do with incoming email that fails DMARC.

Valid options are none, quarantine and reject.

p=none – used for monitoring. If DMARC fails, remote mail server will sent a mail to “rua” or “ruf” tags specified in DMARC record.

p=quarantine – tell recipient mail server to put message in SPAM folder if DMARC fail.

p=reject – reject mail if DMARC fail.

rf=afrf – Specify type of report you will get.

List kernel modules

To list kernal modules, use

Example

Logging Linux Commands for all users

To log commands executed by users on Linux shell, edit file

Add

Create file

Add

Restart rsyslog

Now log off and login, you will be able to see all commends executed by users on bash shell in file /var/log/commands.log

Log rotating

edit

Find

Add below