website enable and disable command in ubuntu

Command for enable website

$ sudo a2ensite 

Your choices are: 000-default default-ssl soa-ssl soatechnology
Which site(s) do you want to enable (wildcards ok)?

$  sudo systemctl reload apache2

Command for disable website

$ sudo a2dissite

Your choices are: 000-default default-ssl soa-ssl soatechnology
Which site(s) do you want to enable (wildcards ok)?

$  sudo systemctl reload apache2

To list all enabled virtual hosts on the web server, run the following command in a terminal.

$ apache2ctl -S

how to prevent denial of service attack ubuntu

How to check for and stop DDoS attacks on Linux

netstat -ntu|awk '{print $5}'|cut -d: -f1 -s |cut -f1,2 -d'.'|sed 's/$/.0.0/'|sort|uniq -c|sort -nk1 -r
sudo apt-get install net-tools -y
netstat -ntu|awk '{print $5}'|cut -d: -f1 -s |cut -f1,2,3 -d'.'|sed 's/$/.0/'|sort|uniq -c|sort -nk1 -r
netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c
sudo netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
sudo route add ADDRESS reject
sudo iptables -A INPUT -s ADDRESS/SUBNET -j DROP

how to install ftp server in ubuntu 20.04

Here we will install and configure vsftpd (Very Secure File Transfer Protocol Daemon) on Ubuntu.

Install vsftpd

Update the package list and dependencies for vsftpd. Then second command download and Install vsftpd.

$ sudo apt update && sudo apt install vsftpd

Check the status of vsftpd

$ sudo service vsftpd status
● vsftpd.service – vsftpd FTP server Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-04-27 19:35:30 IST; 13s ago Main PID: 54532 (vsftpd) Tasks: 1 (limit: 1137) Memory: 652.0K CGroup: /system.slice/vsftpd.service └─54532 /usr/sbin/vsftpd /etc/vsftpd.conf Apr 27 19:35:30 ubuntu systemd[1]: Starting vsftpd FTP server… Apr 27 19:35:30 ubuntu systemd[1]: Started vsftpd FTP server.

Configure Firewall

$ sudo ufw allow OpenSSH
$ sudo ufw allow 20/tcp
$ sudo ufw allow 21/tcp
$ sudo ufw allow 40000:50000/tcp
$ sudo ufw allow 990/tcp
$ sudo ufw enable
$ sudo ufw status
Status: active To Action From — —— —- OpenSSH ALLOW Anywhere Apache Full ALLOW Anywhere 3306 ALLOW Anywhere 20/tcp ALLOW Anywhere 21/tcp ALLOW Anywhere 40000:50000/tcp ALLOW Anywhere 990/tcp ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) Apache Full (v6) ALLOW Anywhere (v6) 3306 (v6) ALLOW Anywhere (v6) 20/tcp (v6) ALLOW Anywhere (v6) 21/tcp (v6) ALLOW Anywhere (v6) 40000:50000/tcp (v6) ALLOW Anywhere (v6) 990/tcp (v6) ALLOW Anywhere (v6)

Create FTP User

$ sudo adduser ftpuser
$ sudo nano /etc/ssh/sshd_config
DenyUsers ftpuser
$ sudo service sshd restart

Directory Permissions

Upload to a Web Server

$ sudo usermod -d /var/www ftpuser
$ sudo chown ftpuser:ftpuser /var/www/html

 Upload to a Home Folder

$ sudo mkdir /home/ftpuser/ftp
$ sudo chown nobody:nogroup /home/ftpuser/ftp
$ sudo chmod a-w /home/ftpuser/ftp
$ sudo mkdir /home/ftpuser/ftp/files
$ sudo chown ftpuser:ftpuser /home/ftpuser/ftp/files

Configure vsftpd

$ sudo mv /etc/vsftpd.conf /etc/vsftpd.conf.bak
$ sudo nano /etc/vsftpd.conf
listen=NO
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
force_dot_files=YES
pasv_min_port=40000
pasv_max_port=50000
user_sub_token=$USER
local_root=/home/$USER/ftp

We are done with vsftpd.conf

$ sudo systemctl restart vsftpd

Secure FTP with TLS (Recommended)

