Linux Hint https://linuxhint.com Exploring and Master Linux Ecosystem Fri, 12 Mar 2021 15:08:05 +0000 en-US hourly 1 https://wordpress.org/?v=5.6.2 Install Zimbra Collaboration Suite (ZCS) on CentOS 8 https://linuxhint.com/install-zimbra-collaboration-suite-zcs-on-centos-8/ Fri, 12 Mar 2021 13:06:35 +0000 https://linuxhint.com/?p=94163

Zimbra Collaboration Suite is open-source software that includes the Zimbra LDAP server, MTA (Mail Transfer Agent), and Zimbra mailbox server. It also provides you with a web-based administration panel that can be used to manage the domain and accounts. Zimbra collaboration software can run on various OS platforms including Red Hat, Ubuntu, CentOS, etc. In an earlier post, we have explained the installation of Zimbra Collaboration in Ubuntu. In today’s post, we will be going to explain how to install Zimbra Collaboration Suite on CentOS 8 system.

Prerequisites

For installing and running the Zimbra Collaboration server, you should have:

  • CentOS 8 system
  • Root privileges
  • A & MX record for your Server
  • Disk space 30 GB (at least)
  • RAM 8 GB (at least)
  • CPU/Processor 2.0 GHz (at least)

We have setup the CentOS 8 system with following specifications:

  • Zimbra Collaboration Suite: 8.8.15 GA Release
  • Domain: test.org
  • Server Hostname: mail.test.org
  • IP: 192.168.72.130

Steps to Install Zimbra Collaboration Suite on CentOS

Step 1: Install Dependencies

First, you will have to install some dependencies in your CentOS system. To do so, open the Terminal and execute the following command :

$ sudo yum install -y libidn gmp nptl nmap sysstat libaio libstdc++

Step 2: Disable Unwanted Services

You will need to disable unwanted services so that they do not conflict with the installation of the Zimbra collaboration suite. Here, we are going to disable SELinux, firewall, and postfix.

In order to disable SELinux, first execute the following command in Terminal to check if it is in “Enforcing” mode.

$ getenforce

If the output shows “Enforcing”, then change the SELinux mode to “Permissive”. Execute the following command to do so:

$ sudo setenforce 0

Now again run the following command to verify if the mode has been changed to “Permissive”:

$ getenforce

In order to disable the firewall, execute the following commands:

$ sudo systemctl stop firewalld
$ sudo systemctl disable firewall

To disable Postfix, run the following commands:

$ sudo systemctl stop postfix
$ sudo systemctl disable postfix

Step 3: Configure hostname and hosts file

Open the /etc/hostname file using the following command:

$ sudo nano /etc/hostname

Then in the file, add the FQDN as follows:

mail.test.org

Make sure to replace the mail.test.org with your FQDN. Now save and close /etc/hostname file.

Now open the /etc/hosts file as follows:

$ sudo nano /etc/hosts

Add the below entry in the file:

192.168.72.130 mail.test.org mail

Now save and close /etc/hosts file.

Step 4: Verify A and MX Records

Now verify the DNS configurations for your mail server. You can do this by using the below command in Terminal:

$ dig -t MX test.org

We can see from the output below that the MX and A records for our mail server have been configured properly.

Step 5: Install Zimbra Collaboration Suite

Now in this step, we will download and install the Zimbra collaboration suite.

1. To download the Zimbra collaboration suite, execute the following command in Terminal:

$ wget https://files.zimbra.com/downloads/8.8.15_GA/zcs-8.8.15_GA_3953.RHEL8_64.20200629025823.tgz

2. The downloaded Zimbra file will be in the .tgz archive format. To extract the archive file, use the following command:

$ tar -zxvf zcs-8.8.15_GA_3953.RHEL8_64.20200629025823.tgz

3. One the file is extracted; navigate to the extracted directory using the following command:

$ cd zcs-8.8.15_GA_3953.RHEL8_64.20200629025823/

4. In the extracted directory, you will see an installer file. To start the installation of Zimbra CS, run the installer as follows:

$ sudo ./install.sh

After executing the above command, the installation of Zimbra will be started.

Install zimbra collaboration

5. After performing a few checks, the installer will ask you to accept the conditions of the software License Agreement. Press “y” to accept the agreement.

6. Now, press “y” when asked to use Zimbra’s package repository.

7. Now, select the packages you want to install by pressing y. Press y for all the packages with the exception of the zimbra-imapd which is only available in the beta edition. After selecting the packages, the system will check the required space for installation. If it verifies the required space, it starts installing the selected packages; otherwise, it stops the installation.

8. When the following prompt appears, press y.

Now it will start installing the selected packages.

9. After the installation of packages is completed, the installer will check to see if the MX record is configured in DNS. At this stage, if an error appears as you can see in the following screenshot, then you will be asked to re-enter the domain name. First, type yes and press Enter and then type your domain name and again press Enter.

10. Now, the following view will appear showing you the default configurations. Here, you will also see some unconfigured option which is Admin Password marked with asterisks (******) to its left. To configure the Admin Password, press 7 from the Main menu.

11. Then from the Store configuration submenu, press 4 and then press Enter. Then type a password for the admin user (should at least contain 6 characters) and press Enter.

12. Now press “r” to return to the Main menu.

13. Now to apply the changes you have made, press a and then press Enter.

14. When asked to save the configurations to a file, type yes to save it and then press Enter.

15. After that, it will ask where you want to save the configurations. To save the configurations to the default (/opt/zimbra/config.75773]) location, just press Enter. If you want to save it on some other location, type the directory path and press Enter.

16. Then it will notify you that the system will be modified. Type yes and press Enter.

17. When the Configuration complete message appears, press Enter.

Now the installation of the Zimbra collaboration suite has been completed.

Step 6: Access Zimbra Administration Panel

Now access the Zimbra Administration panel using any web browser and typing the following URL:

https://mail.test.org:70701

When you open the above URL for the first time in your web browser, you will see a warning message that the connection is untrusted. You can simply ignore this message and continue. After that, a page will appear for you to type the username and password. Enter admin as a username and password that you have configured earlier during the installation.

Once you are logged in, you will see the following similar dashboard where you can view the summary.

Uninstall Zimbra Collaboration Suite

In case, you no longer need Zimbra on your system, you can easily uninstall it. Open the Terminal and go to the directory which contains the Zimbra installation files.

$ cd zcs-8.8.15_GA_3953.RHEL8_64.20200629025823/

Then execute the installer file with the -u option as follows to uninstall Zimbra from your system.

$ ./install.sh -u

Hit y, when it asks if you want to completely remove the existing installation. After which it, will completely uninstall Zimbra from your system.

Now, use the cd command to go back to the main directory which contains both the Zimbra collaboration archive and extracted directory:

$ cd

Then execute the following commands to remove both the archive and extracted directory:

$ sudo rm zcs-8.8.15_GA_3953.RHEL8_64.20200629025823.tgz
$ sudo rm –rf zcs-8.8.15_GA_3953.RHEL8_64.20200629025823

By following the above step by step procedure, you can easily install the Zimbra collaboration server on the CentOS system. We have also shown you how to uninstall Zimbra, in case you no longer want it in your system.

]]>
6 Ways to Find Your Private IP Address in CentOS 8 https://linuxhint.com/6-ways-to-find-your-private-ip-address-in-centos-8/ Fri, 12 Mar 2021 13:01:45 +0000 https://linuxhint.com/?p=94154

Introduction

Private IP addresses are used to communicate inside a local network. Private IP addresses cannot be routed and hence no traffic can be sent to them from the external network. There may come a time when you need to know the private IP address of your system like to setup a network-related application, to enable remote administration, or for troubleshooting, etc. In our previous posts, we have shared with you some ways to find the private IP address in Ubuntu and Debian OS.

In this post, we will describe some methods to find the private IP address in CentOS8. These methods involve both the command line and GUI based methods.

Following are the IP address ranges that are defined by IANA:

10.0.0.0/8=10.0.0.0 – 10.255.255.255
192.168.0.0/16=192.168.0.0 – 192.168.255.255
172.16.0.0/12=172.16.0.0 – 172.31.255.255

6 Ways to find private IP address in CentOS 8

Method # 1: The “ip” command

The most common way to find an IP address in CentOS is by using the “ip” command. Simply type ip followed by the addr” or “a” option:

$ ip a

or

$ ip addr

This command will display all the network interfaces along with their associated private IP addresses. The following output shows our private IP is 192.168.72.130/24.

Method # 2: The “ifconfig” command

The “ifconfig” command is also used to find the private IP address. To use this command, just type ifconfig in the terminal:

$ ifconfig

If running the above command gives you a “command not found” error, then you will have to first install the net-tools as follows:

$ sudo yum -y install net-tools

Once installed, you can then use it to find the private IP address.

This command will display all the network interfaces along with their associated private IP addresses. The following output shows our private IP is 192.168.72.130/24.

Method # 3: The “hostname” command

The “hostname” command is usually used to find the hostname of the system. However, using the hostname command with the -l option provides you with IP address information.

$ hostname -I

Following is the output of above command which shows our private IP is 192.168.72.130.

Method # 4: The “nmcli” command

The “nmcli” is a command-line utility for controlling NetworkManager. It can also be used to find the private IP address of your system.

$ nmcli

Here is the output of the nmcli command which shows the private address on our system is 192.168.72.130/24.

Method 5: Using ip route command

The “ip route” command is used to configure and display static routes in Linux OS. This command also shows the private IP address of a system. Issue the following command in Terminal to find your private IP address:

$ ip route

Here is the output of the nmcli command which shows the private address on our system is 192.168.72.130/24.

Method 6: Using GUI

This method is for all those users who prefer working on GUI instead of the command line. In order to find the private IP address via GUI, click the network icon in the top right corner of your desktop. This step is also highlighted in the following screenshot.

Then a menu will show up on your desktop. Click the Wired Connected option.

Then select Wired Settings.

The Settings window will appear in the Network view. Click the cog icon in front of the network interface also shown highlighted in the following screenshot.

Now the following window will open in the Details tab. Here you will find your private IP address in the Details tab which in our case is 192.168.72.130.

In this post, we have described several ways through which you can find the private IP address in CentOS 8. If you know of some other ways that we have missed for finding the private IP address in CentOS, please share with us in the comments!

]]>
How to convert PDF to Google doc https://linuxhint.com/how-to-convert-pdf-to-google-doc/ Fri, 12 Mar 2021 12:54:36 +0000 https://linuxhint.com/?p=94148 Sometimes, we need to convert pdf files to Google docs in order to edit and share the files with other users. We can easily convert the pdf to Google doc using Google Drive. However, remember that converted documents may not always look perfect. It all depends on the formatting and layout applied to the file likes tables, list, header, footer, etc. The more formatting you have applied to your file, the less are the chances of proper conversion.

In this post, we will look at two methods for converting Pdf to Google Doc. Let’s get started.

Converting Pdf to Google Doc

Method 1:

In this method, we will first upload the pdf file to Google Drive, and then using Google drive we, will convert the file to Google Doc.

  1. Sign in to Google Drive account.
  2. Now upload the desired file to Goggle Drive. To do so, click the New button as highlighted by arrow in the below screenshot.

3. From the menu that shows up, click the File upload option.

4. Now a File Upload dialog will show up. Select the pdf file from your system and click Open in order to upload the file to your Google Drive.

5. At the bottom right of the window, you will see a progress bar displaying the progress of the upload process. After the pdf is uploaded, you will see the “upload complete” message as shown in the below screenshot.

6. Now you will see your pdf file listed in Google Drive. Right-click the file to convert it into Google Doc. By doing so a menu will appear, select Open with, and then select Google Docs.

7. The pdf file will be converted to the Google Doc format keeping the original text and formatting preserved. Now you can easily edit and format the converted document.

Method 2:

In this method, we will first convert the pdf file to the .docx format using Microsoft Word. Next, we will upload the word file in .docx format to Google Drive and then convert it into Google Doc.

Open Microsoft Word on your system. We are using Microsoft Word 2016.

Click the File tab in your Word document and then click Open. It will open a file explorer dialog for you to locate your desired pdf file. Once you have located the pdf file, click Open to load it into your Microsoft Word.

Now an information dialog will appear informing you that Word will transform the PDF to an editable word file. Click OK to close this dialog.

At the top of the document, you will see a message telling you that document is in protected mode. Click Enable Editing to edit the document.

To save this converted file as a .docx file, go to the File menu and click Save As. Then a Save As dialog will show up. Make sure Word Document (*.docx) is selected as Save as type. Name the Word file and select a location to save your document. Then click the Save button.

It will save the file with a .docx extension in your selected location.

Now open your Google Drive account. Click the New button as highlighted by the arrow in the below screenshot.

From the menu that shows up, click the File upload option.

Now a File Upload dialog will show up. Select the converted .docx file from your system and click Open to upload it to your Google Drive.

At the bottom right of the window, you will see a progress bar displaying the progress of the upload process. After the word document is uploaded, you will see the “upload complete” message as shown in the below screenshot.

Now you will see your .docx file listed in Google Drive. Right-click the file to convert it into Google Doc. By doing so a menu will appear, select Open With, and then select Google Docs.

The .docx file will now open in the Google Doc. Now you can easily edit and format the converted document.