$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
$ sudo nano /etc/vsftpd.conf
ssl_enable=YES
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
require_ssl_reuse=NO
ssl_ciphers=HIGH
$ sudo systemctl restart vsftpd

Testing TLS with FileZilla

change pagination style in opencart

how to change design of pagination in opencart

Change or Add new class in pagination.php file stored in /home/ubuntu/public_html/shopping/system/library

<?php
/**
 * @package		OpenCart
 * @author		Daniel Kerr
 * @copyright	Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
 * @license		https://opensource.org/licenses/GPL-3.0
 * @link		https://www.opencart.com
*/

/**
* Pagination class
*/
class Pagination {
	public $total = 0;
	public $page = 1;
	public $limit = 20;
	public $num_links = 8;
	public $url = '';
	public $text_first = '|&lt;';
	public $text_last = '&gt;|';
	public $text_next = '&gt;';
	public $text_prev = '&lt;';

	/**
     * 
     *
     * @return	text
     */
	public function render() {
		$total = $this->total;

		if ($this->page < 1) {
			$page = 1;
		} else {
			$page = $this->page;
		}

		if (!(int)$this->limit) {
			$limit = 10;
		} else {
			$limit = $this->limit;
		}

		$num_links = $this->num_links;
		$num_pages = ceil($total / $limit);

		$this->url = str_replace('%7Bpage%7D', '{page}', $this->url);

		$output = '<ul class="pagination">';

		if ($page > 1) {
			$output .= '<li class="page-item"><a class="page-link" href="' . str_replace(array('&amp;page={page}', '?page={page}', '&page={page}'), '', $this->url) . '">' . $this->text_first . '</a></li>';
			
			if ($page - 1 === 1) {
				$output .= '<li class="page-item"><a class="page-link" href="' . str_replace(array('&amp;page={page}', '?page={page}', '&page={page}'), '', $this->url) . '">' . $this->text_prev . '</a></li>';
			} else {
				$output .= '<li class="page-item"><a class="page-link" href="' . str_replace('{page}', $page - 1, $this->url) . '">' . $this->text_prev . '</a></li>';
			}
		}

		if ($num_pages > 1) {
			if ($num_pages <= $num_links) {
				$start = 1;
				$end = $num_pages;
			} else {
				$start = $page - floor($num_links / 2);
				$end = $page + floor($num_links / 2);

				if ($start < 1) {
					$end += abs($start) + 1;
					$start = 1;
				}

				if ($end > $num_pages) {
					$start -= ($end - $num_pages);
					$end = $num_pages;
				}
			}

			for ($i = $start; $i <= $end; $i++) {
				if ($page == $i) {
					$output .= '<li class="page-item active"><a href="#" class="page-link">' . $i . '</a></li>';
				} else {
					if ($i === 1) {
						$output .= '<li class="page-item" ><a class="page-link" href="' . str_replace(array('&amp;page={page}', '?page={page}', '&page={page}'), '', $this->url) . '">' . $i . '</a></li>';
					} else {
						$output .= '<li class="page-item"><a class="page-link" href="' . str_replace('{page}', $i, $this->url) . '">' . $i . '</a></li>';
					}
				}
			}
		}

		if ($page < $num_pages) {
			$output .= '<li class="page-item"><a class="page-link" href="' . str_replace('{page}', $page + 1, $this->url) . '">' . $this->text_next . '</a></li>';
			$output .= '<li class="page-item"><a class="page-link" href="' . str_replace('{page}', $num_pages, $this->url) . '">' . $this->text_last . '</a></li>';
		}

		$output .= '</ul>';

		if ($num_pages > 1) {
			return $output;
		} else {
			return '';
		}
	}
}

IDE for reactjs

1. VS Code –

You can download VS code on Windows, Mac, Ubuntu, Debian, Red Hat, Fedora, and on SUSE, free of cost under the open-source of MIT license. It is popular among developers for providing all kinds of programming needs. React and VS code easily transformed into a compelling React IDE to enhance the productivity and speed of development using plugins.

vs-code

2. Atom –

Atom is another interesting and widely used ReactJS IDE. With 50K plus Github stars and more than 13k forks, this open-source IDE for ReactJS development brings varieties of features for an amazing development experience for users as well as for developers. It allows programmers to mangle each part of Atom according to their convenience even without tasting any configuration file.