That is all there is to it! Using either of the two methods discussed above, you can easily convert a pdf to Google Doc. Hope it helps!

]]>
How to Change the Background in Zoom https://linuxhint.com/how-to-change-the-background-in-zoom/ Fri, 12 Mar 2021 12:52:48 +0000 https://linuxhint.com/?p=94140

Introduction:

Zoom is a very popular video chat application. It became all the more useful and famous within these days of the COVID-19 pandemic in which every communication was virtualized since physical interactions were strictly forbidden. This application comes with some of the most amazing features, which is the sole reason for its popularity among the general public. By looking at the title of this article, you might think that the interface of this application is already quite appealing. Then what is even the need of changing its background?

So first let us try to clear out this misconception that what does changing the background in Zoom actually means. We know that whenever we are on a video call with someone, our actual background is displayed on the screen and also shared with the other communicating parties. However, we also realize that when an actual video is being transmitted over the network, it consumes a lot of bandwidth. It happens because of the frames that change every second. Therefore, there should be some way of optimizing bandwidth usage.

How about if during a video call, only your own self is being displayed whereas your background remains still? Well, you can achieve this goal by changing the background in Zoom. Doing this will essentially set a static virtual background that will be used during the video calls and hence your bandwidth will definitely be conserved. Therefore, today we will be talking about the method of changing the background in Zoom in Ubuntu 20.04. However, by following the very same procedure, you can even achieve this goal on any other Linux distribution as well.

Prerequisites:

You need to have the Zoom application installed on your Ubuntu 20.04 system. However, if you do not have it, then you can easily install it by following our tutorial on Zoom Installation on Ubuntu 20.04.

Method of Changing the Background in Zoom in Ubuntu 20.04:

For changing the background in Zoom in Ubuntu 20.04, we need to perform all the steps that are listed below:

Step # 1: Look for the Zoom Application in Ubuntu 20.04:

If the Zoom application is installed on your Ubuntu 20.04 system, then you can access it simply by searching for it in the Activities menu. The Zoom search result is highlighted in the following image. You need to click on the highlighted icon to launch the Zoom application in Ubuntu 20.04.

How to Change the Background in Zoom

Step # 2: Sign in to your Zoom Account:

Now you need to sign in to your Zoom account so that you can easily change its background. For that, you need to click on the Sign In option located on the landing page of the Zoom application.

How to Change the Background in Zoom

After clicking on this option, you will be required to provide your login credentials and then click on the Sign In button as highlighted in the image shown below:

How to Change the Background in Zoom

Step # 3: Access the Settings of the Zoom Application:

Once you have gained access to your Zoom account, you need to click on the Settings icon to access its settings as highlighted in the following image:

How to Change the Background in Zoom

Step # 4: Head on to the Background and Filters Settings:

In the Zoom Settings window, you need to click on the Background and Filters tab to change the background of the Zoom application.

How to Change the Background in Zoom

Step # 5: Download the Desired Background:

In the Background and Filters settings tab, you will be able to see your current live video in a small panel. You basically want to change the background of your live video. So, for doing that, you have to select a background listed under the Virtual Backgrounds section by clicking on it as highlighted in the image shown below:

As soon as you will select a desired virtual background, a dialogue box will pop up on your screen from which you will have to click on the Download button to start downloading the selected background.

The download progress bar of our selected background is shown in the following image:

Step # 6: Verify if the Background in Zoom has been Changed or not:

For verifying if the background in Zoom has been changed or not, you simply have to wait till the download of your selected background completes. Once it does, you will be able to see the selected background in your live video panel instead of your actual background as shown in the image below:

Conclusion:

By following the procedure described in this article, one can easily change the background of the Zoom application whenever he wants. In this way, you can ensure efficient bandwidth utilization.

]]>
How to Install Netdata Monitoring Tool on Ubuntu 20.04 https://linuxhint.com/how-to-install-netdata-monitoring-tool-on-ubuntu-20-04/ Fri, 12 Mar 2021 12:45:58 +0000 https://linuxhint.com/?p=94136 Getting real-time statistics on various system metrics is a top priority for system administrators, developers, and operation teams in general. It helps in monitoring systems in realtime and quickly picking up faults or errors and resolving them to ensure things get back on track.

Netdata is a free and open-source distributed, real-time monitoring application that runs across various computing devices; physical servers, cloud servers, containers, and even IoT devices. It collects a great deal of data and visualizes it on sleek and interactive dashboards. We are going to install Netdata on Ubuntu 20.04 LTS and then demonstrate just how various metrics are visualized.

Step 1: Install Netdata using kickstart.sh script

This is the most preferred way of installing Netdata because it allows you to pass other arguments on the same command to customize the installation process. Most importantly, this method seamlessly works across all distros.

At the start you might want to view more information about Netdata. Use the APT command as follows.

$ apt show netdata

The output provides Netdata information such as the latest version, origin, installation size, and a description of the package.

To install Netdata, simply run the kickstart script as follows.

$ bash <(curl -Ss https://my-netdata.io/kickstart.sh)

As you will notice, the script performs a bunch of operations. First, it autodetects the Linux Operating system and distribution you are running and later install the requisite packages.

From the output below, you can see that our OS information has been retrieved and displayed to stdout by the script.

The script then proceeds to check if you have an existing instance of Netdata, and if there is one, the script updates Netdata instead of installing Netdata afresh.

Thereafter, the script pulls Netdata from the Git repository and stores it in /usr/src/netdata.git. Path. All the required files and dependencies are thereafter installed and the package index updated.

Along the way, the location of Netdata files including configuration files, web files, db files and log files will be displayed as shown.

Towards the end, basic instructions on how to access Netdata dashboard along with starting and stopping Netdata will be displayed.

The updater script netdata-updater.sh is then added to /etc/cron-daily f to ensure that Netdata is continually updated.

As the installation wraps up , the script will inform you that Netdata was successfully installed and is now running.

The entire installation takes quite a while you might want to take a short break or simply hang around until it is completed.

Step 2: Confirm Netdata is running

Netdata is finally installed. However, it’s prudent to verify that indeed Netdata service is active and running.

By default, Netdata listens on port 19999. To confirm this, run the netstat command below:

$ sudo netstat -pnltu | grep 19999

Also, you can confirm that Netstat systemd service is running by invoking:

$ sudo systemctl status netdata

The output confirms that indeed, Netdata is running as we would expect.

Step 3: Configure firewall

At this point, you can access Netdata from the browser from your host system. However, if UFW firewall is enabled, this will not be possible. With that in mind, port 19999 needs to be allowed.

So run the following commands:

$ sudo ufw allow 19999/tcp
$ sudo ufw reload

Then confirm that port 19999 is allowed on the firewall.

$ sudo ufw status

Step 4: Access Netdata dashboard

All the configurations are done and dusted. As we wrap up, we are going to access Netdata by browsing the following URL. Replace the host-ip with your host’s real IP address.

http://host-ip:19999

And voila! Netdata dashboard will come into view with elegant and beautiful visualizations displaying a System overview of the main system metrics such as CPU utilization, network bandwidth stats, disk read/write and RAM utilization.

On the right sidebar are additional system metric options that you can click on to view dashboards that visualize real-time statistics.

For instance, to have a glance at the network bandwidth, select the ‘Network Interfaces’ icon as shown.

The ‘Network Interfaces’ dashboard will be displayed with bandwidth statistics on various network adapters.

Conclusion

Netdata provides an excellent solution for monitoring your single node in real-time. You can configure alarms and notifications which can be triggered when a certain event or threshold is exceeded. Give Netdata a try and let us know about your experience.

]]>
Zoom Video Filters not Available https://linuxhint.com/zoom-video-filters-not-available/ Fri, 12 Mar 2021 12:42:28 +0000 https://linuxhint.com/?p=94133 As more and more users are moving towards video communication services like Zoom, they are also encountering some issues. This post is about one of the issues regarding Zoom video filters. Many Linux users are encountering this issue that they are not able to access Zoom video filters.

Problem: Zoom video filters not available

Video filters not available in Zoom for Linux. To confirm this issue, we have installed the latest version of Zoom on three Linux distributions: Ubuntu 20.04, Mint 20, and CentOS 8. On all three distributions, there was no Background and Filters tab available. Instead, there was a tab named Virtual Background which allows you to change your Zoom background.

Here are the screenshots for the Zoom interface for all the three different Linux distributions:

Zoom application in Ubuntu 20.04

This is the Zoom interface on Ubuntu 20.04 OS where there is no option available for the video filters.

Zoom application in Mint 20

This is the Zoom interface on Mint 20 OS where there is no option available for the video filters.

Zoom application in CentOS 8

This is the Zoom interface on CentOS 8 OS where there is no option available for the video filters.

Workaround

Although, there is no proper solution available for this limitation. However, if you really need a video filter for your Zoom meetings, you can try it out in Windows OS or MacOS. Although, we have not tried Zoom in MacOS, but for Windows, video filters are available and work well.

How to use Zoom Video filters in Windows/MacOS

For using Zoom video filters, you must have:

  • Zoom desktop client version 5.2.0 (42619.0804) or higher
  • For Windows, 64-bit OS,
  • For MacOS, macOS 10.13 or higher

1. Access the Zoom web portal and make sure the video filters option is enabled. To do so, point your browser at:

https://zoom.us/profile/setting

Now sign in to your Zoom account.

2. Under In Meeting (Advanced) tab, go to the Video filters option. Make sure the slider is in On position as shown in the following screenshot.

3. Now, open the Zoom desktop application in your Windows system and click the cog icon (settings icon).

4. On the left panel in the Zoom application, select Background & Filters tab. Then on the right panel, select the Video Filters tab. From here, you can choose your desired filter.

So this was the temporary workaround for Linux users who are facing issues regarding missing Video filters in Zoom. Hope this helps!

]]>
How to create and run a Perl script in Debian 10 https://linuxhint.com/how-to-create-and-run-a-perl-script-in-debian-10/ Fri, 12 Mar 2021 12:37:04 +0000 https://linuxhint.com/?p=94129

Introduction:

Perl scripts are yet another powerful method of executing complex programs with a very minimal effort. The people who have a good know-how of programming in C and C++ get along with Perl very nicely because of its close resemblance to these languages. In this article, we will teach you the method of creating your first Perl script and running it in Debian 10.

Method of Creating a Perl Script in Debian 10:

For creating a simple Perl script in Debian 10, there are three main steps that you need to follow:

Step # 1: Checking the Perl Version:

You should assure that you have Perl installed on your Debian 10 system. You can do this simply by checking the version of Perl by executing the following command in your terminal:

perl --version

If Perl has already been installed on your system, then running the above-mentioned command will render the version of Perl installed on your Debian 10 system as shown in the image below:

Step # 2: Ensuring the Presence of Perl Interpreter:

Since every scripting language requires an interpreter which can help in the execution of the programs created in that language, therefore, you also need to ensure that the Perl interpreter has been installed on your system or not. You can check this out by running the following command in your terminal:

which perl

Running this command will show you the path to the binary of Perl as shown in the image below:

However, if you also want to check the path of the source file and the man pages of Perl along with the binary file for an added assurance, then you can run the following command in your terminal:

whereis perl

The output of the “whereis” command is shown in the image below:

Step # 3: Creating a Perl Script in Debian 10:

Once you have ensured the presence of Perl and its respective interpreter on your Debian 10 system, there comes the turn of creating a Perl script. A Perl script can conveniently be created by executing the following command in your terminal:

sudo nano MyFirstPerlScript.pl

Any other text editor can also be used to serve the same purpose instead of the nano editor, however, we have used this editor solely because it is the default text editor of the Linux systems. Moreover, you can have any name for your Perl script that must be followed by a .pl extension.

When you will run this command, an empty Perl script file will open with the nano editor. You just have to type the following script in your file. The first line of this script is “#!/bin/perl” which is there to explicitly state that the following script is a Perl script. Then we have simply printed a dummy message by making use of the “print” command. After typing in this Perl script in your file, you should save it and exit from the editor by pressing Ctrl+ X.

Methods of Running a Perl Script in Debian 10:

You can run a Perl script by using either of the two methods listed below:

Method # 1: Using the “chmod” Command to Set Execute Permissions:

For this method, you first have to set the execute permissions for your Perl script after which you can finally run it. The details of both these steps are listed below:

Step # 1: Setting the Execute Permissions:

You have to make the Perl script that you have just created, executable by running the following command in your terminal:

sudo chmod +x MyFirstPearlScript.pl

Step # 2: Running the Perl Script:

After making your Perl script executable, you can run it by executing the following command in your terminal:

./MyFirstPerlScript.pl

Running this script will show you its output on the terminal as shown in the image below:

Method # 2: Using the “perl” Command:

This method is an easier workaround for running a Perl script in Debian 10. It is so because it does not require you to set up any execute permissions rather you can simply run your Perl script straightaway.

You can run your Perl script by executing the following command in your terminal:

perl MyFirstPerlScript.pl

Running this script will show you its output on the terminal as shown in the image below:

Conclusion:

By following the procedures of creating and running a Perl script described in this article, you can make your life a lot easier by automating your commonly occurring tasks with the help of Perl scripting. This article just teaches you the basic method of creating and running a simple Perl script. Once you manage to learn this, you can use Perl scripting for lots of other programmatically complex problems.

]]>
How to Automatically Empty the Trash in Ubuntu 20.04 https://linuxhint.com/how-to-automatically-empty-the-trash-in-ubuntu-20-04/ Fri, 12 Mar 2021 12:30:33 +0000 https://linuxhint.com/?p=94123 When you delete a file in Linux, it is not immediately deleted from the system. Instead, it is moved to the Trash in case you need to restore it. Trash is the first place where you look for the accidentally deleted files. Because the file is not removed from the system, it continues to take space on the system and in the end, can fill up large storage space. Although we can empty the trash manually to avoid wasting system space, however, we often forgot to do such a simple task. Luckily, Linux OS offers a utility known as “Autotrash” that can automatically delete the data in the Trash based on the options you specify.

In this post, we will explain how to install the Autotrash utility to automatically empty the trash in Ubuntu. This way you can get rid of old and useless files and make room for important files.

Note: The commands discussed here have been tested on Ubuntu 20.04 LTS (Focal Fossa). You must have be root user or have sudo privileges to install Autotrash on your Linux system.

Installing Autotrash

Autotrash utility is by default not installed in the Ubuntu OS. However, it is available as a snap package that can be easily installed using the snapd.

Step 1: Install Snapd

First, install snapd on your system. Execute the below command to do so:

$ sudo apt install snapd

Enter sudo password, after that the installation of snapd will be started on your system. Once snapd is installed, you can use it to install Autotrash snap.

Step 2: Install Autotrash

Execute the below command in Terminal to install Autotrash utility on your system:

$ sudo snap install autotrash-unofficial

Once the Autotrash is installed you will see the below output:

installing autotrash

Step 3: Create an alias for Autotrash

After installation of Autotrash via snap, you will have to run every command by typing the complete snap name that is autotrash-unofficial. You can just use autotrash instead of complete snap name autotrash-unofficial by creating an alias as follows:

$ sudo snap alias autotrash-unofficial autotrash

The alias will support calling the autotrash-unofficial as just autotrash.

Note: In case, you want to remove the alias, execute the below command:

$ sudo snap unalias autotrash

To verify if the Autotrash has been successfully installed and to view its version, execute the below command in Terminal:

$ autotrash -V

autotrash version

Using Autotrash to Automatically Empty the Trash in Ubuntu

Autotrash allows you to automatically empty the trash based on certain options that you need to specify. It can automatically delete files based on age, size, and free space on the trash location.

Automatically Deleting Files older than x number of days

This is the most commonly used Autotrash functionality. The following command syntax can be used to automatically delete the files that exist in the trash for more than x number of days:

$ autotrash -d [number of days]

This will automatically delete the files that have been in the trash over the period you specified. For instance, the below command will delete the files that have been in the trash for more than 45 days:

$ autotrash -d 45

If you want to restore any deleted file, you can do that within 45 days.

Automatically Deleting files based on free-space left

Using the Autotrash utility, you can make sure a specific amount of disk space is free in the Trash location. Here is the syntax of the command:

$ autotrash --min-free [free-space in MB]

For instance, the below command will make sure there is a minimum of 512 MB of free space:

$ autotrash --min-free 512

Automatically Deleting M number of megabytes

Using Autotrash –delete option, you can allow it to automatically delete at least M megabytes, removing the oldest trashed items first. Here is the syntax of the command:

$ autotrash --delete [data size in megabytes]

This option removes the trashed entries, not the individual files. To explain it, consider you have an older trashed directory of 1 GB. If you request Autotrash to delete 512 MB (M=512), it will remove 1 GB.

$ autotrash --delete 512

Uninstalling Autotrash

In case you no longer need Autotrash on your system, you can easily remove it using the following command in Terminal:

$ sudo snap remove autotrash-unofficial

Enter password for sudo, after which Autotrash will be removed from your system.

In this post, we have explained how to install Autotrash on Ubuntu system. Now the Autotrash will automatically delete the files residing in the Trash based on the conditions you specified.

]]>
How to Install and Use Veracrypt on Ubuntu 20.04 https://linuxhint.com/how-to-install-and-use-veracrypt-on-ubuntu-20-04/ Fri, 12 Mar 2021 12:23:27 +0000 https://linuxhint.com/?p=94115

If you do not want others to have access to your data, then encryption is essential. When you encrypt your sensitive data, unauthorized persons cannot easily get to it. This how-to guide focuses on the installation and basic usage of Veracrypt disk encryption software on Ubuntu Linux. Veracrypt is an open-source software and it is free.

Install Veracrypt

As seen on the official downloads page (link: https://www.veracrypt.fr/en/Downloads.html), two options are available for using Veracrypt on Ubuntu Linux, namely: GUI and console. GUI means graphical-based and console means text-based(command-line.)

Install Veracrypt: GUI

Run the following command in the Ubuntu terminal to download the Veracrypt GUI installer package.

$ sudo wget https://launchpad.net/veracrypt/trunk/1.24-update7/+download/veracrypt-1.24-Update7-Ubuntu-20.04-amd64.deb

Now, you may install the downloaded package as follows.

$ sudo apt-get install ./veracrypt-1.24-Update7-Ubuntu-20.04-amd64.deb

Enter y to continue with the installation if prompted. After a successful installation, you can launch Veracrypt from the Applications menu > Accessories > Veracrypt.

Install Veracrypt: Console

Run the following command in the Ubuntu terminal to download the Veracrypt console installer package.

$ sudo wget https://launchpad.net/veracrypt/trunk/1.24-update7/+download/veracrypt-console-1.24-Update7-Ubuntu-20.04-amd64.deb

You may now proceed to install the downloaded package. Run the command below.

$ dpkg -i ./veracrypt-console-1.24-Update7-Ubuntu-20.04-amd64.deb

When the installation completes successfully, you may begin to use Veracrypt in the Ubuntu terminal. To see usage info, run the following command.

$ veracrypt -h

Encrypt Your Sensitive Data

Let us imagine that you have a folder named folder1 on your Ubuntu desktop which contains sensitive documents. We are going to create an encrypted volume via the GUI and the console to serve as a personal vault for storing such sensitive documents.

GUI Method:

Create an encrypted volume

1. Launch Veracrypt from the Applications menu > Accessories > Veracrypt 2.  Click Create 3.  In the Veracrypt volume creation wizard, choose Create an encrypted file container 4.  Click Next Figure 1: Create an encrypted file container 5.  On the Volume Type page, choose the first option labeled Standard Veracrypt volume 6.  Click Next 7.  Under Volume Location, click Select File 8.  Choose your desired location on the left and then enter a name for the encrypted file container at the top

Figure 2: Name your new encrypted file container 9.  Click Save at the bottom of the window 10.  Back to the Volume Location page, click Next 11.  Under Encryption Options, leave the default selections: AES and SHA-512, and click Next 12.  Under Volume Size, enter the desired volume size. Click the drop-down menu to switch between Gigabytes, Megabytes and Kilobytes

Figure 3: Specify the size of the encrypted file container 13.  Click Next 14.  Under Volume Password, enter an encryption password 15.  Click Next 16.  Under Format Options, you may choose Linux Ext3 from the drop-down menu

Figure 4: Choose filesystem type for the encrypted volume 17.  Click Next 18.  Under Cross-Platform Support, let us go with the default selection 19.  Click Next and then click OK when prompted 20.  Under Volume Format, begin to move your mouse randomly for at least 1 minute

Figure 5: Move your mouse randomly 21.  When you are done, click Format 22.  When prompted, enter your Linux user password and click OK 23.  Wait for a message indicating that your Veracrypt volume was successfully created 24.  Click OK 25.  Click Exit

Mount the encrypted volume

1.  Back to the main VeraCrypt window, click any free slot in the list 2.  Click Select File 3.  Choose the encrypted file container which you created earlier 4.  Click Open at the bottom of the Window 5.  Click Mount Figure 6: Mount encrypted volume 6.  When prompted, enter your encryption password and click OK 7.  You should now see a new device icon on your desktop The mounted device will also be listed under Devices when you open File Manager by accessing your home directory for instance. Figure 7 below shows the default mount directory path.

Figure 7: Encrypted volume mount directory path You may now proceed to move your sensitive folder into your personal vault.

Figure 8: Mounted volume listed under devices

Dismount the encrypted volume

1.  To dismount the encrypted volume, make sure that the appropriate slot is selected in the main Veracrypt window 2.  Click Dismount 3.  The slot entry should now be blank 4.  Also, you should no longer see the encrypted volume on your desktop or listed under Devices

Figure 9: Dismount encrypted volume

Console Method:

Create an encrypted volume

Run the command below in the Ubuntu terminal to begin creating your encrypted volume.

$ veracrypt --create

When prompted to choose a volume type, enter 1 for a Normal volume

Volume type: 1) Normal 2) Hidden Select [1]: 1

Next, you would be prompted to enter volume path and volume size. In the example below, the encrypted volume is called personal_vault and will be created in my home directory. The size of the personal vault will be 2 Gigabytes.

Enter volume path: /home/shola/personal_vault Enter volume size (sizeK/size[M]/sizeG): 2G

For encryption algorithm and hash algorithm, the default AES and SHA-512 values are recommended. Enter 1 in both cases.

Encryption Algorithm: 1) AES 2) Serpent 3) Twofish 4) Camellia 5) Kuznyechik 6) AES(Twofish) 7) AES(Twofish(Serpent)) 8) Camellia(Kuznyechik) 9) Camellia(Serpent) 10) Kuznyechik(AES) 11) Kuznyechik(Serpent(Camellia)) 12) Kuznyechik(Twofish) 13) Serpent(AES) 14) Serpent(Twofish(AES)) 15) Twofish(Serpent) Select [1]: 1 Hash algorithm: 1) SHA-512 2) Whirlpool 3) SHA-256 4) Streebog Select [1]: 1

For filesystem, Linux Ext3 would suffice. You may enter 4 to choose that.

Filesystem: 1) None 2) FAT 3) Linux Ext2 4) Linux Ext3 5) Linux Ext4 6) NTFS 7) exFAT 8) Btrfs Select [2]: 4

Now, it is time to choose a strong encryption password. You will get a warning if your chosen password is determined to be weak. Note: Using a short password is NOT recommended.

Enter password: WARNING: Short passwords are easy to crack using brute force techniques! We recommend choosing a password consisting of 20 or more characters. Are you sure you want to use a short password? (y=Yes/n=No) [No]: y Re-enter password:

When you are prompted to enter PIM, press the enter key on your keyboard to accept the default value. Do the same when you are prompted to enter the keyfile path. PIM is a number that specifies how many times your password is hashed. A keyfile is used alongside a password, such that any volume that uses the keyfile cannot be mounted if the correct keyfile is not provided. As we are focusing on basic usage here, the default values would suffice.

Enter PIM: Enter keyfile path [none]:

Finally, you would need to randomly type on the keyboard for at least 1 minute and quite fast too. This is supposed to make the encryption stronger. Avoid the enter key while you type. Press Enter only when you are done typing and then wait for the encrypted volume to be created.

Please type at least 320 randomly chosen characters and then press Enter: Done: 100% Speed: 33 MiB/s Left: 0 s The VeraCrypt volume has been successfully created.

Mount the encrypted volume

To access the content of the encrypted volume, you need to first mount it. The default mount directory is /media/veracrypt1 but you can create yours if you wish. For example, the following command will create a mount directory under /mnt.

$ sudo mkdir /mnt/personal_vault

The next command below will begin mounting the encrypted volume.

$ veracrypt --mount /home/shola/personal_vault

When you are prompted, either press the enter key to use the default mount directory or type your own mount directory path. You would be prompted to enter your encryption password next. For PIM, keyfile and protect hidden volume prompts, hit the enter key to use the default values.

Enter mount directory [default]: /mnt/personal_vault Enter password for /home/shola/personal_vault: Enter PIM for /home/shola/personal_vault: Enter keyfile [none]: Protect hidden volume (if any)? (y=Yes/n=No) [No]:

Run the following command to list mounted volumes.

$ veracrypt --list
1: /home/shola/personal_vault /dev/mapper/veracrypt1 /mnt/personal_vault

You may now move your sensitive folder to your personal vault as follows.

$ sudo mv /home/shola/folder1 /mnt/personal_vault

To list the contents of your personal vault, run:

$ ls -l /mnt/personal_vault

Dismount the encrypted volume

The following command will dismount the encrypted volume.

$ veracrypt --dismount /mnt/personal_vault

If you run veracrypt –list again, you should get a message indicating that no volume is mounted.

Conclusion

Veracrypt has some very advanced capabilities but we only covered the basics in this article. Feel free to share your experiences with us in the comments section.

]]>
Monitor Network Traffic with vnStat on Ubuntu 20.04 https://linuxhint.com/monitor-network-traffic-with-vnstat-on-ubuntu-20-04/ Fri, 12 Mar 2021 12:20:08 +0000 https://linuxhint.com/?p=94110 vnStat is an open-source and lightweight network traffic monitor for Linux operating systems. vnStat quietly monitors the network traffic for specific interfaces and stores the monitoring data in a database. With vnStat, you can view the bandwidth usage per hour, day, month, or for a particular period.

In this guide, we will be looking at how to install vnStat and monitor network traffic on Ubuntu OS.

Note: The procedure described here has been tested on Ubuntu 20.04 LTS. The commands have been executed on Terminal which you can open through the Ctrl+Alt+T shortcut.

Installing vnStat

VnStat is available in the default Ubuntu repositories but it is not the latest version. To install vnStat latest version, follow the below-mentioned steps:

Step 1: Update repository index

First, execute the below command to update the system repository index:

$ sudo apt update

Enter the password for sudo.