atom

Windows, Mac, and Linux offer a wide range of applications and high-end support. Additionally, with auto-completion of syntax and inline indentation, mini-map features, it can be customized using Node.js based plugins to maximize functionality.

3. Reactide –

Reactide is the first ReactJS IDE which can be considered as a cross-platform for web application development. It just does not offer an integrated Node Server and custom simulator which eliminates the need for building unnecessary built-tool and server configurations, it renders the project in the browser instantly and provides hot module re-loading by default. This free tool can be downloaded from macOS, Windows and Debian.

reactide

4. Alloy Editor React –

This rich ReactJS IDE text editor gets used as a core component for several applications such as blogs, eCommerce administrator tools, and many more. It comprises smart toolbars that appear on the selected text depending on the different context functionality. It allows developers to add buttons or upload relevant images from clipboards or to drag from any other applications. Its amazing architecture enables programmers to paste rich text from web pages and preserve the formatting.

alloy-editor-react

5. Webstorm

This ReactJS IDE is a paid service but one of the most feature-rich IDE for ReactJS Development around the entire javascript ecosystem. Its ecosystem includes Cordova, React Native, Electron, NodeJS, and many more.

webstorm

JetBrains is a producer of Webstorm, and from the last 18 years, it has been proved as one of the best IDE for continuous product upgrades as well as customer support. Due to its regular product upgrades and support, most of the React.js Development Company relies on this.

6. Nuclide –

Developed by FaceBook, Nuclide works as a text editor for both React Native and ReactJS. However, now Facebook is no longer associated with this and does not offer any associated updates; still, it gets huge community support. Many developers have considered Nuclide as one of the best IDE reactJS technology due to its cross-platform support, autocomplete, inline indentation, build in debugging capabilities, and diagnosis capabilities.

nuclide

7. Sublime Text-3 –

It is another powerful integrated development programme which helps in various programming languages and frameworks. The sublime Text tool is a great option for those who do not want to scratch their head for anything else.

sublime-text-3

It has many plugins available to turn sublime into a feature-rich IDE for ReactJS Development. Plus, it can be used for enhancing development experience with ColorSublime, Babel, SublimeREPL, ColorPicker, React ES6 snippet, and many other technologies.

8. Rekit Studio –

Rekit is another ReactJS IDE, which basically focuses on developing apps using React. Along with IDE it also works as a toolkit that gets used for developing scalable applications utilizing React, react-router, and redux. A few basic features like refactoring, unit tests, code generation, support for Less and Sass, react-router, command-line tools etc. help in expanding its functionality.

rekit-studio

9. Brackets –

If you are looking for any lightweight, modern and powerful text editor which blends seamlessly with visual tools, Brackets is worth consideration for you. Brackets are produced from Adobe, and it is available under MIT license as free to use the tool. You can find a range of plugins available to enhance Brackets functionality using React components even without delving into the creative procedures. Brackets are specially crafted for web designers and front-end developers.

brackets

10. Deco IDE –

Many React.js development services found Deco IDE as the best IDE to react to native development. Earlier it was supported by macOS, but now it is not getting any regular updates from them. Originally it was a paid IDE reactJS, but since 2016 it is now free and open-source to use.

deco-ide

How to manage Journal logs in ubuntu