Step 2: Install prerequisites

Next, you will have to install some prerequisites that can build software from source. We will need it for the compilation of vnStat. Execute this command to install the prerequisites:

$ sudo apt install build-essential gcc make libsqlite3-dev -y

Step 3: Download vnStat tar.gz package

Now from the vnStat official website, download the latest version of vnStat tar.gz package. Currently, the latest version of vnStat is 2.6, so we can download it as follows:

$ wget https://humdi.net/vnstat/vnstat-2.6.tar.gz

Step 4: Install vnStat

Once the tar.gz package is downloaded, we can install it as follows:

First, extract the tar.gz using the below command in Terminal:

$ tar -xvzf vnstat-2.6.tar.gz

Then switch to the resulting extracted directory using the below command:

$ cd vnstat-2.6

Now configure it using the command below:

$ ./configure --prefix=/usr --sysconfdir=/etc

Then, install vnStat as follows:

$ sudo make
$ sudo make install

Step 5: Verify Installation

To verify if vnStat has been successfully installed, execute the below command in Terminal:

$ vnstat -v

The following output confirms vnStat version 2.6 has been installed.

Step 6: Enable and start vnStat service

To enable and start vnStat service, first you will need to copy vnStat service file from the vnStat extracted directory to the /etc/systemd/system/ using the below command:

$ sudo cp -v vnstat-2.6/examples/systemd/vnstat.service /etc/systemd/system/

Now enable vnStat service using the below command:

$ sudo systemctl enable vnstat

Then to start vnStat service, execute the below command

$ sudo systemctl start vnstat

To verify if vnStat service is running, execute the below command:

$ sudo systemctl status vnstat

The following output confirms vnStat service is running properly without any issues.

Monitor Network Traffic with vnStat

vnStat supports various options that help you to monitor traffic in different ways. You can view some of the available options by executing the below command in Terminal:

$ vnstat --help

Or execute the following command to view the complete list of options:

$ vnstat --longhelp

vnstat help

You can also visit vnStat man page for the complete list of options.

Running the vnStat command without any option prints the bandwidth usage statistics for all the available interfaces.

$ vnstat

Here is the output of vnStat command on our system which is showing statistics of one interface as this is the only available interface on our system.

vnstat command output

You can also monitor a specific interface by using the -i option followed by the interface name.

$ vnstat -i <interface_name>

For instance, to monitor an interface ens33, the command would be:

$ vnstat -i ens33

You can also monitor bandwidth usage as per hourly, daily, monthly, and yearly usage using the -h, -d, -m, and -y options respectively. For example, to find the daily bandwidth usage, the command would be:

$ vnstat -d

vnstat daily statistics

You can also get the bandwidth usage for the top traffic days. For instance, to find the top 10 bandwidth usage days, use -t option followed by the number of days:

$ vnstat -t 10

To monitor bandwidth usage in real-time, use the -l option as follows:

$ vnstat -l

If you want to remove all the statistics for a specific interface from the database and stop monitoring it, use the below command syntax:

$ sudo vnstat --remove -i <interface_name> --force

For instance, to remove the interface ens33 from the database and stop monitoring it, the command would be:

$ sudo vnstat --remove -i ens33 --force

To add this interface again for monitoring, use the below command:

$ sudo vnstat --add -i ens33

After adding the interface, restart vnStat service:

$ sudo systemctl restart vnstat

vnStat is a handy tool to keep an eye on the bandwidth usage on your Linux OS. In this guide, you have learned how to install and use this tool on Ubuntu 20.04 LTS for monitoring the traffic on network interfaces.

]]>
How to digitally sign a PDF document https://linuxhint.com/how-to-digitally-sign-a-pdf-document/ Fri, 12 Mar 2021 12:11:38 +0000 https://linuxhint.com/?p=94107

Introduction:

Signing a document is considered extremely important especially in case of a legal agreement between two or more parties. All of us are familiar with the regular hand-drawn signatures that we do on paper, however, since these days we are supposed to deal with electronic documents very frequently such as PDFs, therefore, it becomes a necessity to figure out a way of digitally signing a document. In this article, we will discuss with you the method of digitally signing a PDF.

Method of Digitally Signing a PDF:

For digitally signing a PDF document, you need to perform the following steps after opening the PDF file that you want to sign:

Click on the signature icon located on the taskbar as highlighted in the image shown below:

Clicking on this icon will cause two options to display on your screen. You need to choose the “Add Signature” option from these options as shown in the following image:

After doing this, a dialogue box will appear on your screen in which you will have the following three tabs: Type, Draw, and Image. The “Type” tab allows you to type in your signature in the form of alphabets and your PDF reader will automatically transform it into a visually appealing signature. The “Draw” tab provides you with a pen with which you can manually draw your signature in the same manner as you do on the paper. The “Image” option enables you to select an image from your computer system and upload it to your PDF document as your digital signature. This dialogue box is presented to you in the image shown below:

Now we will walk you through all the three tabs of this dialogue box one by one. First, we will select the “Type” tab and will type some alphabets as our signature as shown in the following image. You can also change the default style of the signature by choosing one from the Change Style dropdown list. Once you are satisfied with the generated style of the signature, you can simply click on the Apply button.

When you will click on the “Apply” button, you will be able to place your newly generated signature anywhere on your document as shown in the image below:

If you wish to draw your signature manually, then you will need to switch to the “Draw” tab as highlighted in the following image. After switching on to this tab, you will be presented with a pen with which you can do a free form drawing. You can draw any signature of your choice after which you need to click on the “Apply” button.

Once you will click on the “Apply” button, you will be able to place your newly drawn signature anywhere on your document as shown in the image below:

Lastly, if you wish to choose an image as your digital signature, then you need to switch to the “Image” tab. As soon as you will switch to the “Image” tab, you will be allowed to choose any desired image from your computer system. After selecting an image as your digital signature, click on the “Open” button as highlighted in the following image:

Now you need to click on the “Apply” button as highlighted in the image shown below:

When you will click on the “Apply” button, you will be able to place your signature image anywhere on your document as shown in the following image:

Conclusion:

In this article, we shared with you the complete method of digitally signing a PDF. This method can prove to be really effective if you intend to make online agreements with your clients or employers as you can conveniently show your interest in something by signing it digitally.

]]>
How to create and run a Perl script in Ubuntu 20.04 LTS https://linuxhint.com/how-to-create-and-run-a-perl-script-in-ubuntu-20-04-lts/ Fri, 12 Mar 2021 12:07:09 +0000 https://linuxhint.com/?p=94103 Perl is abbreviated for Practical Extraction and Reporting Language that is a well-known and powerful language for String Processing and handling. It is a web scripting language that can be used along with different web frameworks and the latest technologies. Mostly the Perl used for server-side scripting but, it can also be used to front-end interface programming languages like HTML with the backend in the Database application. It is fast and robust so, it can interact with many other programming languages on different platforms.In this article, we will talk about the best steps to install Perl language and how we can create and run the Perl script through the command line on Ubuntu 20.04.

Prerequisites

You should have sudo access to run administrative commands on your system.

Installation of Perl on Ubuntu 20.04

We have implemented different steps in this article on the command line application ‘Terminal’. Before going to start the Perl installation steps in detail, open the terminal window. You can access this application by pressing ‘Ctrl+Alt+t’ or you can also open it from the application menu.

Execute the following different steps to install Perl and run a Perl script on your Ubuntu system:

Step 1: Update your system

Before going to start the installation of Perl, it is recommended to update your system by typing the following command via terminal:

$ sudo apt update

The above command will download and install all available updates for your Ubuntu 20.04 apt repository.

Step 2: Install Perl on Ubuntu 20.04

On our system, Perl is already installed. But, if you don’t have Perl installed on your system then, you can install it directly from the Ubuntu repository by typing the following command:

$ sudo apt install perl

The above command will automatically install the all required Perl packages and dependencies on your system.

Step 3: Verify the Perl Installation

Once the installation of Perl is completed, now you can verify the installation by using the following ‘grep’ command on your terminal:

$ apt list --installed | grep -i perl

The above command will find the all installed packages of Perl and list on the terminal window which you can see in the following snapshot:

Step 4: Check Installed Perl Version

If you want to know which Perl version is installed on your Ubuntu system then, by executing the following command you can check it:

$ perl -v

As you can see in the below-given screenshot that Perl version ‘v5.30.0.’ is installed our system.

Step 5: Run Your First Perl Script on Ubuntu 20.04

Now, it’s time to run your first Perl script on your system. To do this, create a simple text file in your favorite text editor and paste the following code into it:

#!/usr/bin/perl

use warnings;

print("Hi, this is test script Hello world\n");

Save the above file with named ‘helloworld.pl’. The file will be saved in your home directory by default. Run this file via the terminal by typing the below-mentioned command:

$ perl helloworld.pl

The following result will be shown on the terminal after running the above mentioned script:

Step 6: Install Perl Sql module on Ubuntu 20.04

You can install the MySQL module for Perl on your Ubuntu 20.04 system. To do this, follow the below apt command to install the Perl Mysql module:

$ sudo apt install libdbd-mysql-perl -y

The above mentioned command will install the necessary mysql Perl packages on your Ubuntu system.

Conclusion

In the above article, we have explained the installation of Perl and how to create and run Perl script using the command line on Ubuntu 20.04. We have also discussed how to configure necessary Perl modules on your system. Please let us know about your difficulties or queries related this article.

]]>
Wall Command in Linux with Examples https://linuxhint.com/wall-command-in-linux-with-examples/ Fri, 12 Mar 2021 12:03:14 +0000 https://linuxhint.com/?p=94100 In a Linux environment, there are scenarios when multiple users are working on the server simultaneously through SSH. However, sometimes system admin needs to restart or shut down the system due to e.g. system maintenance, kernel upgrade, adding or removing hardware from the server. If this is the case, the system admin should inform all logged-in users to save their work. Email does not fit in this situation, as you first have to find out who is logged in and then sending emails to them. Also, you do not know when the user will read the email. Luckily, there is a Linux command “wall” that allows you to do this easily.

Here, we are going to describe the usage of wall command in Linux. Remember, the wall command works the same for all Linux distributions.

Note: Wall command only displays the message on the Terminal window of logged-in users. Users working only on GUI, with no Terminal window open will not be able to see the messages.

Linux Wall Command

Linux Wall command allows you to send a message or the contents of a file to all the currently logged-in users. If no file or message is specified, wall command reads the message from the stdin (standard input).

Wall Command Syntax

The syntax for wall command is as follows:

$ wall [options] [message-or-filename]

Send a Message to All Users

To send a message to all the currently logged-in users, type wall followed by the message you want to send.

$ wall System is going down for 1-hour maintenance.

This command will send the message to all the logged-in users with a Terminal window open.

Note: For some Linux distributions, you have to execute the above command as super user. Also, if a user has chosen to deny messages to their Terminals (like using the mesg command), then only a sudo user will be able to send messages to their Terminals.

Following are the outputs displayed to two users “linuxways” and “ummara” who are logged-in to the server via SSH. These users are working from the system running Ubuntu and Debian.


The wall command also reads the message from stdin (standard input). To do so, simply type wall and hit Enter.

$ wall

After that, type any message or messages you want to send to logged-in users. Once you are done typing the messages, press Ctrl+D to send those messages.

this is first line

this is second line

.

Here is the output which all logged-in users received on their Terminal.

Send a Message from a File

If there are some messages that you have to repeat often, you can simply type them in a file. When you have to send those messages to the logged-in users, simply call that file with wall command. Remember, you will require sudo privileges if you want to send a message from a file.

$ sudo wall <filename>

For example in the following output, file content has been first shown using the cat command. Then to send the message contained in the file, the filename is passed to the wall command.

These are the outputs (from the file msg.txt) received by the logged-in users.

Send a Message to a Group

Instead of sending the message to all logged-in users, you can send it to only the members of a group who are currently logged in to your system. The syntax is as follows:

$ wall -g [group] [message]

For example, to send a message to a group named “sshusers”, the command would be:

$ wall -g sshusers System is going down for 1 hour maintenance.

All the members of the “sshusers” group who are currently logged in to the server will receive the specified message.

Suppress Banner

The wall command displays a banner before displaying a message as can be seen in the following screenshot.

To suppress this banner, use the -n option with the wall command:

$ wall -n <message>

For example, the following command will only display the specified message while suppressing the banner.

$ wall -n System is going down for 1 hour maintenance.

All the logged-in Terminal users will receive the message without a banner.

View Version Information

To view the version of the wall command, use the following command:

$ wall -V

The following output shows the version of the wall utility is 2.34.

Wall is a handy utility that helps a multi-user system admin to quickly notify other users to save their work before a system shutdown or reboots. In this article, we covered how to use the wall command to communicate with logged-in users. Hope you find it interesting and useful.

]]>
How to Install YakYak on Ubuntu 20.04 https://linuxhint.com/how-to-install-yakyak-on-ubuntu-20-04/ Fri, 12 Mar 2021 05:32:35 +0000 https://linuxhint.com/?p=94061 Google Hangouts is a famous communication app to send messages, share content like files, pictures, and videos. The screen sharing and video call options in this application make it popular among its users. The application can be installed on all operating systems and is also available on mobile phones. To make phone calls, users might need to buy monthly packages. In this tutorial, we will set up and install the YakYak Google Hangouts client on an Ubuntu 20.04 system.

Installing Google Hangouts/YakYak

Google Hangouts cannot be installed directly on the Linux platform-based desktop, we require to use YakYak a third-party application. This open-source client allows users to download Google Hangouts in their systems.

Method 01 # Installing Google Hangouts using Snap package

The first method discussed will use the snap package for the installation of Google Hangouts.

Step 1: Installing snap package

We can install Google Hangouts using YakYak in an Ubuntu system. To do so, make sure you already have installed the snap package within your system. If you do not have the package in the system, install it before moving to the next steps. To do so, open up the terminal window by using the Ctl+Alt+T shortcut or you can simply go to the ApplicationsTerminal of the system. When opened, type this command in the terminal window of your computer system:

$ sudo apt update && sudo apt install snapd

The moment you press the enter key from the keyboard, the apt updates and installation will begin.

Install Snapd

Step 2: Installing core

After the successful configuration of snap within the system, you need to install core of the snap. Type the following mentioned command in the terminal window:

$ sudo snap install core

Confirmation of installation

Once you hit enter an output similar to the one displayed below will confirm the installation process.

Step 3: Restarting snapd services

After that, restart the snapd services by typing the following:

$ sudo systemctl restart snapd

This will restart the snapd services in your system.

Step 4: Installing YakYak

The next step is the installation of YakYask within the system. To do so, type the following command within the terminal window and press the enter key:

$ sudo snap install yakyak

The download will begin as shown in the figure below:

Confirmation of installation

Once the process of installation is completed an output will appear as shown in the following figure:

Method # 02: Download and install the YakYak deb package

The second method requires user to download the YakYak deb package. Follow all of the steps mentioned below:

Step 1: Download the deb package

Download the latest deb package for YakYak in your system from the link. Download the highlighted deb package by clicking on it.

A dialog box will appear. Click on Save File option then press the OK button.

Once the deb package is saved, you need to access the Downloads directory. Type this command in the terminal window:

$ cd Downloads

Then list all of the downloaded files in the system. For this, use the command mentioned below:

$ ls

The deb package will be listed below as shown in the figure below:

Step 2: Installation of the deb package

Now, you have to install YakYak using the command given below:

The system will ask for the password of the user, provide it, and then press the enter key to proceed.

The installation process will then be finished soon.

Accessing the application

Once the application is installed in your system, go to the Applications and type YakYak, the application can now be seen in the available options.

Double click on it. The Google Account will ask for the credentials. If you already have an account, then proceed by providing the user credentials, otherwise, you need to create an account.

Uninstalling Google Hangouts/YakYak

To uninstall YakYak from the system, type the following command in the terminal window:

$ sudo apt remove yakyak

As soon as you press the enter key, the system will ask for the password of the logged in user.

This way, users can smoothly uninstall the application from their system based on their necessity.

Conclusion

In this tutorial, we went through the method of installation of Google Hangouts on the Ubuntu 20.04 system. Users can use YakYak to install the Google Hangouts application on their Linux systems. The tutorial discussed two methods of installation of YakYak and then walked users through the uninstallation process.

]]>
How to Assign Multiple IP Addresses to Single NIC in Ubuntu 20.04 LTS https://linuxhint.com/how-to-assign-multiple-ip-addresses-to-single-nic-in-ubuntu-20-04-lts/ Fri, 12 Mar 2021 05:24:57 +0000 https://linuxhint.com/?p=94058 While working with computer systems, sometimes you might require multiple IP addresses on your physical machine. One of the solutions is to have multiple NICs installed on your system. However, it is not practical to buy a new NIC and plug it in your system when you have the option to assign multiple IP addresses to a single NIC which is referred to as IP Aliasing. The common use case of IP aliasing is the implementation of IP based virtual hosting.

In this post, we will be demonstrating you how to assign multiple IP addresses to a single NIC in Ubuntu OS. We will be demonstrating the procedure on Ubuntu 20.04 (Focal Fossa).

Assigning Multiple IP Addresses to Single NIC Temporarily

In the following section, we will see how to assign a second IP address to a NIC. The second IP address assigned by this method is temporary. Once you reboot the system, it will be removed automatically.

Here are the steps for assigning a second IP address to NIC.

1. First find the current IP address and the name of the interface in your system. To do so, issue the following command in Terminal:

$ ip addr

The following output shows our network interface is ens33 and the current IP address is 192.168.72.157/24 which is the dynamic IP address assigned by DHCP.

2. Let’s assign another IP address to the NIC. To assign an additional IP address to your NIC, issue the following command in Terminal:

$ ip adder add <ip-address> dev <interface-name>

Replace the <ip-address> with the additional IP address you want to assign to your NIC and <interface-name> with the name of your NIC. For instance, to assign the second IP address 10.1.1.5/8 to your network interface ens33, the command would be:

$ ip addr add 10.1.1.5/8 dev ens33

3. After running the above command, verify if the second IP address has been assigned to your network interface. Run the following command to do so:

$ ip addr

Here is the output of the above command which shows two IP addresses assigned to the ens33 network interface.

4. Now try to ping both IP addresses one by one. You can see both IP addresses are reachable.

Remove the Multiple IP addresses from NIC

In order to remove the additional IP addresses assigned to a NIC, run the following command:

$ sudo ip addr del <ip-address> dev <interface-name>

Replace the <ip-address> with the additional IP address you have assigned to your NIC and <interface-name> with the name of your NIC. For instance, to remove the IP address 10.1.1.5/8 assigned to our network interface ens33, the command would be:

$ sudo ip addr del 10.1.1.5/8 dev ens33

Assigning Multiple IP Addresses to Single NIC Permanently

In the previous section, we have assigned the second IP address using the “ip addr add” command which is not the permanent method. Once you reboot the system, the IP address removes automatically. In this section, we will see how to make the IP assignment permanent.

In order to assign multiple IP addresses to a single NIC permanently, you will need to configure it in the interfaces configuration file.

1. Edit the interfaces configuration file as follows:

$ sudo nano /etc/network/interfaces

Append the following lines in the file:

iface <interface-name> inet static
address <ip-address>

Replace the <interface-name> with the name of your NIC to which you want to assign the additional IP address and <ip-address> with the IP address, you want to assign. For instance, to assign the second IP address 10.1.1.5/8 to your network interface ens33, the lines would be changed to:

iface ens33 inet static

address 10.1.1.5/8

Once you have added the above lines, save, and close the file.

Now restart the networking service to apply the configuration changes you have made above:

$ sudo systemctl restart networking

Alternatively, bring down and bring up the interface to apply the changes:

$ sudo ifdown ens33
$ sudo ifup ens33

Now to verify if the additional IP address has assigned to the network interface, use the following command:

$ ip addr

As we have configured the additional IP address in the configuration file, therefore it will remain permanent even if you reboot the system.

Remove the Multiple IP addresses from NIC

You can also remove the additional IP address you have configured in the interfaces configuration file. To do so, simply edit the /etc/network/interfaces file and remove the entry for the additional IP addresses you have added. Then save and close the file and restart the networking services:

$ sudo systemctl restart networking

or bring down and bring up the interface to apply the changes

$ sudo ifdown ens33
$ sudo ifup ens33

This is how you can assign multiple IP addresses to a single NIC in Ubuntu OS. In this post, we have discussed both the temporary and permanent methods for assigning the secondary IP address to a single NIC. Following the same methods, you can allocate multiple IP addresses to a single NIC.

]]>
How to block or unblock ping requests on Ubuntu Server 20.04 LTS https://linuxhint.com/block-unblock-ping-requests-to-ubuntu-server/ Fri, 12 Mar 2021 05:21:21 +0000 https://linuxhint.com/?p=94055 Ping is a network administration utility that is used to test the availability of a system on an IP network. Ping is also used to test the quality of the network connection by monitoring the round trip time and packet losses. On the other hand, network intruders and hackers also use ping to identify network subnets to find potential hosts or to perform ICMP flood attacks. Therefore, it is a good practice to block ping requests to your servers to prevent any kind of attack.

This article is about how to block ping requests to Linux Server. We will also describe how to unblock the ping requests in case you need to use ping for system administration and troubleshooting.

Prerequisites

  • Ubuntu 20.04 LTS
  • User with sudo privileges

Note: The commands discussed here have been tested on Ubuntu 20.04 LTS.

Block/unblock ping requests to Linux Server

Ping works by sending an ICMP packet (Echo request) to the destination system and then receives a response ICMP packet (Echo reply). In Linux, the ping command continues sending ICMP packets until you stop it using Ctrl+C.

In order to block ping requests, you will need to ignore/block the ICMP echo requests that are sent to your server. There are following two ways through which you can block/unblock ICMP echo requests to the Linux server.

  • Through Kernel parameters
  • Through iptables

Let’s get started.

Block/unblock ping requests through kernel parameters

Through kernel parameters, you can block ping requests either temporarily or permanently. Kernel parameters can be modified through sysctl command, /sys/proc directory, and /etc/sysctl.conf file.

Temporary block/unblock ping requests

The sysctl command in Linux is used to read and write kernel parameters in the /proc/sys directory. Using this command, we can set up kernel parameters to block/unblock ping requests. The kernel parameter net.ipv4.icmp_echo_ignore_all controls whether the system should respond to the ICMP echo request. The default value of it is ‘0’ which means to respond to the ICMP request.

Block Ping Request

In order to block ping request, issue the following command in Terminal:

$ sudo sysctl -w net.ipv4.icmp_echo_ignore_all=1

This command sets the kernel parameter to ‘1’ which means to ignore all the ICMP requests.

Now all the ping requests to your system will be blocked and the sender will receive no response as shown in the below screenshot.

Unblock Ping Request

To unblock the ping requests, again run the same command by changing the parameter value to default ‘0’.

$ sudo sysctl -w net.ipv4.icmp_echo_ignore_all=0

Alternatively, you can block the ping requests by changing the kernel parameter value in the /proc/sys directory using the echo command. However, to use this method, you will need to run the command as root.

In order to block ping request, first switch to root account using the following command in Terminal:

$ su root

When prompted for the password, enter the password for root.

Then issue the following command in Terminal:

$ echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all

To unblock the ping requests, the command would be:

$ echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all

Permanently block ping requests

Kernel parameters can also be modified through the /etc/sysctl.conf file. This file will allow you to permanently block ping requests to your server.

Block Ping Request

In order to block ping request to your system, edit /etc/sysctl.conf file:

$ sudo nano /etc/sysctl.conf

Then append the following line in the file:

net.ipv4.icmp_echo_ignore_all = 1

Save and close the file.

Then issue the following command in Terminal to apply this configuration without reboot:

$ sysctl -p

Unblock Ping Request

To unblock ping requests, edit the /etc/sysctl.conf file:

$ sudo nano /etc/sysctl.conf

Then modify the value of net.ipv4.icmp_echo_ignore_all to ‘0’:

net.ipv4.icmp_echo_ignore_all = 0

Save and close the file.

Then issue the following command in Terminal to apply this configuration without reboot:

$ sysctl -p

Block/unblock ping requests Using iptables

Iptables is a firewall utility in Linux that controls incoming and outgoing traffic based on certain rules. It comes preinstalled in the Ubuntu system. In case, it is missing from the system, you can install it using the following command in Terminal:

$ sudo apt install iptables
Block Ping Request

To block ping requests to your system, type following command in Terminal:

$ sudo iptables -A INPUT -p icmp --icmp-type 8 -j REJECT

Where the A flag is used to add a rule in iptables and icmp-type 8 is the ICMP type number used for echo request.

The above command will add a rule in the firewall that will block any incoming ping requests to your system. By adding this rule, anyone sending the ping request to your system will see the “Destination Port Unreachable” message as shown in the below screenshot.

If you do not want this message to appear, use the following command replacing REJECT with DROP:

$ sudo iptables -A INPUT -p icmp --icmp-type 8 -j DROP

Now anyone sending the ping request to your system will see the following similar output:

Unblock Ping Request

In order to unblock ping requests to your server, type the following command in Terminal:

$ sudo iptables -D INPUT -p icmp --icmp-type 8 -j REJECT

Where the D flag is used to delete a rule in iptables and icmp-type 8 is the ICMP type number used for an echo request.

In order to make these rules persistent after a system reboot, you will need iptables-persistent package. Issue the below command in Terminal to install iptables-persistent:

$ sudo apt install iptables-persistent

You will be asked to confirm whether you want to proceed with the installation or not. Hit y to proceed, after which the system will start the installation and once completed, it will be ready to use.

After adding or deleting any rule, issue the following commands in Terminal to make them survive the system reboot.

$ sudo netfilter-persistent save
$ sudo netfilter-persistent reload

In order to view all the rules added to your iptables, issue the following command in Terminal:

$ sudo iptables -L

That is all there is to it! In this article, we have discussed how to block/unblock ping requests to Linux Server either through the kernel parameters or through iptables utility. Hope this helps!

]]>
How to install and configure HAproxy on Ubuntu 20.04 LTS https://linuxhint.com/how-to-install-and-configure-haproxy-load-balancer-in-linux/ Fri, 12 Mar 2021 05:10:22 +0000 https://linuxhint.com/?p=94051 HAproxy is an open-source and lightweight package that offers high availability and load balancing for TCP and HTTP based programs. It distributes the load among the web and application servers. HAproxy is available for nearly all Linux distributions. It is a widely used load balancer that is popular for its efficiency, reliability, and low memory and CPU footprint. In this post, we will explain how to install and configure HAproxy on a Ubuntu system.