Yes you can delete everything inside of /var/log/journal/* but do not delete the directory itself. You can also query journalctl to find out how much disk space it’s consuming:

$ journalctl --disk-usage
Journals take up 3.8G on disk.

You can control the size of this directory using this parameter in your /etc/systemd/journald.conf:

SystemMaxUse=50M

You can force a log rotation:

$ sudo systemctl kill --kill-who=main --signal=SIGUSR2 systemd-journald.service

NOTE: You might need to restart the logging service to force a log rotation, if the above signaling method does not do it. You can restart the service like so:

$ sudo systemctl restart systemd-journald.service

abrt logs

These files too under /var/cache/abrt-di/* can be deleted as well. The size of the log files here is controlled under:

$ grep -i size /etc/abrt/abrt.conf 
# Max size for crash storage [MiB] or 0 for unlimited
MaxCrashReportsSize = 1000

You can control the max size of /var/cache/abrt-di by changing the following in file, /etc/abrt/plugins/CCpp.conf:

DebugInfoCacheMB = 2000

NOTE: If not defined DebugInfoCacheMB defaults to 4000 (4GB).

What is the journal?

what is journal in ubuntu

Many modern file systems employ a journal including NTFS, Ext3/4, XFS, HFS+, and others. The journal helps with two things, avoiding file system corruption and speeding up recovery after a failure such as a power loss or system crash. There are two major components to a file system, the data and the metadata. The data is the contents of a file, image, video, documents, and ultimately it is what gives the file system it’s value. The metadata is what describes the structure of the filesystem including how files are named, stored in directories, access permissions, file modification times, and recording areas of the disk that are in use or are free to be allocated to other files as they grow or are created. If the metadata becomes corrupted because of a system crash, it could lead to further data loss/corruption. For example, part of the disk might be selected for allocation to a file, but if it’s not recorded correctly before a crash, it might be added to the file’s list of data blocks, but still in the list of free data blocks and allocated to a second file later on. Now, there are two files that are sharing the same data blocks/content.

The journal is a place on the disk reserved for recording changes to the file system. The exact details of what is being changed it written first to the journal located in a single location on disk, then, after the journal is updated, the changes are applied to the appropriate locations on the disk which might require several writes. One the updates are done, the journal entry is marked as complete. After a crash, the system only need to examine the journal for incomplete entries and complete them to fix the file system. This speeds recovery and ensures a change is made entirely or not at all. If a block is allocated to a growing file, it will be added to the file’s block list and also marked as in use.

Also, on file systems that support journalling, most often it’s only metadata journalling to preserve the structure, but not the data itself. Full data journalling is normally quite expensive and slow, but less crucial than metadata. It’s possible to enable for data as well if needed.

Also, to complete this, there are some file systems that don’t currently offer journalling including FAT32, exFAT, Ext2, and UDF. If there’s a crash during an update, a full scan of the filesystem needs to be done to track down any errors or corruption.

what happened when we remove all files and folders in ubuntu from /var/log folder

Delete all of /var/log?

If you delete everything in /var/log, you will most likely end up with tons of error messages in very little time, since there are folders in there which are expected to exist (e.g. exim4, apache2, apt, cups, mysql, samba and more). Plus: there are some services or applications that will not create their log files, if they don’t exist. They expect at least an empty file to be present. So the direct answer to your question actually is “Do not do this!!!”.

How to clean log files in Linux

1.Check the disk space from the command line. Use the du command to see which files and directories consume the most space inside of the /var/log directory.

$ sudo du -h /var/log/

The du command prints the estimated disk space usage of each file and directory for the path that you specified.

The -h argument causes the command to print the information in a human-readable format.

The output of the du command  :

$ sudo du -h /var/log/

4.0K /var/log/landscape
196K /var/log/apt
80M /var/log/apache2
12K /var/log/dbconfig-common
4.1G /var/log/journal/ec2d37b34f2f9fd221dd8855017d9f76
4.1G /var/log/journal
du: cannot read directory ‘/var/log/amazon/ssm/audits’: Permission denied
4.0K /var/log/amazon/ssm/audits
208K /var/log/amazon/ssm
212K /var/log/amazon
4.0K /var/log/lxd
4.0K /var/log/dist-upgrade
36K /var/log/mysql
152K /var/log/unattended-upgrades
4.5G /var/log/

List Disk Usage of current directory

 $ du -h *

After finding that my /var/log/journal folder was taking several GB, I followed:

$ sudo journalctl --vacuum-time=10d

which cleared 90%+ of it

Remove all mail services from ubuntu

List of mail service used for php in ubuntu

  1. postfix
  2. sendmail
  3. mailutils

remove postfix ubuntu

$ sudo apt remove postfix
$ sudo apt purge postfix
$ sudo apt autoremove

remove sendmail service ubuntu

$ sudo apt-get remove sendmail
$ sudo apt-get purge sendmail
OR  To remove send mail completely you have to use:
$ sudo apt-get purge sendmail*

remove mailutils service ubuntu

$ sudo apt-get remove mailutils 
$ sudo apt-get remove --auto-remove mailutils 
$ sudo apt-get purge mailutils 
$ sudo apt-get purge --auto-remove mailutils