We have setup three machines. We will install HAproxy on one server and the Apache web servers on two servers. Our HAproxy server will then act as a load balancer and will distribute the load among Apache web servers.

Note: The procedure and commands mentioned in this post has been tested on Ubuntu 20.04 LTS (Focal Fossa). The same procedure is also valid for Debian and Mint distributions.

Network Details

We will be using three Ubuntu servers; all on the same network. The details of our servers are as follows:

Hostname: HAproxy, IP address: 192.168.72.157 (Frontend server)
Hostname: web-server1, IP address: 192.168.72.158 (Backend servers)
Hostname: web-server2, IP address: 192.168.72.159 (Backend servers)

Note: You must have sudo privileges on all the servers.

We will configure one machine as a load balancer and the other two as web servers. The HAproxy server will be our front-end server that will receive the requests from the users and forward them to the two web servers. The web servers will be our Backend servers that will receive those forwarded requests.

This is how our setup looks like:

Setting up web servers-Backend servers

In this section, we will setup two web servers (web-server1 and web-server2) as our backend servers.

On web-server1(192.168.72.158)

Perform the below steps in your web server. Make sure to replace the hostnames and IP addresses with the relevant IP addresses and hostnames of your web servers.

1. Configure hosts file

On web-server1, edit the /etc/hosts file:

$ sudo nano /etc/hosts

Then add the hostname entry for HAproxy server as follows:

hostname-of-HAproxy IP-address-of-HAproxy

In our scenario, it would be:

HAproxy 192.168.72.157

2. Setup Apache webserver

Now install Apache web server using the below command in Terminal. You can also visit our post on How to install the Apache web server on Linux.

$ sudo apt install apache2

Then enable and start the Apache service using the below commands in Terminal:

$ sudo systemctl enable apache2
$ sudo systemctl start apache2

Create an index file for web-server1 using the below command in Terminal:

$ echo "<H1>Hello! This is webserver1: 192.168.72.158 </H1>" | sudo tee /var/www/html/index.html

If a firewall is running on your system, you will need to allow Apache traffic through it:

$ sudo ufw allow 80/tcp

Then reload the firewall configurations:

$ ufw reload

Now try accessing the site in your web browser by typing http:// followed by either the IP address or the hostname of your web server.

http:// hostname-or-IP-address

Alternatively, you can also use the curl command to test the webpage.

$ curl <hostname-or-IP-address>

On web server-2 192.168.72.159)

Perform the below steps in your second web server. Make sure to replace the hostnames and IP addresses with the relevant IP addresses and hostnames of your web servers.

1. Configure hosts file

In web-server2, edit the /etc/hosts file:

$ sudo nano /etc/hosts

Then add the hostname entry for HAproxy server as follows:

HAproxy 192.168.72.157

2. Install Apache webserver

Now install Apache web server using the below command in Terminal.

$ sudo apt install apache2

Then enable and start the Apache service using the below commands in Terminal:

$ sudo systemctl enable apache2
$ sudo systemctl start apache2

Create an index file for web-server2 using the below command in Terminal:

$ echo "<H1>Hello! This is webserver2: 192.168.72.159 </H1>" | sudo tee /var/www/html/index.html

Allow Apache in the firewall:

$ sudo ufw allow 80/tcp

and then reload firewall configurations:

$ ufw reload

Now try accessing the site in your web browser by typing http:// followed by either the IP address or the hostname.

http:// hostname-or-IP-address

Alternatively, you can use the curl command to test the webpage.

$ curl <hostname-or-IP-address>

Now our Apache web servers are ready.

Setting up HAproxy load balancer-Frontend server

In this section, we will set up an HAproxy load balancer for our web servers. This HAproxy server will act as a frontend server and accepts incoming requests from clients.

On the HAproxy server (192.168.72.157), perform the below steps to setup load balancer.

1. Configure hosts file

Edit the /etc/hosts file using the below command in Terminal:

$ sudo nano /etc/hosts

Add the following hostname entries for both Apache web servers along with its own hostname:

192.168.72.157 HAproxy
192.168.72.158 web-server1
192.168.72.159 web-server2

Now save and close the /etc/hosts file.

Installing HAproxy load balancer

Now in this step, we will be installing the HAproxy on one of our Ubuntu server (192.168.72.157). To do so, update apt using the following command in Terminal:

$ sudo apt-get update

Then update packages using the below command:

$ sudo apt-get upgrade

Now install HAproxy using the following command in Terminal:

$ sudo sudo apt install haproxy

Once the installation of the HAproxy server is finished, you can confirm it using the below command in Terminal:

$ haproxy -v

It will show you the installed version of HAproxy on your system which verifies that the HAproxy has been successfully installed.

Configuring HAproxy as a load balancer

In the following section, we will configure HAproxy as a load balancer. To do so, edit the /etc/haproxy/haproxy.cfg file:

$ sudo nano <strong>/etc/haproxy/haproxy.cfg</strong>

Append the following lines in the haproxy.cfg file replacing the IP addresses with your own IP addresses.

The frontend web-frontend in the above configuration lines tells HAproxy to listen to incoming requests on port 80 of 192.168.72.157 and then forward them to backend servers configured under the backend web-backend. While configuring, replace the IP addresses with the relevant IP addresses of your web servers.

Configuring HAproxy Monitoring

With HAproxy monitoring, you can view a lot of information including server status, data transferred, uptime, session rate, etc. To configure HAproxy monitoring, append the following lines in the configuration file located at /etc/haproxy/haproxy.cfg:

listen stats
bind 192.168.72.157:8080
mode http
option forwardfor
option httpclose
stats enable
stats show-legends
stats refresh 5s
stats uri /stats
stats realm Haproxy\ Statistics
stats auth kbuzdar:kbuzdar            #Login User and Password for the monitoring
stats admin if TRUE
default_backend web-backend

The above configuration enables the HAproxy “stats” page using the stats directive and secures it with http basic authentication using the username and password defined by the stats auth directive.

Once you are done with the configurations, save and close the haproxy.cfg file.

Now verify the configuration file using the below command in Terminal:

$ haproxy -c -f /etc/haproxy/haproxy.cfg

The following output shows that the configurations are correct.

Now to apply the configurations, restart the HAproxy service:

$ sudo systemctl restart haproxy.service

It will stop and then start the HAproxy service.

To check the status of the HAproxy service, the command would be:

$ sudo systemctl status haproxy.service

The active (running) status in the following output shows that the HAproxy server is enabled and running fine.

Here are some other commands for managing the HAproxy server:

In order to start the HAproxy server, the command would be:

$ sudo systemctl start haproxy.service

In order to stop the HAproxy server, the command would be:

$ sudo systemctl stop haproxy.service

In case you want to temporarily disable the HAproxy server, the command would be:

$ sudo systemctl disable haproxy.service

To re-enable the HAproxy server, the command would be:

$ sudo systemctl enable haproxy.service

Test HAproxy

Before testing the HAproxy setup, make sure you have connectivity to web servers. From your HAproxy server, ping both web servers either by their IP addresses or hostnames.

$ ping hostname-or-ip-address

The following output shows that the HAproxy server can reach both web servers.

Test HA Proxy using a web browser

Now in your HAproxy server, open any web browser and type http:// followed by the HAproxy server IP address which in our case is 192.168.72.157.

http://192.168.72.157

The HAproxy server will alternatively send the request to both web servers in a round-robin method. You can test this by reloading the webpage a few times.

This is the response we received when we visited the http://192.168.72.157 for the first time:

This is the response we received when we reloaded the webpage:

You can also use the hostname in place of the HAproxy server IP address.

Test HA Proxy using curl

You can also use the curl command in Linux to test the HAproxy setup. Open the Terminal and type curl followed by the IP address or the hostname of the HAproxy server.

$ curl 192.168.72.157

or

$ curl HAproxy

Run the curl command a few times and you will see the response alternating between both web servers.

Instead of running the commands several times, you can also run the following one-line script to test the HAproxy server:

$ while true; do curl 192.168.72.157; sleep 1; done

Testing HAproxy Monitoring

To access the HAproxy monitoring page, type http:// followed by the IP address/hostname of HAproxy server and port 8080/stats:

http://192.168.72.157:8080/stats

or

http://HAproxy:8080/stats

The following authentication box will appear. Enter the username and password you have configured earlier in the configurations and then press OK.

This is the statistics report for our HAproxy server.

There you have the installation and configuration of HAproxy load balancer on the Linux system. We have just discussed the basic setup and configuration of HAproxy as a load balancer for Apache web servers. We also looked at some commands for managing the HAproxy server. In the end, we tested the load balancing through the browser and the curl command. For more information, visit HAproxy official documentation

]]>
How to install XAMPP Server on Linux Mint 20 https://linuxhint.com/how-to-install-xampp-server-on-linux-mint-20/ Thu, 11 Mar 2021 09:10:30 +0000 https://linuxhint.com/?p=93986

Introduction:

XAMPP is a cross-platform web server that is designed for testing your web applications based on Apache, MySQL, Perl, and PHP. This webserver was developed by Apache Friends and it has been in use since 2002. Today, we will learn the method of installing XAMPP on Linux Mint 20. However, the same series of steps can be performed on Debian 10 for installing XAMPP on it.

Method of Installing XAMPP on Linux:

For having XAMPP installed on your Linux system, you should perform all the steps listed below:

Step # 1: Verifying the Installation of “net-tools”:

XAMPP requires the “net-tools” package to be installed on your system. This package can be installed by running the following command in the terminal:

$ sudo apt install net-tools

Since the net-tools package was already installed on our system that is why we got the message shown in the image below on our terminal:

Step # 2: Downloading XAMPP via the Internet:

Now you need to visit the following website for downloading XAMPP:

https://www.apachefriends.org/download.html

Once you will visit this website, you need to download the latest version of XAMPP for Linux as highlighted in the image shown below:

When you will click on the “Download” button, a dialogue box will appear on your screen from which you are supposed to select the “Save” option and then click on the “OK” button.

After doing this, XAMPP will start downloading and when it has been downloaded successfully, you will see the following message on your browser:

Step # 3: Making the Downloaded File Executable:

Once the XAMPP file has been downloaded on your system, you need to make it executable so that it can be installed successfully. For making this file executable, you need to navigate to your Downloads directory and then execute the command stated below:

sudo chmod 755 xampp-linux-x64-7.2.34-0-installer.run

Running this command will set the execute permissions for your downloaded XAMPP file.

Step # 4: Installing XAMPP on Linux:

When we have made this file executable, we can easily install it by running the following command in our terminal:

sudo ./xampp-linux-x64-7.2.34-0-installer.run

After doing that, the installation wizard will appear on your screen. You are required to go with all the options that are selected by default and just press the Next button at every screen that appears. However, we have still shown all the screens below for your convenience. The welcome screen of XAMPP is shown in the image below:

After clicking the Next button on the welcome screen, you will be asked to select the components for XAMPP. Just go with the default selected components and click on the Next button as highlighted in the following image:

Now select an installation directory and click on the Next button.

On the Bitnami for the XAMPP screen, you are again supposed to click on the Next button.

Then the installation wizard will tell you that the setup is ready to install as shown in the image below:

The installation progress bar is shown in the following image:

Finally, when the installation will complete, you will be supposed to click on the Finish button as highlighted in the image shown below:

Step # 5: Verifying the Installation of XAMPP on Linux:

If XAMPP has been successfully installed on your Linux system, then after clicking on the Finish button, the following screen will appear on your system which will confirm the installation:

Method of Uninstalling XAMPP in Linux:

However, at any point, if you feel like you do not need XAMPP on your Linux system anymore, then you can always uninstall it. First, you will need to move to the directory where XAMPP has been installed by running the command stated below:

cd /opt/lampp

After navigating to this directory, uninstall XAMPP by running the following command:

sudo ./uninstall

Your terminal will prompt you with a confirmation dialogue box from which you are supposed to click on the “Yes” button as highlighted in the image shown below:

When the uninstallation process will complete, you need to click on the “OK” button.

Finally, you can also remove the directory in which XAMPP was installed by running the following command:

sudo rm –r /opt/lampp

Doing this will remove all the traces of XAMPP from your Linux system.

Conclusion:

In this article, we explained to you the method of installing XAMPP on Linux Mint 20. The steps described above were demonstrated on Linux Mint 20 but they can also be performed as it is on Debian 10. Moreover, we also shared with you the method of uninstalling this web server whenever you feel like it.

In my next post, I will continue hosting a small application on this webserver. ]]> How to change MTU size in Linux https://linuxhint.com/how-to-change-mtu-size-in-linux/ Thu, 11 Mar 2021 09:01:01 +0000 https://linuxhint.com/?p=93981 MTU (Stands for Maximum Transmission Unit) is the maximum size of the packet that can be transmitted from a network interface. All the devices including servers and switches/routers involved in communication should have the same MTU size. Large MTU size has less overhead associated with it while the smaller MTU has less delay.

The default MTU size in most of the Ethernet networks is 1500 bytes. However, you can change it as per the requirements. In this tutorial, we will explain how to change MTU size in Linux.

Prerequisites

  • Ubuntu 20.04 system
  • User with sudo privileges

Note: The commands discussed in this article have been tested on Ubuntu 20.04 LTS (Focal Fossa). The same commands are also valid for Debian distribution.

View Current MTU Size

In order to view the current MTU size of your ethernet interface, use the ifconfig command as follows:

$ ifconfig | grep mtu

The output below shows the current MTU size of interface ens33 is 1500.

Alternatively, you can also use the “ip a” command to view the current MTU size:

$ ip a | grep mtu

Temporarily changing the MTU Size – Using ifconfig command

We can use the ifconfig command to change the MTU size of a system’s network interface. However, remember that this change does survive a reboot and returns to the default value i.e. 1500.

To change the MTU size of an interface, use the following syntax:

$ ifconfig <Interface_name> mtu <mtu_size> up

For instance, to change the MTU size of an interface named ens33 to 1000 bytes, the command would be:

$ ifconfig ens33 mtu 1000 up

After running the above command, the MTU size changes instantaneously. This change even does not require a service restart.

You can verify the new MTU size by running the following command in Terminal:

$ ifconfig | grep mtu

From the above output, you can verify that MTU size has now changed to 1000 bytes. However, as mentioned before, this change will not survive a reboot. The MTU size will return to its default value of 1500 after a reboot.

Permanently changing the MTU Size

The ifconfig command instantaneously changes the MTU size but this change does not survive a system reboot. In the following section, we will see how to permanently change the MTU size.

In dynamic IP addressing, the MTU size is set by DHCP. So will need to configure the DHCP configuration file located at /etc/dhcp/dhclient.conf. For static IP address, we will make changes in the network interface configuration file located at /etc/network/interfaces.

Using /etc/dhcp/dhclient.conf file

If the DHCP server is running on your system and the network interfaces are configured to receive the IP addresses from it, then use /etc/dhcp/dhclient.conf file to change the MTU size.

Edit the nano /etc/dhcp/dhclient.conf using the following command:

$ sudo nano /etc/dhcp/dhclient.conf

Then add the following lines below the “send host-name = gethostname(); line:

default interface-mtu <mtu_size>;

supersede interface-mtu <mtu_size>;

For instance, to set the MTU size to 1400, we will add:

default interface-mtu 1400;

supersede interface-mtu 1400;

If you have multiple interfaces and you want to change the MTU size of just one interface, then enclose it in the braces as follows:

interface "interface_name" {

default interface-mtu <mtu_size>;

supersede interface-mtu <mtu_size>;

}

Once you have configured the file, save, and close it.

Now restart the networking service using the following command in Terminal:

$ sudo service networking restart

Also, bring up the interface using the following command:

$ sudo ifup <interface_name>

Make sure to replace the <interface_name> with the actual network interface on your system e.g ens33, eth0, eth1, etc.

In our case, it would be:

$ sudo ifup ens33

Now issue the following command in Terminal to verify if the MTU size has changed successfully.

$ sudo ifconfig | grep mtu

From the output, you can see the MTU size has been changed to 1400.

Using /etc/network/interfaces file

If your network interface is configured to obtain a static IP address, then you can change the MTU size by configuring the /etc/network/interfaces file.

Edit the /etc/network/interfaces file using the following command in Terminal:

$ sudo nano /etc/network/interfaces

Append the below line in the file:

post-up /sbin/ifconfig <interface-name> mtu <mtu_size>

Make sure to replace <interface-name> with the actual interface name and <mtu_size> with the MTU size you want to set on the network interface.

For instance, to change the MTU size of an interface named ens33 to 1300 bytes, the command would be:

post-up /sbin/ifconfig ens33 mtu 1300 up

Once you have configured the file, save, and close it.

Now restart the networking services using the following command in Terminal:

$ sudo service networking restart

Also, bring up the interface using the following command:

$ sudo ifup <interface_name>

Make sure to replace the <interface_name> with the actual network interface on your system e.g. ens33, eth0, eth1, etc.

In our case, it would be:

$ sudo ifup ens33

Now issue the following command in Terminal to verify if the MTU size has changed successfully.

$ ip a | grep mtu

From the output, you can see that the MTU size has been changed to 1300. This change will be kept persistent and will not be affected even after a reboot.

That is all there is to it! By following the above procedures, you can change the MTU size of a network interface either temporarily or permanently in your Linux system. Hope this helps!

]]>
How to install Zimbra on Ubuntu 18.04 LTS https://linuxhint.com/how-to-install-zimbra-on-ubuntu-18-04-lts/ Wed, 10 Mar 2021 10:25:24 +0000 https://linuxhint.com/?p=93717 Zimbra Collaboration Server is open-source collaborative software that comprises a mail server and a web client. It allows for email, calendaring, creating users and distribution lists, file sharing, chatting, managing mail server activities, etc. Zimbra Collaboration Server is supported on various platforms including Ubuntu 12.04, Ubuntu 14.04, Ubuntu 18.04, Redhat Enterprise Linux 6, Redhat Enterprise Linux 7, CentOS6, CentOS 7, etc. It is also supported on cloud platforms like VMware vCloud Director VMware vCloud Air and virtualization platform like VMware vSphere, XenServer 6, and KVM.  The subject of today’s post is how to install the Zimbra Collaboration server on Ubuntu 18.04 LTS.

Prerequisites

For running the Zimbra collaboration server, you should have:

  • Ubuntu machine 18.04 – 64bit
  • Root privileges
  • Free Disk space 30 GB (minimum)
  • RAM 8 GB (minimum)
  • CPU/Processor 2.0 GHz (minimum)

Note:

For the setup, we have used:

Zimbra: 8.8.15 GA Release

Domain: test.org

IP: 192.168.1.101

Installing Zimbra on Linux

Here are the steps to install the Zimbra Collaboration Server on Linux. Let’s get started.

Step 1: Update and upgrade existing packages

First, you will need to update and upgrade the existing packages. To do so, issue the below commands in Terminal:

$ sudo apt update
$ sudo apt upgrade

Step 2: Edit hostname and hosts file

Now, we will need to setup a hostname for Zimbra. To do so, edit /etc/hostname file using the below command in Terminal:

$ sudo nano /etc/hostname

Replace the hostname with the mail.test.org and then save and close the hostname file.

Replace mail.test.org with your own domain name.

Now edit the /etc/hosts file using the below command in Terminal:

$ sudo nano /etc/hosts

Type the following entry and then save and close the hosts file.

192.168.72.167 mail.test.org mail

Where 192.168.72.167 is the IP address of your Zimbra server, and mail.test.org is the fully qualified domain name (FQDN).

Step 3: Install DNS server

In this step, we will install dnsmasq as our DNS server. However, before installing dnsmasq, we will first need to disable systemd-resolve as it runs on port 53. The DNS server dnsmasq also runs on port 53 which can cause port conflict.

Therefore, we will disable the systemd-resolve. Use the following command to do so:

$ sudo systemctl disable systemd-resolved

Then stop the systemd-resolved using the below command:

$ sudo systemctl stop systemd-resolved

Now remove the resolv.conf symlink file:

$ sudo rm /etc/resolv.conf

Then create a new resolv.conf file using the below command:

$ sudo sh -c 'echo nameserver 8.8.8.8 >> /etc/resolv.conf'

Now to install dsmasq, issue the below command in Terminal:

$ sudo apt install dnsmasq

Install Zimbra on Ubuntu

Once the installation of dnsmasq is completed, run the below command to edit the dnsmasq configuration file:

$ sudo nano /etc/dnsmasq.conf

Add the following lines in the configuration file:

server=192.168.72.167

domain=test.org

mx-host= test.org, mail.test.org, 5

mx-host=mail.test.org, mail.test.org, 5

listen-address=127.0.0.1

Then restart the dnsmasq service using the below command in Terminal:

$ sudo systemctl restart dnsmasq

Step 4: Downloading and installing Zimbra Collaboration Tool

Now download Zimbra for Ubuntu 18.04 LTS from the following link:

https://www.zimbra.org/download/zimbra-collaboration

Or use the following wget command in Terminal to download Zimbra:

$ wget https://files.zimbra.com/downloads/8.8.15_GA/zcs-8.8.15_GA_3869.UBUNTU18_64.20190918004220.tgz

The downloaded file will be in the .tgz format. Issue the below command in Terminal to extract the downloaded file:

$ tar -xvf zcs-8.8.15_GA_3869.UBUNTU18_64.20190918004220.tgz

Navigate to the extracted folder using the cd command as follows:

$ cd zcs-8.8.15_GA_3869.UBUNTU18_64.20190918004220

Then run the installer as follows:

$ sudo ./install.sh

Once the installation is started, you will see something like this:

Install Zimbra on Ubuntu

When the following Software License agreement appear, hit y to accept. Then again hit y to use Zimbra’s package repository for installation.

When the following view appears, hit y for each of the packages except for the zimbra-imapd which is available only in the beta version.

When you are notified that the system will be modified, hit y after which the installation will be started.

Install Zimbra on Ubuntu

Once the installation is done, the following view will appear and you will be asked to configure the unconfigured items.

Here, we will configure the admin password for Zimbra which is not yet configured. You can also see the Admin Password marked as ***** under the zimbra-store section. Hit 7 on your keyboard to enter into the zimbra-store section.

Now for Admin Password configuration, hit 4. You will be prompted to set the password for admin. Type any password (with a minimum of 6 characters).

Install Zimbra on Ubuntu

Now hit a to apply the configurations and hit y again to save the configurations. When you are notified that the system will be modified, hit y.

Now you will see the following screen with the configuration completed message, hit Enter to exit.

Now the installation of Zimbra mail server has been completed.

Step 5: Access Zimbra administration page

Now you can access the Zimbra administration page. Open any web browser and type:

https://ip_adddress:7071

or

https://FQDN:7071

You will see the following default Zimbra login page. Enter admin as username and type password you have set earlier (as described in the previous section).

Install Zimbra on Ubuntu

Once you are logged in, you will see the following view showing the summary and other statistics.

Install Zimbra on Ubuntu

Zimbra is an open-source mail server that offers several features but on the other hand, it consumes a lot of resources. Therefore, it is recommended to install it in a machine that has enough memory, processor, and disk space available. Now, you have learned how to install Zimbra in Ubuntu. In some other posts, we will follow up with the configuration of Zimbra.

]]>
Minecraft Command you need to know https://linuxhint.com/minecraft-command/ Wed, 10 Mar 2021 03:40:52 +0000 https://linuxhint.com/?p=93487 Few games give their players a great degree of freedom to complete their objectives, and Minecraft is one of them. Minecraft is a sandbox-style game with an infinite world where your primary objective is to mine and craft to survive. Though open-world games have so much to explore, sometimes doing the same things makes the whole experience bland. Luckily, Minecraft is known for its adaptability for personalization and allows players to customize everything.

In the previous articles, we discussed various ways to customize the Minecraft experience. The center of interest of this post is another feature of Minecraft, and that is the use of commands in the game. Minecraft commands are quite useful to modify and manage the world you have created. There is a wide range of commands with many possibilities. Some commands are simple for basic interactions, and some are powerful commands to modify almost everything in the world.

How to Enter Minecraft commands:

Entering the Minecraft command is as simple as creating a new world from the menu. Once you are in the world, press the forward-slash “/” key to get the command bar, where you will type your command. Every command you enter must start with a forward slash (/) if you play it as a single player.

If you are getting the error “command not found,” then press the “Esc” key, then go to “Open to LAN” options and “Allow Cheats: ON” and click on “Start LAN World“:

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft

How to select targets with Minecraft commands:

Before exploring Minecraft commands, let’s talk about how to select a target. For instance, if you want to give some items to a player, you have to select that player and target that player using “@<Selector Variable>“. Here is the list:

Target Description
@a To target all Players
@e To target all Entities (Bats, Arrows, Creepers, etc.)
@p To target the nearest Player
@r To target a random Player
@s To target the person executing the command (yourself)

The above mentions target selectors greatly help to target players without specifying their names.

Let’s discuss some well-known commands and their usage in Minecraft:

1. How to use the help command in Minecraft:

To get help and usage about any command, use help with a forward slash:

/help <Command>

To get help with the “gamemode” command, use:

/help gamemode

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft%20

2 How to change the game mode using the command:

Minecraft has 2 modes, the creative mode where you have unlimited resources, you can fly, and no mob attacks while in survival mode, your health keeps on dropping, and there are mob-attacks as well, but with the usage of the command, the mode of the game can be changed immediately. Press forward, slash “/” and type:

/gamemode creative

If you are in creative mode, use the same command to get into the survival mode:

/gamemode survival

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft%20Comm

You can also enable adventure and spectator mode.

3 How to change game difficulty using the command:

Another important command you must know is changing game difficulty. You got to set game difficulty before generating your world. But with the command, the difficulty level can be modified at any time. Press “/” and type:

/difficulty easy

To add more challenges to your game experience, replace easy with normal or hard. But if the game is getting more difficult, then use difficulty level “peaceful”.

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft%20Comman

4 How to get seed code of your world using the command:

If you are interested in generating the seed of your world so you can use it to load an identical world in the future, then used the command given below:

/seed

This command will generate a seed code.

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft%20

5 How to teleport anywhere in Minecraft world using the command:

It would not be easy to move from place to place on feet if your world is gigantic. In this situation, teleport command can help you. With the use of this command, you can teleport anywhere in your world. Another benefit is that you can also teleport other players and items using this command. Teleport command is a big time-saver; to use it, press forward slash “/”:

/tp <Target>[x,y,z]

Type “tp” select target as discussed above and input coordinates x, y, and z.

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft%20Comm

6 How to change the weather of Minecraft world using the command:

Another interesting command is changing the weather. To change the weather, type the following command:

/weather <Type> <Time in seconds>

For the <type> field, use “clean”, “rain,” or “thunder,” and in the time field, input the number of seconds you want to keep that weather.

/weather thunder 30

The above command will change the weather to thunder for 30 seconds.

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft%20Com

7 How to summon anything in Minecraft using the command:

Summon command is another handy Minecraft command you must know. Using this command, you can instantaneously get any object, item, or mob at your specified location. The syntax is

/summon <Entity> <Position> <NBT>

Just type the name of any Minecraft entity and then specify the position and NBT. Position and NBT is an option. For instance, if you want to summon a horse, use:

/summon horse

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft%20Co

8 How to set daylight cycle using the command:

This command is simple but important to remember. In Minecraft, 50 seconds of real-time equals 1 hour Minecraft, and 20 minutes of real-time equals 1 day of Minecraft. With command, you can also set time:

/time set <Time>

The <Time> could be a letter “day”, “midnight”, “night”, “noon” or you can put a number as well, a list of time numbers is given below:

Time Description
0 For day time
6000 For midday
12000 For dusk
18000 For night
/time set 12000

or

/time set day

The above command will set the time to dusk. But there is a command as well to stop the time as well.

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft%20Com

To stop the time ticking, use:

/gamerule doDaylightCycle false

If you want to play under permanent sunlight or permanent moonlight, then use the above command. To resume the time use:

/gamerule doDaylightCycle true

9 How to enable instant mine using the command:

Who wants to hit several times to mine when there is a quick way to do it. To enable one-click mine with any tool, use the command:

/instantmine

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft%20Command

10 How to kill using the command:

To kill anyone in the game, use the “kill” command, you can target yourself or any other character in the game:

/kill <Target>

11 How to increase moving speed using the command:

For the most part, Minecraft is moving from place to place; how about changing the moving speed, yes! That’s is possible in Minecraft. You can change the speed using the command:

/attribute @s minecraft:generic.movement speed base set 120

Every creature has its own default movement speed, but the maximum value is 1024.

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecra

12 How to disable fire and fall damage in Minecraft using the command:

Disabling the fire damage and fall damage could be quite helpful. To disable it fire damage use:

/gamerule fireDamage false

And to disable fall damage use:

/gamerule fallDamage false

../../../../../../../../../../Desktop/My%20Mac/Articles/FEBRUARY/21%20Minecraft%20Comma

Conclusion:

Commands can be cheats for some people, but they are used to save time and shape your gameplay according to your preference. In this post, we learned another technique to modify the Minecraft game experience. Being a sandbox game, there is a lot to explore in Minecraft. Still, sometimes exploration becomes tedious and monotonous, and to overcome it, they add an interesting layer of features. There are plenty of commands used for various purposes, but in this, we covered those commands that you must know if you are new to this feature.

]]>
How to Create Django Views? https://linuxhint.com/create-django-views/ Tue, 09 Mar 2021 05:32:51 +0000 https://linuxhint.com/?p=93540 Different types of data of Django application, such as HTML content, XML data, JSON data, image, 404 error, etc. are transferred to the template through Django view. Each view is created for a specific purpose and associated with a particular template. The data of the view can be generated from the user through HTML form or from the database or business logic. Django views can be created using a method of python class or python function. The class-based views contain many functionalities compared to function-based views. For this, most of the Django applications use class-based views to represent the data of the Django application. The ways of creating the function-based view and class-based view have been explained in this tutorial.

Prerequisites:

Before practicing the examples of this tutorial, you have to complete the following tasks:

  1. Install the Django version 3+ on Ubuntu 20+ (preferably)
  2. Create a Django project
  3. Run the Django server to check whether the server is working properly or not

Setup a Django App:

A. To create a Django app named viewapp, run the following command:

$ python3 manage.py startapp viewapp

B. To create the user for accessing the Django database, run the following command. If you have created the user before then skip this part:

$ python3 manage.py createsuperuser

C. Add the app name in the INSTALLED_APP part of the settings.py file.

INSTALLED_APPS = [
    …..
    'viewapp'
]

D. Create a folder named templates inside the viewapp folder and set the template’s location of the app in the TEMPLATES part of the settings.py file.

TEMPLATES = [
    {
      ….
            'DIRS': ['/home/fahmida/django_pro/viewapp/templates'],
             ….
      },
]

Create a Simple function-based View:

Open the views.py file from the viewapp folder and replace the content of this file with the following script. index() function is used in the script to create the HTML content that will be sent to the browser using the HttpResponse() method. Here, the current date and time of the system will be read using the today() function and the current date value will be generated before sending to the browser.

Views.py

# Import the date module to read the current date
from datetime import date
# Import the HttpResponse module to send data from view to template
from django.http import HttpResponse

# Define function to create function-based view
def index(request):
    # Read the current date
    today = date.today()
    # Set static data for the view
    content = "<center><h1 style='color:green'>Welcome to LinuxHint</h1><h2>"
    content += "Today is " + today.strftime("%B") + " " + today.strftime("%d") + ", " + str(today.year) + "</h2></center>"
    # Sent the content to the browser
    return HttpResponse(content)

Modify the content of the urls.py file with the following script. In the script, the ‘welcome/’ path is defined to call the index() function that will send the HTML content to the template file.

urls.py

# Import path module
from django.urls import path
# Import view module
from viewapp import views

# Call index method to display the content
urlpatterns = [
   # Define path to call index() function
    path('welcome/', views.index)
]

Run the following URL from the browser that will show the following output. A formatted headline text and the current date value are shown in the output.

http://localhost:8000/welcome/

Create a Simple class-based View:

Create a views2.py file inside the viewapp folder and add the following script. MyView class is defined in the script that contains a method named get(). A list variable named listdata is declared in the script to create a list of 10 random numbers. The values of the list will be passed to the template through the HttpResponse() method when this view is called. the random module has been used in the script to generate a random integer number in each iteration of the for loop using the randint() function.

views2.py

# Import the HttpResponse module to send data from view to template
from django.http import HttpResponse
# Import view module
from django.views import View
# Import random module
import random

# Define class for class-based views
class MyView(View):

    def get(self, request):
        # Declare the list variable
        listdata = []
        # Add the first element of the list
        listdata.append('<center><h2>he list of 10 random numbers are:</h2>')
        # Iterate the loop for 10 times
        for n in range(10):
            # Generate a random number within 1 to 50
            random_number = random.randint(1, 50)
            # Add the random number in the list
            listdata.append(random_number)
            # Add a break element in the list
            listdata.append('<br/>')
        # Add the last element of the list
        listdata.append('</center>')
        # Send the list values to the browser
        return HttpResponse(listdata)

Modify the content of the urls.py file with the following script. In the script, the “number/” path is defined to call the MyView.as_view() method that will send the data of the list to the template file.

urls.py

# Import path module
from django.urls import path
# Import view module
from viewapp import views
# Import MyView class
from viewapp.views2 import MyView

# Call the get method of MyView class
urlpatterns = [
   # Define  path to call index() function
   path('welcome/', views.index),
   # Define path to call MyView.as_view() method
    path('number/', MyView.as_view()),
]

Run the following URL from the browser that will show the following output. The numbers of the output will be changed if the page is refreshed because each number of the list will be generated randomly.

http://localhost:8000/number/

Conclusion:

The output of the web application depends on the script of the view file that is a major part of any web application. Function-based views are mostly used in the early version of the Django app and now class-based vies are used in most applications of Django. The ways of creating both types of views have been shown in this tutorial to help the new Django users create their views based on their application.

]]>
How to Fix “failed to start hostname.service unit hostname.service is masked” Error https://linuxhint.com/fix-failed-to-start-hostname-service-error/ Tue, 09 Mar 2021 05:23:33 +0000 https://linuxhint.com/?p=93550 Whenever you bring in a new computer system, there is a default hostname associated with it that is mapped onto a specific IP address. However, you can always change this hostname for your convenience. Once you change the hostname of your Linux-based system, you should always restart the “hostname.service” module for the new changes to take effect. Sometimes, when restarting this service, you may encounter the “failed to start hostname.service unit hostname.service is masked” error. This article highlights the root cause of this error and shows you how to resolve this error.

Causes of the Error

The system hostname is stored in two main files in Linux. The first file is the “/etc/hostname” file, and the other file is the “/etc/hosts” file. The former only consists of the hostname of your system, whereas the latter contains a mapping of the hostname onto a specific IP address. The “failed to start hostname.service unit hostname.service is masked” error arises when the contents of these two files are mismatched, i.e., the hostname mentioned in one of these files is different from the hostname in the other file. Due to this inconsistency between the contents of the “/etc/hostname” and “/etc/hosts” files, your system will fail to start the hostname.service, and the error will occur.

How to Resolve the Error

The simplest way to resolve this error in Linux is by ensuring that the hostname mentioned in both files is the same. To do so, you will need to check the contents of both these files. You can access the “/etc/hostname” file by executing the following command in the Linux terminal:

$ sudo nano /etc/hostname

Our “/etc/hostname” file is shown in the image below:

The “/etc/hosts” file can be accessed with the following command:

$ sudo nano /etc/hosts

Our “/etc/hosts” file is shown in the image below:

As you can see from the contents of both files, our hostname is the same in both files, i.e., kbuzdar-VirtualBox. Once you have ensured that the hostname in your respective files is exactly the same, then you can try restarting the hostname.service once again. This time, it should not render the error.

Conclusion

This article enlightened you about the causes of the “failed to start hostname.service unit hostname.service is masked” error. Moreover, it also shared with you the simplest method through which you can get rid of this error in Linux.

]]>
Difference between CPython, Jython, IronPython, PyPy, and Cython https://linuxhint.com/cpython-jython-ironpython-pypy-cython/ Tue, 09 Mar 2021 05:09:20 +0000 https://linuxhint.com/?p=93547 Computer Science is one of the hottest fields out there right now, and it keeps on growing and expanding further. It has tremendously evolved from what it used to be in the early days and now is being used for content that is changing the lives of millions of people. Such has been its advancement that has allowed concepts like artificial intelligence, deep learning, and so many others, which once looked impossible to come into existence.

One particular element of computer science that has seen a large evolution is the programming language section, which is an integral part of machines and comprises instructions that allow the machines to perform different tasks. Python is one high-level programming language that has immensely grown and is being used in multiple sectors of the industry.

However, Python itself is vast and can be implemented in several different flavors, which shall also be the topic of our discussion in this article, and where we will be looking at the different implementations that currently exist of Python.

Different Implementations of Python

We have been using the term “implementation” for a while now. What does this mean? Well, implementation refers to the way the interpreter was written – what languages were used and what is the purpose of that specific interpreter.

Now, let us look at some of the different implementations of Python.

1) CPython

CPython is the default and most widely used interpreter or implementation of Python, written in C. It is the original Python version, which users download from its official website, Python.org. It can be better described as a mixture of both an interpreter and compiler as it converts your written Python source code into bytecode. By bytecode, we refer to a program code that gets compiled and processed into a low-level language that can be used as instructions for the interpreter. It is this bytecode that gets executed on the CPython Virtual Machine.

Since it is the original Python implementation, CPython has the highest compatibility with a variety of Python packages and modules and is the best choice if users need to write code that completely matches the Python standards.

2) Jython

Jython is another Python implementation that has been written in the Java language whose implementation can run in Java platforms. Similar to CPython, it first converts the source code into bytecode, which, as mentioned before, are a set of instructions that are needed by an interpreter. In Jython, these are written in Java and can run on the Java Virtual Machine, which is the same environment that Java itself uses. Jython allows users to easily work with Java programs since you can call, as well as utilize, your Java functions and classes directly from Jython without any additional effort which is immensely beneficial as Python users can get access into the enormous ecosystem of libraries and frameworks that come along with Java. The same is true on the opposite end.

3) IronPython

Similar to how Jython has been developed for Java users, IronPython is the popular Python implementation that has been written in C-Sharp (C#) and has been designed to run on the .NET platform. It creates a bridge between the Python and .NET universe and allows Python users to get access to C-sharp functions and classes, as well as .NET libraries and frameworks directly from IronPython. IronPython excels for programs that make use of threading and can be found on the ironpython.net website.

4) PyPy

PyPy is the Python implementation that has been written in the Python language itself and is another alternative to CPython. Since it has been created while keeping in mind the specifications of the Python language, it is most compatible with CPython, allowing it to run web frameworks like Django and Flask, and even adds a few improvements on the top of it. PyPy makes use of the concept called Just-in-time (JIT) compilation, which allows it to compile the source code during the execution of the program. This, in turn, has made it several times faster than CPython, in which its runtime speed being slow was a common complaint among users. PyPy completely improves this part of CPython.

5) Cython

Unlike the other implementations of Python mentioned in the list, Cython is not a Python interpreter but rather a superset of the Python language that allows users to compile programs in the C language. The amazing thing is that it provides you with the combined power of both Python and C, and this, therefore, is why it can be used for writing C extensions as well as transform and tune your Python code into C. Hence, Cython overcomes many limitations of Python and still maintains the convenience and comfort that comes with Python.

Conclusion:

Python has enormously grown and expanded into various implementations, all of which have been developed to the cater the needs of different users. Throughout the time frame in which users might be working with the Python interface, they might come across several of these implementations, and therefore, it is important to know what exactly each of these is and where does their expertise lie.

]]>