Linux | LinuxHostSupport https://linuxhostsupport.com/blog/category/linux/ Linux Tutorials and Guides Tue, 09 Jul 2024 12:52:44 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 How to stop Receiving Spam Emails on Linux with SpamAssassin https://linuxhostsupport.com/blog/how-to-stop-receiving-spam-emails-on-linux-with-spamassassin/ https://linuxhostsupport.com/blog/how-to-stop-receiving-spam-emails-on-linux-with-spamassassin/#respond Thu, 15 Aug 2024 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=2153 In the ongoing struggle against unwanted communication there are many technologies and strategies on how to stop receiving spam emails. One highly effective way for Linux users is the open-source Apache SpamAssassin project, offering a highly-effective and free anti-spam platform. In this article, we’ll teach you exactly how to stop receiving spam emails on Linux […]

The post How to stop Receiving Spam Emails on Linux with SpamAssassin appeared first on LinuxHostSupport.

]]>
In the ongoing struggle against unwanted communication there are many technologies and strategies on how to stop receiving spam emails. One highly effective way for Linux users is the open-source Apache SpamAssassin project, offering a highly-effective and free anti-spam platform.

In this article, we’ll teach you exactly how to stop receiving spam emails on Linux with SpamAssassin.

What is SpamAssassin and how it works

Spamassassin is a tool that scores spam emails by comparing them against various tests. It uses a header (X-Spam-Status:) marked with a number ranging from 0-5, with a setting of 3.5 being safe enough to reduce false positives and the amount of SPAM that makes it through. A SPAM score is calculated from multiple characteristics, ranging from 0 to 5, and has been effective for years. Spamassassin is a helpful tool for filtering spam emails. In this tutorial, we’ll learn how to integrate this filter into our Postfix server.

Prerequisites

  • An up-to-date Linux system
  • Postfix installed on your system
  • Root access to your server

Installing SpamAssassin

The installation of SpamAssassin service is easy to do. We accomplish it with the following command:

sudo apt-get install spamassassin # Ubuntu
sudo yum install spamassassin # AlmaLinux

After installing the service, we must integrate it with the Postfix mail server. To accomplish that, we’ll follow the next topic.

Configuring Spamassassin with Postfix

The main configuration file from Spamassassin is generally located at /etc/spamassassin/local.cf. There, you’ll find the required_score part, which sets what is spam and what is not. You can keep it as 5 and uncomment the line if it’s commented:

required_score 5.0

If you need to whitelist someone’s domain, you can add the following directive to your local.cf file:

whitelist_from *@sender_domain.com

Also, we need to configure report_safe. This directive will do the handle of the marked spam messages.

report_safe 0 # The incoming SPAM messages will have the header modified with a directive pointing it's spam
report_safe 1 # The incoming messages tagged as SPAM will create a report and attach the original message to it
report_safe 2 # The incoming SPAM will be attached as a new report and sent as plain text

To identify spam messages on the mailbox, we need to remove the rewrite_header Subject comment line so it will identify the spam:

rewrite_header Subject SPAM

And it’s done the configuration. Now, we need to integrate Spamassassin and Postfix.

Integrating Postfix and SpamAssassin

The postfix configuration file is located at /etc/postfix/master.cf. The first change required to be done is related to the SMTP line, so the line would look like:

smtp inet n - - - - smtpd

Then, after our changes, with the integration of SpamAssassin, it would look like this:

smtp inet n - - - - smtpd -o content_filter=spamassassin

At the end of our file, we need to add the following content:

spamassassin
unix – n n – – pipe
flags=R
user=spamd
argv=/usr/bin/spamc
-e /usr/sbin/sendmail
-oi -f ${sender} ${recipient}

That’s it. SpamAssassin is configured on your system and integrated with Postfix. At this point, you can test the email deliverability of your service to see if it’s working as expected. If you’re struggling with this, feel free to contact our Incident Server Support team, and we’ll help you get everything sorted out.

The post How to stop Receiving Spam Emails on Linux with SpamAssassin appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-stop-receiving-spam-emails-on-linux-with-spamassassin/feed/ 0
How to fix “405 error” https://linuxhostsupport.com/blog/how-to-fix-405-error/ https://linuxhostsupport.com/blog/how-to-fix-405-error/#respond Sat, 15 Jun 2024 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=2101 In this tutorial, we will explain more about the 405 website error and how to fix it. A 405 error is an HTTP not allowed error that prevents visitors from accessing the content of your website. The result of this error is a blank page and can be caused due to several reasons. If not […]

The post How to fix “405 error” appeared first on LinuxHostSupport.

]]>
In this tutorial, we will explain more about the 405 website error and how to fix it.

A 405 error is an HTTP not allowed error that prevents visitors from accessing the content of your website. The result of this error is a blank page and can be caused due to several reasons. If not resolved on time this can cause visitors to leave. Inevitably this damages your website reputation which may lead to a loss of sales.

In the next paragraphs, we will explain the reasons and possible solutions for fixing this error.

The 405 Not Allowed error can be tricky to identify quickly. Typically there’s only a blank page with the message at the top. We need to go through some checks which may take ten minutes to get our website up and running again.

Wrong URL

It’s easy to enter a long URL incorrectly which may lead to a 405 Not Allowed error. Try accessing the website homepage first. See if it is accessible and if so try to access the specific page you need. Checking the URL is so simple that sometimes we forget to do it, but it can solve our issue immediately.

Database Changes

If you use CMS websites with plugins such as WordPress, Drupal, or Joomla plugin updates can change your database. Before updating, it is necessary to have a database dump. In most cases, the database tables are changed by some plugins with full access to our database. Even if you uninstall the plugins, the database changes would not be reverted. One possible solution would be for the developer to modify them manually. It is recommended to have a database backup before doing anything to prevent such a scenario.

Web server configuration

If are using Apache as a web server, check the configuration of .htaaccess. We should consider the rewriting rules, limited directives, and who can access the website. If you are using Nginx, the configuration is in the Nginx virtual host file. You should check the Nginx location blocks, and the error page directives. This way you can make the changes, restart the web services, and see if that will fix the issue.

Files and Folder permissions

Uploading files in your website’s root directory with the root user can cause it to be inaccessible due to permissions. Always upload files and folders with the user who is the owner of the website’s root directory. However, if there are incorrect files and folder permissions we can fix them with the following commands:

chown www-data:www-data  -R .         # If the Apache or Nginx are owners
find . -type d -exec chmod 755 {} \;  # Directory Permissions
find . -type f -exec chmod 644 {} \;  # Files Permissions

Check the Code

You have to check if there are any hard-coded lines in your code. In addition, you should check your submitting forms, the GET, and the POST requests. Finally, check if some of the libraries in the website framework are using inconsistent methods rejected by the server. The developer should enable the debug mode and perform unit tests to find the issue.

Rollback any Updates

If your website was accessible before any plugin updates, the 405 Not Allowed method may be caused by the update. You should roll back the plugin update and see if that will fix the issue. If the issue is due to changed code, simply revert the lines of the changes and restart your web service.

Restore the whole Website

Finally, you can restore the website from our daily, weekly, or the whole backup made before any minor changes. This way we are sure that we will not lose time for debugging, and will fix the issue immediately. If your hosting provider offers managed services, contact their support to restore the website from a backup. If you have a bare-metal unmanaged server, you can always contact our technical support. We will help you with any aspect of your website. We are available 24/7.

These were some basic steps to solve the 405 Not Allowed error. If you liked this post on how to fix the 405 error, please share it with your friends. You can also leave a comment below.

The post How to fix “405 error” appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-fix-405-error/feed/ 0
How to Fix MySQL “Can’t connect to local server” https://linuxhostsupport.com/blog/how-to-fix-mysql-cant-connect-to-local-server/ https://linuxhostsupport.com/blog/how-to-fix-mysql-cant-connect-to-local-server/#respond Sat, 30 Mar 2024 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=2061 MySQL is an open-source relational database management system used for storing data. It is written in C and C++, offering various features that are very useful for developers and other users familiar with it. Often, it’s very useful to block off access to your MySQL server to prevent unauthorized access. Sometimes, you may lock yourself […]

The post How to Fix MySQL “Can’t connect to local server” appeared first on LinuxHostSupport.

]]>
MySQL is an open-source relational database management system used for storing data. It is written in C and C++, offering various features that are very useful for developers and other users familiar with it. Often, it’s very useful to block off access to your MySQL server to prevent unauthorized access. Sometimes, you may lock yourself out. In this blog post we will show you how to fix the MySQL connectivity issues when accessing MySQL as a local server. This blog post will teach you how to fix the dreaded “can’t connect to local server” issue. Let’s get started!

Prerequisites

  • A server with a Linux-based distribution (we used Ubuntu 22.04)
  • User privileges: root or non-root user with sudo privileges

MySQL Can’t connect to local server

The error message “can’t connect to local MySQL server through socket” can appear due to various reasons. One possibility is that the server cannot establish a connection to the MySQL server using its default socket due to an incorrect path to the socket file. Other reasons include incorrect permissions, misconfiguration in the MySQL setup, or the MySQL service is crashing unexpectedly due to a broken database, not enough RAM on the server, etc.

The socket is an endpoint where two processes communicate with each other. When we say the MySQL socket, we are talking about the mysqld.sock file located at /var/run/mysqld/mysqld.sock. Let’s go over the possible solutions for this connecting issue with the local MySQL server.

Let’s go over each possibility – we’re confident your MySQL server will be accessible locally once you try all of these solutions.

Check Your MySQL Service

Sometimes the MySQL service can stop unexpectedly due to various reasons. It may be due to insufficient disk space, not enough RAM, or the server has been rebooted and the MySQL service was not enabled to start on boot previously.

So, when we try to log in to the MySQL console with the following command:

mysql -u root -p

The connection cannot be established, and we will receive the following output:

root@host:~# mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

First, we need to check if the MySQL service is up and running with the following command:

systemctl status mysql

If the service is not running, you should receive the following output:

root@host:~# systemctl status mysql
○ mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: inactive (dead)  since Mon 2024-01-08 18:19:37 CST; 13min ago
    Process: 30718 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Process: 30749 ExecStart=/usr/sbin/mysqld (code=exited, status=0/SUCCESS)
   Main PID: 30749 (code=exited, status=0/SUCCESS)
     Status: "Server shutdown complete"
        CPU: 1.981s

We just need to start and enable the service with the command below:

sudo systemctl start mysql && sudo systemctl enable mysql

After checking the status again, you should receive the following output:

root@host:~# systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-01-08 18:32:21 CST; 8min ago
   Main PID: 30950 (mysqld)
     Status: "Server is operational"
      Tasks: 37 (limit: 4558)
     Memory: 365.3M
        CPU: 5.241s
     CGroup: /system.slice/mysql.service
             └─30950 /usr/sbin/mysqld

Try to log into your server now – it should be working again. If you are still seeing the same error, move onto the next potential solution.

MySQL Socket Permissions

Let’s say that we started and enabled the MySQL service, but we are still experiencing the error message:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Now we need to check if the socket file exists and is in the right directory with the correct permissions. Execute the command below:

ls -al /var/run/mysqld/

If you get this output:

root@host:~# ls -al /var/run/mysqld/
drwxr-xr-x  2 root root 120 Jan 8 19:12 .
drwxr-xr-x 32 root root 960 Jan 8 19:12 ..
srwxrwxrwx  1 root root   0 Jan 8 19:12 mysqld.sock
-rw-------  1 root root   6 Jan 8 19:12 mysqld.sock.lock

This output shows us that the permissions are incorrect – the root user owns the files. In this case, we need to set the right permissions:

chown -R mysql:mysql /var/run/mysqld/
chmod 755 /var/run/mysqld/

Once the permissions are set, restart the MySQL service and try to connect again to the MySQL console.

MySQL Configuration File

If you are still not able to connect to the MySQL console, or in other words your MySQL client can’t connect to a local server, then you should check the MySQL configuration file usually located at /etc/mysql/mysql.conf.d/mysqld.cnf – other locations for this include /etc/mysql/my.cnf, or even /etc/my.cnf. Find where your configuration file is and open it using your preferred text editor.

Look for the socket variable and make sure to put the full path of the socket file. If there is no socket variable, add it to your file like so:

socket = /var/run/mysqld/mysqld.sock

Make sure the permissions for that folder are set correctly as well. Save the file, close it and restart the MySQL service. Your MySQL client should be able to connect to your local server.

If none of this is solving the issue and if you have a managed Linux support plan with us, you can ask our support team to help you with your MySQL service. We are available 24/7 and are experts in system configuration, including with MySQL. We will be able to help you with the configuration of MySQL as well as any other issues you’re having with your server.

The post How to Fix MySQL “Can’t connect to local server” appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-fix-mysql-cant-connect-to-local-server/feed/ 0
How to Fix Themes Not Installing on WordPress https://linuxhostsupport.com/blog/how-to-fix-themes-not-installing-on-wordpress/ https://linuxhostsupport.com/blog/how-to-fix-themes-not-installing-on-wordpress/#respond Fri, 15 Mar 2024 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=2055 Finding the right theme for your WordPress website can take some time. Once you found the right WordPress theme, installing the WordPress theme is often easy and straightforward. However, sometimes you may face some problems or errors and the WordPress theme can’t be installed. You don’t want to look for another theme again and this […]

The post How to Fix Themes Not Installing on WordPress appeared first on LinuxHostSupport.

]]>
Finding the right theme for your WordPress website can take some time. Once you found the right WordPress theme, installing the WordPress theme is often easy and straightforward.

However, sometimes you may face some problems or errors and the WordPress theme can’t be installed. You don’t want to look for another theme again and this theme was perfect for your website. You are in luck – join us in this guide to help you fix the WordPress theme not installing problem on your website.

There are a few different ways that this problem can be solved, so please try and check each one. Odds are something here will fix your problem.

Your uploaded theme file exceeds the maximum file size

Let’s say you downloaded the theme that you want to install, and you navigate to Appearance -> Theme -> Add New Theme and you upload your theme.

Then you receive the following error message:

The uploaded file exceeds the upload_max_filesize directive in php.ini

Based on the error message, your PHP configuration resticts file uploads to a size that is smaller than the theme you tried to upload. Just like the error suggests, to fix the problem you’ll need to increase the upload_max_filesize value. Once that’s done, you can upload the theme, and it’ll likely work.

How to increase max file upload size for PHP in cPanel

If you have WHM & cPanel, you can log in to your cPanel account and click on “MultiPHP INI Editor” and select the WordPress domain in the Select Location drop-down menu. Then you can increase the “upload_max_filesize” value to be higher than the size of the WordPress theme that you are uploading. For example, if your theme is 50 megabytes in size, we recommend setting it to something like 75 megabytes.

How to increase max file upload size for PHP using php.ini

In case you don’t have WHM & cPanel, you should change the upload_max_filesize value in the php.ini file. You can find the php.ini file by creating a new file phpinfo.php in the DocumentRoot of your WordPress website with the following content inside.

<?php

phpinfo( );

?>

Then go ahead and save this file and navigate to https://your-domain.com/phpinfo.php in your favorite browser and you can find the location of the php.ini file in the section “Loaded Configuration File“.

Then open the php.ini file in the location where it is found and change upload_max_filesize from 25M for example to a larger number – one that is larger than the theme you want to upload. Save the file and exit. Restart your web server.

Also, make sure to delete the phpinfo.php file from your web server as revealing information about your environment invites attackers to find ways into your server through vulnerabilities.

Your PHP memory limit is too low

Another error that you may face is exhausting the memory with the following error message in your PHP log:

Fatal error: Allowed memory size of X bytes exhausted.

Same as in the previous example, you should increase the PHP memory limit from cPanel or by finding the php.ini file on your server and increasing the value for the “memory_limit” variable.

You can change the memory limit from cPanel by logging in to your cPanel account and navigating to the “MultiPHP INI Editor” and selecting the WordPress domain in the Select Location drop-down menu, then you can change the “memory_limit” value.

If you are not using cPanel you can find the php.ini file by creating a phpinfo.php file that will show you the php.ini location on your server. Then adjust your memory_limit variable from the default 128M to a larger number, such as 256M or 512M. Make sure to restart your web server.

“Installation Failed: Could Not Create Directory” Error

Two scenarios may cause this error. Your server has run out of disk space, or your cPanel or DirectAdmin account has reached the disk quota. In some extreme cases, if your server has too many files, you may reach the inodes limit on your server. Inodes are used to identify unique files and folders – it’s possible to run out of numbers even without running out of disk space.

To fix this error you should delete some old or unused files to free up some space/inodes, or upgrade your hosting plan.

Lack of permissions or ownership by the web server

Another problem that you can face is your directory or files might have incorrect permissions or ownership.

You can change the file and directory permissions of the WordPress directory using FTP or SFTP through your FTP client, such as FileZilla. This is a free application for Windows, macOS and Linux that lets you remotely connect to your server.

You can select the WordPress DocumentRoot, righ-click on it and select File permissions…

Then you can set 755 in the numeric value field > select recurse into subdirectories > apply to directories only and click ok.

Again you can repeat the same procedure right-click on the DocumentRoot, select File permissions… and set 644 in the numeric value field > select recurse into subdirectories > apply to files only and click ok.

To change the file permissions from your terminal you can navigate inside the WordPress website directory and run the following commands.

find . -type f -exec chmod 644 {} +
find . -type d -exec chmod 755 {} +

This will set the correct permissions for your WordPress files and directories.

You may also need to change the ownership of the files and directories to your web server’s user. Depending on what Linux distribution and web server you’re using, this user is named differently. It could be www-data, nginx, or apache to name a few.

To set the ownership of your WordPress installation, let’s say your WordPress is installed at the directory /var/www/html/wordpress/. To change the ownership of the entire WordPress installation to your web server user (in our example it is www-data), you can do that like so:

chown -R www-data:www-data /var/www/html/wordpress

With that, your web server should now be able to access all WordPress files and folders properly.

Incompatible plugins

Sometimes plugin compatibility may be the issue when you are installing a new theme. It may cause a conflict and you won’t be able to install the new theme. This is especially possible if your theme depends on some plugins to function properly. You can test this by installing some WordPress plugin compatibility checker or disabling all the plugins one by one to check which plugin is causing the issue.

Some of the themes may have requirements that you can check before installing. This may include incompatibility with certain plugins, which PHP versions and WordPress versions can be used.

Parse or Syntax Error with your theme

Another problem that you might encounter when installing a new WordPress theme is when you try to install some custom theme in WordPress, and you receive a syntax error. It’ll usually say something about “parse error” and “syntax error”. In this case, there’s a code issue within the theme itself. You should contact the theme developer or check the theme code for any syntax errors in the code.

What about child themes?

Installing child themes works in the same way as installing parent themes. You just need to ensure you keep the parent theme of your child theme installed. If you see any errors with the child theme but not with the parent theme, it’s possible that it is a permissions issue, in which case you can scroll up and try to fix your permissions again.

Conclusion

By trying each of these solutions, you shouldn’t have any issues with themes not installing on WordPress. If you still have trouble, however, get in touch with our managed server support team and we’ll make sure your themes can be installed, or we’ll at the very least tell you exactly why it’s not possible to install your theme.

The post How to Fix Themes Not Installing on WordPress appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-fix-themes-not-installing-on-wordpress/feed/ 0
How to Check and Change the Time Zone on Linux https://linuxhostsupport.com/blog/how-to-check-and-change-the-time-zone-on-linux/ https://linuxhostsupport.com/blog/how-to-check-and-change-the-time-zone-on-linux/#respond Thu, 15 Feb 2024 18:30:00 +0000 https://linuxhostsupport.com/blog/?p=2038 Time zones are very important for the Linux system because they can affect how the system operates, as well as affecting data displayed on your website for example. In this blog post, we will explain how to check and change the time zone on your Linux server. Setting the time and date is also important […]

The post How to Check and Change the Time Zone on Linux appeared first on LinuxHostSupport.

]]>
Time zones are very important for the Linux system because they can affect how the system operates, as well as affecting data displayed on your website for example. In this blog post, we will explain how to check and change the time zone on your Linux server. Setting the time and date is also important as it involves setting the correct time zone. These settings can be easily checked and changed according to your needs.

Changing the timezone on a Linux server is a very straightforward process. Let’s get things done!

Prerequisites

  • A server running a recent version of Linux
  • User privileges: root or non-root user with sudo privileges

Update the System

Before we make any changes to our Linux system, we should always update the packages to the latest version available. To do that, execute the following command:

sudo apt-get update -y && sudo apt-get upgrade -y

If there’s a new kernel update, you’ll need to restart to load the new kernel.

Check the Time Zone

All Linux servers have some kind of time zone that is already set. To check the time zone, we need to use the timedatecl command. The timedatectl command in Linux is used for displaying the current time on your server. It displays the system time, the hardware clock, and the time zone configured on your system. There is additional info as output from this command about the status of the systemd-timesyncd.service and clock synchronization.

Let’s execute the timedatectl command and see the exact output:

root@host:~# timedatectl
               Local time: Sun 2024-01-14 15:57:57 CST
           Universal time: Sun 2024-01-14 21:57:57 UTC
                 RTC time: Sun 2024-01-14 21:57:57
                Time zone: America/Chicago (CST, -0600)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

The first line displays the local time, the second line is the Universal time, and the third line is the hardware clock (RTC, or Real Time Clock). Then the timezone is displayed, and as you can see on our system it’s set to America/Chicago CST (Central Standard Time). After that is the info about the synchronization, the network time protocol service, and the hardware clock in the local time zone, which in this case is disabled.

We can check the time zone if we execute the date command:

root@host:~# date
Sun Jan 14 16:12:14 CST 2024

There is also another way to check the time zone, and that way is by listing the following file:

ls -l /etc/localtime

You should get the following outptut:

root@host:~# ls -al /etc/localtime
lrwxrwxrwx 1 root root 35 Jan  14 16:14 /etc/localtime -> /usr/share/zoneinfo/America/Chicago

As you can see, the timedatectl command is easier to use and the output of that command includes more details compared to the other methods.

Change the Time Zone on Linux

In the previous step, we explained different ways for checking the time zone. Now let’s cover how to change the current time zone on Linux.

Before changing the time zone, we need to list the available time zones with the following command:

timedatectl list-timezones

You will get a long list of time zones, as listed below:

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
	.
	.
America/Anchorage
America/Anguilla
America/Antigua
America/Araguaina
America/Argentina/Buenos_Aires
America/Argentina/Catamarca
America/Argentina/ComodRivadavia
America/Argentina/Cordoba
America/Argentina/Ushuaia
	.
	.
Europe/Monaco
Europe/Moscow
Europe/Nicosia
Europe/Oslo
Europe/Paris
Europe/Podgorica
Europe/Prague
Europe/Riga
Europe/Rome
Europe/Samara
Europe/San_Marino

To change the current time zone to Europe/Monaco for example, you need to execute the following command:

timedatectl set-timezone Europe/Monaco

After executing this command, you can check the time zone to see the changes:

root@host:~# timedatectl
               Local time: Sun 2024-01-15 22:28:29 CET
           Universal time: Sun 2024-01-15 21:28:29 UTC
                 RTC time: Sun 2024-01-15 21:28:29
                Time zone: Europe/Monaco (CET, +0100)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

As you can see the time zone was successfully changed.

Another way to change the time zone is using the tzselect command:

root@host:~# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".
1) Africa
2) Americas
3) Antarctica
4) Asia
5) Atlantic Ocean
6) Australia
7) Europe
8) Indian Ocean
9) Pacific Ocean
10) coord - I want to use geographical coordinates.
11) TZ - I want to specify the timezone using the Posix TZ format.
#? 

Now, you can select the continent, ocean, and coordinates, or specify the time zone using the Posix TZ format. Let’s choose number 1 for the Africa continent. You will get a list of all countries in Africa.

Please select a country whose clocks agree with yours.
 1) Algeria		  13) Côte d'Ivoire	    25) Iceland		      37) Namibia		49) Sudan
 2) Angola		  14) Djibouti		    26) Kenya		      38) Niger			50) Tanzania
 3) Benin		  15) Egypt		    27) Lesotho		      39) Nigeria		51) Togo
 4) Botswana		  16) Equatorial Guinea	    28) Liberia		      40) Rwanda		52) Tunisia
 5) Burkina Faso	  17) Eritrea		    29) Libya		      41) Sao Tome & Principe	53) Uganda
 6) Burundi		  18) Eswatini (Swaziland)  30) Madagascar	      42) Senegal		54) Western Sahara
 7) Cameroon		  19) Ethiopia		    31) Malawi		      43) Sierra Leone		55) Zambia
 8) Central African Rep.  20) Gabon		    32) Mali		      44) Somalia		56) Zimbabwe
 9) Chad		  21) Gambia		    33) Mauritania	      45) South Africa
10) Comoros		  22) Ghana		    34) Mayotte		      46) South Sudan
11) Congo (Dem. Rep.)	  23) Guinea		    35) Morocco		      47) Spain
12) Congo (Rep.)	  24) Guinea-Bissau	    36) Mozambique	      48) St Helena
#? 

We will choose number 45 for example to change the time zone to South Africa.

The following information has been given:

	South Africa

Therefore TZ='Africa/Johannesburg' will be used.
Selected time is now:	Mon Jan 15 13:00:40 SAST 2024.
Universal Time is now:	Mon Jan 15 11:00:40 UTC 2024.
Is the above information OK?
1) Yes
2) No
#? 

After that, we can confirm by typing 1 and hitting the Enter button. You will get the following screen:

You can make this change permanent for yourself by appending the line
	TZ='Africa/Johannesburg'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Africa/Johannesburg 

You should definitely add that line to your .profile file so that your time zone is remembered when you next login:

echo "TZ='Africa/Johannesburg'; export TZ" >> ~/.profile

Congratulations! You successfully changed your time zone using two different ways.

Of course, you don’t have to spend your time on this and if you have a managed Linux support plan with us. We will help you with any aspect of your server time zones, including any app-specific time zone settings. You can simply ask our support team – they are available 24/7 and will be able to help you with your time zone as well as any additional requirements that you may have.

The post How to Check and Change the Time Zone on Linux appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-check-and-change-the-time-zone-on-linux/feed/ 0
How to Install Tar.gz on AlmaLinux 9 https://linuxhostsupport.com/blog/how-to-install-tar-gz-on-almalinux-9/ https://linuxhostsupport.com/blog/how-to-install-tar-gz-on-almalinux-9/#respond Sat, 15 Jul 2023 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=1838 If you are asking what is Tar.gz, then the tar file is an archive that contains files and folders into it, while the gz stands for the compressed file format. If you combine these two, you will get a compressed archive. The compressed archives are used on a daily basis by the system administrators, developers, […]

The post How to Install Tar.gz on AlmaLinux 9 appeared first on LinuxHostSupport.

]]>
If you are asking what is Tar.gz, then the tar file is an archive that contains files and folders into it, while the gz stands for the compressed file format. If you combine these two, you will get a compressed archive.

The compressed archives are used on a daily basis by the system administrators, developers, and regular Linux users. Compressing multiple files in one archive can simplify the process of sending that compressed file quickly.

In this blog post, we will install and show you some real-life examples of using the tar.gz format with commands. Let’s get started!

  • A server with AlmaLinux 9 as OS
  • User privileges: root or non-root user with sudo privileges

Update the System

We assume that you have a fresh installation of AlmaLinux 9 so let’s first update the system packages to their latest versions available:

sudo dnf update -y && sudo dnf upgrade -y

Tar.Gz Installation

Tar.Gz can be installed and is compatible with multiple operating systems such as MacOS, Windows and Linux. We will focus of course Linux operating system because AlmaLinux is a Linux distribution. To install tar.gz on AlmaLinux 9, execute the following command:

yum install tar gzip

Once installed, you can check the installed versions of tar and gzip using the following commands:

tar --version

gzip --version

You should get the following output:

[root@host ~]# tar --version
tar (GNU tar) 1.34
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
[root@host ~]# gzip --version
gzip 1.12
Copyright (C) 2018 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License .
There is NO WARRANTY, to the extent permitted by law.

Written by Jean-loup Gailly.

How to create Tar.gz files

Now, when the tar.gz is installed, we are going to show you how to create a tar.gz file. Let’s say that we have WordPress files and folders:

[root@host wordpress]# ll
total 228
-rw-r--r--  1 root root   405 Feb  6  2020 index.php
-rw-r--r--  1 root root 19915 Dec 31 18:06 license.txt
-rw-r--r--  1 root root  7402 Mar  4 18:52 readme.html
-rw-r--r--  1 root root  7205 Sep 16  2022 wp-activate.php
drwxr-xr-x  9 root root  4096 May 16 11:45 wp-admin
-rw-r--r--  1 root root   351 Feb  6  2020 wp-blog-header.php
-rw-r--r--  1 root root  2338 Nov  9  2021 wp-comments-post.php
-rw-r--r--  1 root root  3013 Feb 23 04:38 wp-config-sample.php
drwxr-xr-x  4 root root  4096 May 16 11:45 wp-content
-rw-r--r--  1 root root  5536 Nov 23 09:43 wp-cron.php
drwxr-xr-x 28 root root 12288 May 16 11:45 wp-includes
-rw-r--r--  1 root root  2502 Nov 26 15:01 wp-links-opml.php
-rw-r--r--  1 root root  3792 Feb 23 04:38 wp-load.php
-rw-r--r--  1 root root 49330 Feb 23 04:38 wp-login.php
-rw-r--r--  1 root root  8541 Feb  3 07:35 wp-mail.php
-rw-r--r--  1 root root 24993 Mar  1 09:05 wp-settings.php
-rw-r--r--  1 root root 34350 Sep 16  2022 wp-signup.php
-rw-r--r--  1 root root  4889 Nov 23 09:43 wp-trackback.php
-rw-r--r--  1 root root  3238 Nov 29 09:51 xmlrpc.php

We want to compress them in an archive so we can easily upload somewhere or store them locally on our system. To do that, execute the following command inside the WordPress directory:

tar -zcvf wordpress.tar.gz .

This will compress all files and folders of the current directory (That is why we are using dot in the command), and the compressed file will be inside it:

[root@host wordpress]# ll
total 22700
-rw-r--r--  1 root root      405 Feb  6  2020 index.php
-rw-r--r--  1 root root    19915 Dec 31 18:06 license.txt
-rw-r--r--  1 root root     7402 Mar  4 18:52 readme.html
-rw-r--r--  1 root root 23007861 May 19 15:06 wordpress.tar.gz
-rw-r--r--  1 root root     7205 Sep 16  2022 wp-activate.php
drwxr-xr-x  9 root root     4096 May 16 11:45 wp-admin
-rw-r--r--  1 root root      351 Feb  6  2020 wp-blog-header.php
-rw-r--r--  1 root root     2338 Nov  9  2021 wp-comments-post.php
-rw-r--r--  1 root root     3013 Feb 23 04:38 wp-config-sample.php
drwxr-xr-x  4 root root     4096 May 16 11:45 wp-content
-rw-r--r--  1 root root     5536 Nov 23 09:43 wp-cron.php
drwxr-xr-x 28 root root    12288 May 16 11:45 wp-includes
-rw-r--r--  1 root root     2502 Nov 26 15:01 wp-links-opml.php
-rw-r--r--  1 root root     3792 Feb 23 04:38 wp-load.php
-rw-r--r--  1 root root    49330 Feb 23 04:38 wp-login.php
-rw-r--r--  1 root root     8541 Feb  3 07:35 wp-mail.php
-rw-r--r--  1 root root    24993 Mar  1 09:05 wp-settings.php
-rw-r--r--  1 root root    34350 Sep 16  2022 wp-signup.php
-rw-r--r--  1 root root     4889 Nov 23 09:43 wp-trackback.php
-rw-r--r--  1 root root     3238 Nov 29 09:51 xmlrpc.php

The original WordPress directory was 72 megabytes:

[root@host html]# du -csxh wordpress/
72M     wordpress/
72M     total

Now, the compressed file is 22 megabytes which is three times smaller than the WordPress directory:

[root@host wordpress]# du -csxh wordpress.tar.gz
22M     wordpress.tar.gz
22M     total

How to Extract Tar.gz Files

To extract the compressed tar.gz archive, execute the following command:

tar -xzvf wordpress.tar.gz

You can notice now that instead of the c flag, the x flag is used, which means extract.

If you want to know more about the usage of tar, you can execute the following command:

man tar

You should get the following output:

[root@host ~]# man tar
TAR(1)                                                                     GNU TAR Manual                                                                    TAR(1)

NAME
       tar - an archiving utility

SYNOPSIS
   Traditional usage
       tar {A|c|d|r|t|u|x}[GnSkUWOmpsMBiajJzZhPlRvwo] [ARG...]

   UNIX-style usage
       tar -A [OPTIONS] ARCHIVE ARCHIVE

       tar -c [-f ARCHIVE] [OPTIONS] [FILE...]

       tar -d [-f ARCHIVE] [OPTIONS] [FILE...]

       tar -t [-f ARCHIVE] [OPTIONS] [MEMBER...]

       tar -r [-f ARCHIVE] [OPTIONS] [FILE...]

       tar -u [-f ARCHIVE] [OPTIONS] [FILE...]

       tar -x [-f ARCHIVE] [OPTIONS] [MEMBER...]
          .
          .
          .
          .
          .

That’s it. In this blog post, we explained how to install Tar.gz on AlmaLinux 9 and its usage. If you find it difficult to install and use the tar command, you can always sign up for one of our NVMe VPS plans and submit a support ticket. We are available 24/7

If you liked this post about installing Tar.gz on AlmaLinux 9, please share it with your friends on social networks or simply leave a reply below.

The post How to Install Tar.gz on AlmaLinux 9 appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-install-tar-gz-on-almalinux-9/feed/ 0
How to Install and Configure Elasticsearch on AlmaLinux https://linuxhostsupport.com/blog/how-to-install-and-configure-elasticsearch-on-almalinux/ https://linuxhostsupport.com/blog/how-to-install-and-configure-elasticsearch-on-almalinux/#comments Mon, 15 May 2023 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=1790 Elasticsearch is an open-source search engine built on the Apache Lucene library. Elasticsearch was initially released in 2010 and has become the most popular search engine application ever since. People use Elasticsearch for log analytics, full-text search, operational use cases, etc. Magento, as a well-known e-commerce application also uses Elasticsearch as its search engine. In […]

The post How to Install and Configure Elasticsearch on AlmaLinux appeared first on LinuxHostSupport.

]]>
Elasticsearch is an open-source search engine built on the Apache Lucene library. Elasticsearch was initially released in 2010 and has become the most popular search engine application ever since. People use Elasticsearch for log analytics, full-text search, operational use cases, etc.

Magento, as a well-known e-commerce application also uses Elasticsearch as its search engine. In this tutorial, we will show you how to install and configure Elasticsearch on AlmaLinux.

Prerequisites

  • An AlmaLinux VPS with at least 8GB of RAM
  • root SSH access or a regular user with sudo privileges

Step 1: Log in to your server via SSH

First, you will need to log in to your AlmaLinux 8 VPS via SSH as the root user:

ssh root@IP_Address -p Port_number

You will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the system user with sudo privileges.

You can check whether you have the proper AlmaLinux version installed on your server with the following command:

# cat /etc/almalinux-release

It will return an output like this.

AlmaLinux release 9.1 (Lime Lynx)

In this article, we are using ‘root’ to execute the shell commands. If you want to use your regular user with sudo privileges to run the commands, make sure to append ‘sudo’ in front of the commands.

Step 2: Update the system

Before starting, you have to make sure that all AlmaLinux OS packages installed on the server are up to date. You can do this by running the following commands:

# yum update
# yum upgrade

Step 3. Install Java

Elasticsearch is based on Java, so we need to install it first. We can simply run this command below to install it from the default repository.

# yum install java-11-openjdk java-11-openjdk-devel

Let’s check java version

# java --version

It will show you an output similar to this:

openjdk 11.0.18 2023-01-17 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.18.0.10-2.el9_1) (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-2.el9_1) (build 11.0.18+10-LTS, mixed mode, sharing)

Step 4. Add repository

In this step, we are going to add the Elasticsearch repository and then install it from the repository. But, there is an issue with importing the Elastic key on AlmaLinux 9, and it is expected for a workaround, you can invoke this command:

# update-crypto-policies --set LEGACY

then reboot the server

Next, create a file called elasticsearch.repo in the /etc/yum.repos.d/ directory

# nano /etc/yum.repos.d/elasticsearch.repo

Paste the following content into that file

[elasticsearch]
name=Elasticsearch repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

Save the file, then exit from the editor. Next, let’s update the packages to the latest available version.

# yum update
# yum makecache

Step 5. Install Elasticsearch

Elasticsearch is a memory-intensive application. It requires at least 8GB of RAM to run properly. And in this step, we are going to install it using the repository we added earlier in the previous step. Let’s proceed with the installation.

# yum install elasticsearch

Once installed, the elasticsearch service is not automatically running; let’s execute this command below to run Elasticsearch and enable the service.

# systemctl enable --now elasticsearch

That’s it; Elasticsearch should be up and running now we can verify it by running this command.

# systemctl status elasticsearch

The command will show you an output like this:

[root@almalinux ~]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2023-03-10 17:30:37 WIB; 54s ago
Docs: https://www.elastic.co
Main PID: 1813 (java)
Tasks: 90 (limit: 10907)
Memory: 1.2G
CPU: 57.850s
CGroup: /system.slice/elasticsearch.service
├─1813 /usr/share/elasticsearch/jdk/bin/java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=/usr/share/elasticsearch/bin/elasticsearch -Dcli.libs=lib/too>
├─1872 /usr/share/elasticsearch/jdk/bin/java -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -Djava.security.manager=allow -XX:+AlwaysPreTouch>
└─1893 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

Mar 10 17:30:08 almalinux.rosehosting.com systemd[1]: Starting Elasticsearch...
Mar 10 17:30:37 almalinux.rosehosting.com systemd[1]: Started Elasticsearch.

Step 6. Configure Elasticsearch

Elasticsearch has three main configuration files, and you can find them in /etc/elasticsearch directory.

  • elasticsearch.yml for configuring Elasticsearch itself
  • jvm.options for configuring Elasticsearch JVM settings
  • log4j2.properties for configuring Elasticsearch logging

In this step, we are going to modify the elasticsearch.yml file, and the configuration file uses YAML format.

For example, we can edit the listening IP address. By default, Elasticsearch is only accessible on localhost. We can set a different address to expose our Elasticsearch node on the network:

# nano /etc/elasticsearch/elasticsearch.yml

Find this line

#network.host: 192.168.0.1

Uncomment it and modify the IP address. Let’s change it to 0.0.0.0.

network.host: 0.0.0.0

We can also modify the port, it is port 9200 by default, and we can change it to any port we like.

#http.port: 9200

Uncomment and modify the port like this:

http.port: 9222

Save the file, then exit from the editor. Next, restart elasticsearch service.

# systemctl restart elasticsearch

Please note that Elasticsearch uses two ports to listen to external TCP traffic. Port 9200 is used for all API calls over HTTP. This includes search and aggregations and anything else that uses an HTTP request. Port 9300 is a custom binary protocol used for communications between nodes in a cluster.

Congratulations! You have successfully installed Elasticsearch on AlmaLinux 9.

If you are one of our web hosting customers and use our managed Linux Hosting, you don’t have to follow this tutorial and install Elasticsearch on AlmaLinux 9 yourself, our Linux admins will set up and configure an Elasticsearch VPS for you. They are available 24×7 and will take care of your request immediately, and all you need to do is to submit a ticket. We can also help you configure the more complex setup, like configuring Elasticsearch on your Magento website.

PS. If you liked this post, please share it with your friends on social networks or simply leave a reply below. Thanks.

The post How to Install and Configure Elasticsearch on AlmaLinux appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-install-and-configure-elasticsearch-on-almalinux/feed/ 2
How To Install Apache Spark on AlmaLinux 9 https://linuxhostsupport.com/blog/how-to-install-apache-spark-on-almalinux-9/ https://linuxhostsupport.com/blog/how-to-install-apache-spark-on-almalinux-9/#respond Sat, 15 Apr 2023 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=1777 In this tutorial, we are going to explain in step-by-step detail how to install Apache Spark on AlmaLinux 9 OS. Apache Spark is an open-source unified analytics engine used for data processing large amounts of data. This software stores data in memory and performs the operations very fast using SQL query languages. Apache Spark is […]

The post How To Install Apache Spark on AlmaLinux 9 appeared first on LinuxHostSupport.

]]>
In this tutorial, we are going to explain in step-by-step detail how to install Apache Spark on AlmaLinux 9 OS.

Apache Spark is an open-source unified analytics engine used for data processing large amounts of data. This software stores data in memory and performs the operations very fast using SQL query languages. Apache Spark is written in Scala language and is compatible with multiple operating systems such as macOS, Windows, and Linux of course.

Installing Apache Spark and running it as a service is a straightforward process and may take up to 10 minutes. Let’s get things done.

Prerequisites

  • Fresh installation of AlmaLinux 9 as OS
  • User privileges: root or non-root user with sudo privileges

Step 1. Update the System

Before we install Apache Spark we need to update the system packages to the latest version available.

sudo dnf update -y && sudo dnf upgrade -y

Step 2. Install Java

The application programming interface is written in Java so we need to install Java with the following command:

sudo dnf install java-11-openjdk -y

After the installation you can check the installed Java version with the following command:

java -version

You should get the following output:

[root@vps ~]# java -version
openjdk version "11.0.18" 2023-01-17 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.18.0.10-2.el9_1) (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-2.el9_1) (build 11.0.18+10-LTS, mixed mode, sharing)

Step 3. Install Apache Spark

We can not install Apache Spark with the command since it is not included in the default repository of AlmaLinux 9. We need to download it manually and extract it in a directory on the server. To do that execute the following commands:

cd /home

curl -O https://www.apache.org/dyn/closer.lua/spark/spark-3.3.2/spark-3.3.2-bin-hadoop3.tgz

gunzip -c spark-3.2.3-bin-hadoop3.2.tgz | tar xvf -

rm spark-3.2.3-bin-hadoop3.2.tgz

mv spark-3.2.3-bin-hadoop3.2/ spark/ 

Step 4. Create System User

We need to create a system user for Apache Spark. To do that execute the following command:

 useradd useradd sparkuser

Once, created you need to set the right permissions of the Apache Spark document root:

chown -R sparkuser:sparkuser /home/spark

Step 5. Create Service files

Now, we need to create two separate services for Apache Spark. Those services are master and slave services required for Apache Spark to work efficiently. We will start with the master service:

Create the master service file first:

touch /etc/systemd/system/spark-master.service

Open the file with your favorite editor and paste the following lines of codes:

[Unit]
Description=Apache Spark Master
After=network.target

[Service]
Type=forking
User=sparkuser
Group=sparkuser
ExecStart=/home/spark/sbin/start-master.sh
ExecStop=/home/spark/sbin/stop-master.sh

[Install]
WantedBy=multi-user.target

Now, create the slave service file.

touch /etc/systemd/system/spark-slave.service

Open the file with your favorite editor and paste the following lines of codes:

[Unit]
Description=Apache Spark Slave
After=network.target

[Service]
Type=forking
User=sparkuser
Group=sparkuser
ExecStart=/home/spark/sbin/start-slave.sh spark://127.0.0.1:7077
ExecStop=/home/spark/sbin/stop-slave.sh

[Install]
WantedBy=multi-user.target

Once, the files are created reload the daemon and start the services:

sudo systemctl daemon-reload

sudo systemctl start spark-master

sudo systemctl start spark-slave

To check the status of the master service execute the following command:

sudo systemctl status spark-master

You should receive the following output:

[root@host spark]# sudo systemctl status spark-master
● spark-master.service - Apache Spark Master
     Loaded: loaded (/etc/systemd/system/spark-master.service; disabled; vendor preset: disabled)
     Active: active (running) since Sat 2023-02-25 05:45:47 CST; 48s ago
    Process: 1274 ExecStart=/home/spark/sbin/start-master.sh (code=exited, status=0/SUCCESS)
   Main PID: 1286 (java)
      Tasks: 34 (limit: 24796)
     Memory: 242.9M
        CPU: 11.958s
     CGroup: /system.slice/spark-master.service
             └─1286 /usr/lib/jvm/java-11-openjdk-11.0.18.0.10-2.el9_1.x86_64/bin/java -cp "/home/spark/conf/:/home/spark/jars/*" -Xmx1g org.apache.spark.deploy.master.

To check the status of the slave service execute the following command:

sudo systemctl status spark-slave

You should receive the following output:

[root@host spark]# sudo systemctl status spark-slave
● spark-slave.service - Apache Spark Slave
     Loaded: loaded (/etc/systemd/system/spark-slave.service; disabled; vendor preset: disabled)
     Active: active (running) since Sat 2023-02-25 05:45:54 CST; 2min 31s ago
    Process: 1350 ExecStart=/home/spark/sbin/start-slave.sh spark://127.0.0.1:7077 (code=exited, status=0/SUCCESS)
   Main PID: 1363 (java)
      Tasks: 33 (limit: 24796)
     Memory: 178.2M
        CPU: 11.086s
     CGroup: /system.slice/spark-slave.service
             └─1363 /usr/lib/jvm/java-11-openjdk-11.0.18.0.10-2.el9_1.x86_64/bin/java -cp "/home/spark/conf/:/home/spark/jars/*" -Xmx1g org.apache.spark.deploy.worker.

That’s it. Now you can access the Apache Spark service on the following URL: http://YourServerIPAddress:8080.

Congratulations! You successfully installed and configured the Apache Spark service on AlmaLinux 9. If you find any difficulties installing this software and service, you can contact our support. All you need to do is to sign up for one of our NVMe VPS plans and submit a support ticket. We are available 24/7.

The post How To Install Apache Spark on AlmaLinux 9 appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-install-apache-spark-on-almalinux-9/feed/ 0
How To Install ERPNext on AlmaLinux https://linuxhostsupport.com/blog/how-to-install-erpnext-on-almalinux/ https://linuxhostsupport.com/blog/how-to-install-erpnext-on-almalinux/#respond Thu, 30 Mar 2023 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=1771 In this tutorial, we are going to explain in step-by-step detail how to install ERPNext on AlmaLinux OS. ERPNext or Enterprise Resource Planning is an open-source integrated software solution that collects and organizes business information. ERPNext is built on the Frappe Framework in Python and Javascript that stores the data in the MySQL database server. […]

The post How To Install ERPNext on AlmaLinux appeared first on LinuxHostSupport.

]]>
In this tutorial, we are going to explain in step-by-step detail how to install ERPNext on AlmaLinux OS.

ERPNext or Enterprise Resource Planning is an open-source integrated software solution that collects and organizes business information. ERPNext is built on the Frappe Framework in Python and Javascript that stores the data in the MySQL database server. The framework also uses Nginx as a web server and Redis cache. It is important to know that ERPNext requires only a clean server and has a configuration that needs to be installed from scratch. In this tutorial, we are going to use AlmaLinux 8.5 OS.

Installing ERPNext on AlmaLinux OS can take up to 1 hour. Let’s get things done!

Prerequisites

  • A VPS with at least 4GB of RAM (Our NVMe 4 VPS plan)
  • Fresh install of AlmaLinux 8 as OS
  • Valid domain pointed to the servers IP address
  • User privileges: root or non-root user with sudo privileges

Step 1. Update the System

We need to update the system packages to their latest version available before installation of ERPNext

sudo dnf update -y && sudo dnf upgrade -y

Step 2. Install Dependencies

To install the required dependencies, execute the following command:

yum groupinstall "Development Tools" -y
yum install epel-release gcc make git openssl-devel zlib-devel bzip2-devel libffi-devel xz-devel redis -y

After installation of the required dependencies, start and enable the Redis service.

sudo systemctl start redis && sudo systemctl enable redis

Step 3. Install Python

The latest version of ERPNext requires python version 3.10. To install the Python 3.10 version, execute the following commands:

cd /opt

wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tar.xz

tar -xvf Python-3.10.0.tar.xz

rm Python-3.10.0.tar.xz

cd Python-3.10.0

./configure --enable-optimizations && make altinstall

After installation, make a symbolic link

ln -s /usr/local/bin/python3.10 /usr/bin/python3

Check the installed version with the following command: python3 -V

You should receive the following output:

[root@host Python-3.10.0]# python3 -V
Python 3.10.0

If there was already a symbolic link, just remove it with the following command:

rm -f /usr/bin/python3

Now, install pip3 and wheel dependencies with the newly installed Python3.10 version:

python3 -m pip install --upgrade pip setuptools wheel

Step 4. Install the MariaDB database server

Next, we need to install the MariaDB database server. To do that, execute the following command:

sudo yum install -y  mariadb mariadb-server

Start and enable the mariadb.service with the following commands:

sudo systemctl start mariadb && sudo systemctl enable mariadb

Check the status of the mariadb.service

sudo systemctl status mariadb

You should receive the following output:

[root@host]# sudo systemctl status mariadb
● mariadb.service - MariaDB 10.3 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2023-02-10 03:59:54 CST; 20s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 47326 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 30 (limit: 23666)
   Memory: 87.4M
   CGroup: /system.slice/mariadb.service
           └─47326 /usr/libexec/mysqld --basedir=/usr

Feb 10 03:59:50 host.test.vps systemd[1]: Starting MariaDB 10.3 database server...
Feb 10 03:59:50 host.test.vps mysql-prepare-db-dir[47223]: Initializing MariaDB database
Feb 10 03:59:54 host.test.vps mysqld[47326]: 2023-02-10  3:59:54 0 [Note] /usr/libexec/mysqld (mysqld 10.3.35-MariaDB) starting as process 47326 ...
Feb 10 03:59:54 host.test.vps systemd[1]: Started MariaDB 10.3 database server.

We must secure the database instance and set MySQL root password:

mysql_secure_installation

Follow the steps to secure the database:

Enter current password for root (enter for none): Hit Enter

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!

Remove anonymous users? [Y/n] Y

Disallow root login remotely? [Y/n] Y

Remove test database and access to it? [Y/n] Y

Reload privilege tables now? [Y/n] Y

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Save the MySQL root password since you will need it while installing ERPNext.

Next, we need to add the lines of code below in /etc/my.cnf file:

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]

default-character-set = utf8mb4

After adding these lines, restart the MariaDB service:

sudo systemctl restart mariadb

Step 5. Install NodeJS

ERPNext’s latest version, 14, requires a newer NodeJS version, such as NodeJS 16. To install nodejs execute the following command:

yum module list nodejs 

yum module enable nodejs:16

yum install nodejs -y

After installation, check the Node and NPM versions with the following command:

node -v && npm -v

You should get the following output:

[root@host]# node -v && npm -v
v16.18.1
8.19.2

After nodejs installation, we will install Yarn:

npm install -g yarn

Check the installed Yarn version with the yarn -v command:

[root@host]# yarn -v
1.22.19

Step 6. Install ERPNext

Finally, we are at the last step of the tutorial, and that step is the installation of ERPNext.

First, create an ERPNext user, add to the wheel group, and set a password.

sudo useradd -m erpnext -G wheel

sudo passwd erpnext

Changing password for user erpnext.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Switch to the erpnext user.

su - erpnext

Go into the /home directory of the erpnext user:

cd /home/erpnext/

Install the Frappe bench version 14 with the following command:

pip3 install --user frappe-bench

bench init frappe-bench --frappe-branch version-14

After the successful installation of the bench, you will receive the following output:

frappe/dist/js/
├─ bootstrap-4-web.bundle.22U72DEL.js                       1.73 Kb
├─ controls.bundle.RQCO7PK6.js                              1228.26 Kb
├─ data_import_tools.bundle.ZHGGYJ52.js                     106.10 Kb
├─ desk.bundle.VYQDF5SY.js                                  1414.14 Kb
├─ dialog.bundle.X36Y7A7S.js                                53.07 Kb
├─ form.bundle.6OYSHLE3.js                                  153.69 Kb
├─ frappe-web.bundle.W6O5MTCM.js                            949.60 Kb
├─ libs.bundle.YZMCKPNH.js                                  574.13 Kb
├─ list.bundle.RERWMHEV.js                                  185.53 Kb
├─ logtypes.bundle.7STJ7YLS.js                              0.73 Kb
├─ recorder.bundle.5AOEUOFD.js                              179.54 Kb
├─ report.bundle.IQ4SSISM.js                                170.93 Kb
├─ user_profile_controller.bundle.YR6XHZRM.js               11.35 Kb
├─ video_player.bundle.UO3KNN5D.js                          120.59 Kb
├─ web_form.bundle.75LN4HKD.js                              1562.54 Kb
├─ print_format_builder.bundle.KP4FAW42.js                  170.39 Kb
├─ build_events.bundle.L2HAVD4K.js                          11.62 Kb
└─ kanban_board.bundle.VCVKXCPT.js                          27.42 Kb

frappe/dist/css/
├─ desk.bundle.MBTR4LD7.css                                 547.98 Kb
├─ email.bundle.D7YLNAJF.css                                4.02 Kb
├─ login.bundle.6T5NJHU5.css                                24.88 Kb
├─ print.bundle.N3SFSER3.css                                196.28 Kb
├─ print_format.bundle.JH7UBL6H.css                         178.93 Kb
├─ report.bundle.HWLJLFER.css                               5.36 Kb
├─ web_form.bundle.YDYF7I73.css                             14.73 Kb
└─ website.bundle.IPR4YLHZ.css                              422.09 Kb

frappe/dist/css-rtl/
├─ desk.bundle.PZAWYDHE.css                                 548.23 Kb
├─ email.bundle.HU2YKLCX.css                                4.02 Kb
├─ login.bundle.FLH267FT.css                                24.88 Kb
├─ print.bundle.ALDGUYEF.css                                196.43 Kb
├─ print_format.bundle.3QFLLY7D.css                         179.05 Kb
├─ report.bundle.LY72JI7U.css                               5.35 Kb
├─ web_form.bundle.L26SZB7K.css                             14.72 Kb
└─ website.bundle.355E5L7G.css                              422.24 Kb

DONE  Total Build Time: 41.861s
Done in 45.98s.
SUCCESS: Bench frappe-bench initialized

Next is to create the website:

cd frappe-bench

bench new-site YourDomainName

The installation will ask for the MySQL root password, and you will need to set up a password for the administrator</b login user.

[erpnext@host frappe-bench]$ bench new-site YourWebsiteName
MySQL root password:
Updating DocTypes for frappe        : [========================================] 100%
Updating country info               : [========================================] 100%
Set Administrator password:
Re-enter Administrator password:
*** Scheduler is disabled ***

Enable the scheduler:

bench --site YourDomainName enable-scheduler

Once the scheduler is enabled, we need to get the ERPNext app and install it with the following commands:

bench get-app erpnext --branch version-14

bench --site YourDomainName  install-app erpnext

Step 7. Setup ERPNext in Production Mode

Now, we can install the bench in production mode with the following substeps:

pip3 install frappe-bench

Next, we will install Nginx and Supervisor:

sudo yum install nginx supervisor -y

After installation, open the /etc/nginx/nginx.conf file and change the Nginx user from root to erpnext.

user erpnext;

Save the file, close it, and start both services:

sudo systemctl start nginx && sudo systemctl enable nginx

sudo systemctl start supervisord && sudo systemctl enable supervisord

Once the services are enabled, create the symbolic links for Nginx, Supervisor, and Python3.10 again:

sudo ln -s `pwd`/config/supervisor.conf /etc/supervisord.d/frappe-bench.ini

sudo ln -s `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe-bench.conf

sudo rm /usr/bin/python3

sudo ln -s /usr/local/bin/python3.10 /usr/bin/python3

Once the symbolic links are set, setup nginx and supervisor with the following commands:

bench setup supervisor

bench setup nginx

You should get the following output:

Site YourWebsiteDomain assigned port: 80

The last thing is to restart the services:

sudo systemctl restart supervisord

sudo systemctl restart nginx

sudo supervisorctl start all

Now, you can access your website at http://YourWebsiteDomain using administrator as username and the password you set above.

That’s it. You successfully installed and configured ERPNext 14 on AlmaLinux 8 OS in production mode. If you find this setup difficult, you can always contact our technical support and they will help you immediately. You just need to sign up for one of our NVMe VPS hosting plans with >= 4GB of RAM and submit a support ticket.

If you liked this about installing ERPNext on AlmaLinux, please share it with your friends on social networks or simply leave a reply below.

The post How To Install ERPNext on AlmaLinux appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-install-erpnext-on-almalinux/feed/ 0
How to Install Docker CE on AlmaLinux https://linuxhostsupport.com/blog/how-to-install-docker-ce-on-almalinux/ https://linuxhostsupport.com/blog/how-to-install-docker-ce-on-almalinux/#respond Wed, 15 Mar 2023 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=1768 Docker Community Edition (CE) is a free, open-source, and community-supported version of the Docker platform. Docker CE provides all the essential features to build, ship, and run container applications. It is designed for developers who are just starting out with containerization, as well as for small-scale development and testing environments. Docker CE includes the Docker […]

The post How to Install Docker CE on AlmaLinux appeared first on LinuxHostSupport.

]]>
Docker Community Edition (CE) is a free, open-source, and community-supported version of the Docker platform. Docker CE provides all the essential features to build, ship, and run container applications. It is designed for developers who are just starting out with containerization, as well as for small-scale development and testing environments.

Docker CE includes the Docker Engine, a lightweight runtime and packaging tool, and Docker CLI, a command-line interface for interacting with the Docker Engine. With Docker CE, developers can quickly build, package, and deploy their applications as containers, making it easier to run the same application across multiple environments, such as development, testing, and production.

In the following tutorial, we will show you how to install Docker CE on AlmaLinux server.

Step 1: Log in to the Server & Update the Server OS Packages

First, log in to your AlmaLinux  server via SSH as the root user:

# ssh root@IP_Address -p Port_number

You will need to replace ‘IP_Address‘ and ‘Port_number‘ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the admin account username if necessary.

Before starting, you have to make sure that all AlmaLinux packages installed on the server are up to date. You can do this by running the following command:

# dnf update

Step 2. Install Docker CE and Docker Compose

By default, the latest Docker CE package is unavailable in the AlmaLinux default repository, so you must add the Docker CE official repository to your server.

To add a Docker CE repository to your AlmaLinux system, run the following command:

# dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

Update the package index by running the following command:

# dnf update

You can check the added repo, including others of your system, using the command:

# dnf repolist -v

Now that the Docker repository has been added to your system, you can continue to install Docker CE:

# dnf install docker-ce docker-ce-cli containerd.io

Once Docker is installed, verify the installed version with the following command:

# docker --version

You should get the following output:

Docker version 23.0.1, build a5ee5b1

Start the Docker CE service by running the following command:

# systemctl start docker

Enable the Docker service to start automatically at boot time by running the following command:

# systemctl enable docker

Verify the service is up and running with the following command:

# systemctl status docker

You should see a similar output with information about Docker being active:

● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
     Active: active (running) since Fri 2023-02-17 15:36:29 CET; 1min 9s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 49178 (dockerd)
      Tasks: 7
     Memory: 30.6M
        CPU: 160ms
     CGroup: /system.slice/docker.service
             └─49178 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Step 3. Run Docker without root

This step is optional, but if you prefer the ability to run Docker as your current user, add your account to the docker group with this command:

# usermod -aG docker $USER

You need to reboot your system for those changes to take effect.

# reboot

Step 4. Running Docker Containers

Now that you have installed Docker CE on AlmaLinux and set up your user account to run Docker commands, you can run Docker containers.

To run a Docker container, you need to have a Docker image. A Docker image is a pre-built environment for running an application.

Run the following command to pull a Docker image from the Docker Hub repository:

# docker pull hello-world

Note: Replace “hello-world” with the name of the Docker image you want to pull.

Run the following command to start a Docker container:

# docker run -it hello-world

The output should be similar to this:

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

You can see your locally available images by using the docker images command.

# docker images

If you want to see the container information, you can use the following command:

# docker ps -a

The output should be similar to this:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
519a0de94621 hello-world "/hello" 7 minutes ago Exited (0) 7 minutes ago gracious_hamilton

In this tutorial, we learned how to install Docker CE on your AlmaLinux server and the basics of using it.

Of course, you don’t have to spend your time and follow this article to install Docker CE on AlmaLinux if you have an active AlmaLinux VPS Hosting service with us, in which case you can ask our expert Linux admins to install Docker CE for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post about installing Docker CE on AlmaLinux, please share it with your friends on social networks or leave a reply below.

The post How to Install Docker CE on AlmaLinux appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-install-docker-ce-on-almalinux/feed/ 0
5 most Used dig Commands in Linux With Examples  https://linuxhostsupport.com/blog/5-most-used-dig-commands-in-linux-with-examples/ https://linuxhostsupport.com/blog/5-most-used-dig-commands-in-linux-with-examples/#respond Wed, 15 Feb 2023 18:30:00 +0000 https://linuxhostsupport.com/blog/?p=1761 The DIG command offers a vast amount of functionalities and different options. In this guide, we’ll learn more about some of the most important functionalities for DNS troubleshooting. What is the DIG command? DIG command (Domain Information Groper command) is a tool with a basic command-line interface that serves for making different DNS (domain name […]

The post 5 most Used dig Commands in Linux With Examples  appeared first on LinuxHostSupport.

]]>
The DIG command offers a vast amount of functionalities and different options. In this guide, we’ll learn more about some of the most important functionalities for DNS troubleshooting.

What is the DIG command?

DIG command (Domain Information Groper command) is a tool with a basic command-line interface that serves for making different DNS (domain name system) queries. You can use the DIG command to:

– Check all of the available DNS records or individual DNS records
– Diagnose the name servers of your domain.
– Trace IP addresses.
– See the hostnames that correspond to an IP address.

And many other aspects that you can read directly on their manual. You can find the DIG command pre-installed on most Linux distros. Also, you can easily install it on macOS, too with brew, and get the DIG command on Windows 10 with bind9.

Top 5 most used DIG commands:

Here you have five examples of DIG command. We will use rosehostingtest.com as a hostname and 1.1.1.1. as an IP address. Feel free to try these commands with the domain and IP address you want by simply changing the text before you try.

Once you are on your terminal, we can proceed with the following commands:

1. Finding the website IP address

To do that function, everything you need to do is simply use the dig command with the domain name after it, for example:

dig rosehostingtest.com

This will return you the A record of your hostname but with a lot of details together, here is an example:

➜  ~ dig rosehostingtest.com

; <<>> DiG 9.10.6 <<>> rosehostingtest.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40154
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;rosehostingtest.com. IN A

;; ANSWER SECTION:
rosehostingtest.com. 300 IN A 104.21.51.178
rosehostingtest.com. 300 IN A 172.67.183.57

;; Query time: 53 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Tue Dec 20 12:23:50 -03 2022
;; MSG SIZE  rcvd: 80

If you want an answer with fewer details, you can add +short to your command, no matter if it’s before or after the hostname, you can use it together with your domain and it will return only the IP address:

➜  ~ dig rosehostingtest.com +short
104.21.51.178

From now on, in this guide, we’ll use the +short option so it’s less information making it more friendly to be readen.

2. Getting the NameServers from the domain.

For that usage, instead of only using the dig command, we had to add the option NS to our command. So, to get the nameservers of your domain name, you can use the following command:

➜  ~ dig rosehostingtest.com NS +short
aragorn.ns.cloudflare.com.
coco.ns.cloudflare.com.

Here you can see to which DNS the domain you are checking is pointing to.

3. Check the path of your DNS.

This option will show you the path from the root servers to the DNS zone of the hostname that you are querying. To use the trace option, you should run:

➜  ~ dig rosehostingtest.com +trace +short
NS h.root-servers.net. from server 8.8.8.8 in 44 ms.
NS b.root-servers.net. from server 8.8.8.8 in 44 ms.
NS k.root-servers.net. from server 8.8.8.8 in 44 ms.
NS m.root-servers.net. from server 8.8.8.8 in 44 ms.
NS c.root-servers.net. from server 8.8.8.8 in 44 ms.
NS a.root-servers.net. from server 8.8.8.8 in 44 ms.
NS f.root-servers.net. from server 8.8.8.8 in 44 ms.
NS j.root-servers.net. from server 8.8.8.8 in 44 ms.
NS d.root-servers.net. from server 8.8.8.8 in 44 ms.
NS i.root-servers.net. from server 8.8.8.8 in 44 ms.
NS g.root-servers.net. from server 8.8.8.8 in 44 ms.
NS e.root-servers.net. from server 8.8.8.8 in 44 ms.
NS l.root-servers.net. from server 8.8.8.8 in 44 ms.
RRSIG NS 8 0 518400 20230102050000 20221220040000 18733 . Ban8EH/5IIhAO5yzTrFjKFL/ZblByKCk1ln3kXGqwwusnoBTY6fpXY/4 bQztpIpYGEE0O0Nh6afh6O2Uk/BtFvZf1YT6t1xRFZOJJ2fQGntqnvYt VX0HLYwrGmWZiaTcRWVWezLDJ/xQrxab1FGH/09qn9UQjfkswN372vb3 feGu2vbti9I63rzKTl2wJFn95jwkTRwkgrXUfP10znzJpCj3B8ZCPtN+ cvwWWrUFu1Yj5DuOS3c0SRDrcF4YFkRQTc3Fy/kMlqAvbuDuKKmGuo+f E0+oBXFWroFPLf7wB6dbHOGxoppNokqjDN1VyAHQx0uMWnfRksMpq3RC 8u3GIw== from server 8.8.8.8 in 44 ms.
A 104.21.51.178 from server 2a06:98c1:50::ac40:2143 in 37 ms.
A 172.67.183.57 from server 2a06:98c1:50::ac40:2143 in 37 ms.
RRSIG A 13 2 300 20221221162911 20221219142911 34505 rosehostingtest.com. Nn6Pr3DT0JjfqH2yV1HlMPMIbfsFYr4Voyvb5kR6aV70cTGdrItRmi6E cIKc6eDoPWJUdoIpIuDUuDwj3wcpyA== from server 2a06:98c1:50::ac40:2143 in 37 ms.

The output will show you the route of your DNS query goes. You can check if the connection is hoping somewhere to troubleshoot your DNS problems, so you can get exactly when it’s lost.

4. Checking the entries responsible for mails.

All emails to be received by the recipient, requires the domain to have their MX records properly setup, you can check yours by using the following command:

➜  ~ dig rosehostingtest.com MX +short
31 route2.mx.cloudflare.net.
42 route1.mx.cloudflare.net.
66 route3.mx.cloudflare.net.

So in our example case, the email from the test domain is handled by Cloudflare, and any email issues or problems need to be checked directly with them.

5. Check the RDNS of an IP address.

You can easily get a reverse DNS from one ip address (this means the hostname that is associated with the ip address basically) using this dig command:

➜  ~ dig -x 1.1.1.1 +short
one.one.one.one

The hostname of the queried IP address will be available on the output.

Those are the most useful commands from the dig, but you can use more options that are available in their own manual. You can run:

man dig

dig -h

This will show ALL The options available so you can do different queries. Of course, if you have an active server and need assistance in troubleshooting your DNS servers, do not hesitate to contact us. We are available 24/7/365 to help you.

The post 5 most Used dig Commands in Linux With Examples  appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/5-most-used-dig-commands-in-linux-with-examples/feed/ 0
5 Ways to Empty or Delete a Large File in Linux https://linuxhostsupport.com/blog/5-ways-to-empty-or-delete-a-large-file-in-linux/ https://linuxhostsupport.com/blog/5-ways-to-empty-or-delete-a-large-file-in-linux/#respond Mon, 30 Jan 2023 18:30:00 +0000 https://linuxhostsupport.com/blog/?p=1755 In this article, we will go over five different ways to empty/delete a large file in Linux. You might have a file that’s gigabytes in size that you want to get rid of quickly, or you want to automate emptying a file for each iteration. Whatever the case may be, you’ll be able to easily […]

The post 5 Ways to Empty or Delete a Large File in Linux appeared first on LinuxHostSupport.

]]>
In this article, we will go over five different ways to empty/delete a large file in Linux.

You might have a file that’s gigabytes in size that you want to get rid of quickly, or you want to automate emptying a file for each iteration. Whatever the case may be, you’ll be able to easily delete or empty a file with help from this article.

We’ll be running these commands on an Ubuntu 22.04 VPS, but pretty much all of these commands should work on any modern distribution.

Prerequisites

  • A Linux VPS or a dedicated server of your choosing
  • Write access to the file or root/sudo privileges

1. Using /dev/null to empty the contents of a file

What is /dev/null?

The software device file (found in the /dev/ directory) called “null” is a file with two very simple purposes. It discards or deletes any data written to it or returns EOF (short for “end-of-file”) if you try to read its contents. In this case, we are going to read from /dev/null.

You can use the cat command (which is short for concatenate) to read the contents of /dev/null, followed by a redirection operator to redirect the output into the file we want to empty.

cat /dev/null > yourFile.ext

What this does is output the contents of /dev/null and then redirect that content into your file. The contents of your file are essentially starting with “End of file,” making it empty.

What does > do?

This redirection operator takes whatever data would’ve been printed to the console and allows you to place it into any file. Using only one > replaces the contents of the file with the data you are redirecting, and using two of them >> appends the data to the end of the file. Since we want to empty our file, we only use one > to replace the contents.

Here is a screenshot as an example.

You can see the text that says “10G” (short for ten gigabytes) changes to, say 0 (zero bytes) after our command is executed.

Unfortunately, you cannot delete a file using /dev/null as it can only do the two functions mentioned earlier.

2. Using echo to empty the contents of a file

You can use the echo command, normally designed to send data to stdout (standard output or your console) and use a redirection operator again to place the contents of your echo command into the file you want to empty.

echo > yourFile.txt

The echo command outputs a new line when no input is provided. When combining this with a redirection of the output into your file, your file gets replaced with only the new line.

This is how it looks in practice:

As you can see, the file’s contents are emptied. You might notice, however, that unlike the previous method shown, this file now has a size of 1 byte instead of 0 bytes. This is because we store a newline instead of a truly empty file. If your use case requires that the file have a size of zero bytes, then this method won’t work for you.

Additionally, you cannot delete files using the echo command. Echo can only create data, not destroy it.

3. Using a redirection operator to empty the contents of a file

You may have noticed our use of redirection operators in both methods listed above to empty the contents of a file. Instead of using commands to redirect output, we can actually take advantage of this redirection to empty our file.

> yourFile.txt

You can see in this command we are redirecting nothing! By doing this, we are taking the output of nothing and replacing the contents of our file with it.

This is what it looks like when you run the command using only redirection:

You should note that the file is emptied completely, with a file size of zero bytes. This is the easiest and fastest way to empty a file.

Once again, this method won’t work for deleting files, as it only redirects content instead of destroying it.

4. Using truncate to empty the contents of a file

This great command lets you truncate (or cut short) the content of any file easily and quickly. Interestingly, the name does not suggest it, but you can also use this command to increase the apparent size of any file too.

truncate -s 0 yourFile.txt

What this command does is execute the truncate command, the option -s 0 sets the size to zero bytes.

You can see the example below:

This command does exactly as advertised, setting the file size to 0 bytes by truncating anything past that size.

Once again, this useful tool only sets the size of files; it does not delete them.

5. Using rm or unlink to delete a file

Now that we have seen multiple ways to empty the contents of a file, it’s about time we see ways to delete the file altogether. Luckily, there are two different ways of doing so.

Delete a file with the rm command

The rm command (short for remove) does one task extremely well: removing files and directories.

rm yourFile.txt

By running this, your file will be deleted instantly.

Another option is the unlike command, which simply calls the unlink function, which removes the link to the file.

unlink yourFile.txt

If no process is using the file, then the file is deleted, and the filesystem reclaims the space.

Here are some examples detailing how they work:

The next image shows the use of unlink:

With these commands, however, the opposite issue is the case – you cannot empty the contents of the file. You can only delete the file or destroy the link to the file.

However, if you are a user of our Managed VPS hosting services, make sure to use our team of Linux experts. Not only will they give you a list of all of the large files on your system, but they can also clear their contents, delete the files, or even set up a rotation of these files to ensure their size stays small automatically.

Did this post help you empty or delete a large file on your filesystem? If so, please consider spreading the word so others can benefit from this tip. Have any other methods of emptying or deleting a file? Let us know in our comment section below!

The post 5 Ways to Empty or Delete a Large File in Linux appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/5-ways-to-empty-or-delete-a-large-file-in-linux/feed/ 0
How to Install Bagisto Ecommerce on Almalinux https://linuxhostsupport.com/blog/how-to-install-bagisto-ecommerce-on-almalinux/ https://linuxhostsupport.com/blog/how-to-install-bagisto-ecommerce-on-almalinux/#respond Sun, 15 Jan 2023 18:30:00 +0000 https://linuxhostsupport.com/blog/?p=1751 Bagisto is an open-source eCommerce platform built using Laravel framework and VueJS. The framework is very flexible and easy to use, even for non-tech users. Bagisto offers Multi-Warehouse Inventory; almost everything you need when building an eCommerce website is available in Bagisto. In this tutorial, we will show you how to install Bagisto Ecommerce on […]

The post How to Install Bagisto Ecommerce on Almalinux appeared first on LinuxHostSupport.

]]>
Bagisto is an open-source eCommerce platform built using Laravel framework and VueJS. The framework is very flexible and easy to use, even for non-tech users. Bagisto offers Multi-Warehouse Inventory; almost everything you need when building an eCommerce website is available in Bagisto. In this tutorial, we will show you how to install Bagisto Ecommerce on Almalinux.

Prerequisites

  • A server with AlmaLinux as the operating system
  • Root access or regular access with sudo privileges

Step 1. Log in to your server via SSH

First, you will need to log in to your AlmaLinux VPS via SSH as the root user:

ssh root@IP_Address -p Port_number

You will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the system user with sudo privileges.

You can check whether you have the proper AlmaLinux version installed on your server with the following command:

# cat /etc/almalinux-release

You will see an output similar to this:

[root@almalinux9 ~]# cat /etc/almalinux-release
AlmaLinux release 9.1 (Lime Lynx)

The shell commands in this article are executed using ‘root’ account. If you want to use your regular user with sudo privileges to run the commands, make sure to append ‘sudo’ in front of the commands.

Step 2. Update the system

Before starting, you have to make sure that all AlmaLinux OS packages installed on the server are up to date. You can do this by running the following commands:

# dnf update
# dnf upgrade

Step 3. Install and Configure the Web Server

In this tutorial, we are going to use Nginx as the web server. Run this command to install it.

# dnf install nginx -y

Start nginx and enable it on boot.

# systemctl enable --now nginx

Now, let’s create an nginx server block or virtual host.

# nano /etc/nginx/conf/bagisto.conf

Paste the following and make sure you replace bagisto.yourdomain.com with your actual domain or subdomain name:

server {
   listen 80;
   server_name bagisto.yourdomain.com;
   root /opt/bagisto/public;

   add_header X-Frame-Options "SAMEORIGIN";
   add_header X-Content-Type-Options "nosniff";

   index index.php;

   charset utf-8;

   location / {
      try_files $uri $uri/ /index.php?$query_string;
   }

   location = /favicon.ico { access_log off; log_not_found off; }
   location = /robots.txt { access_log off; log_not_found off; }

   error_page 404 /index.php;

   location ~ \.php$ {
      fastcgi_pass unix:/run/php-fpm/www.sock;
      fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
      include fastcgi_params;
   }

   location ~ /\.(?!well-known).* {
      deny all;
   }
}

Save the file, then exit and restart nginx.

# systemctl restart nginx

Step 4. Install MariaDB and Create a Database

In this step, we are going to install the MariaDB server from the default repository. To install the MariaDB server, execute this command:

# dnf install mariadb-server

Let’s run the MariaDB service and enable it on boot.

# systemctl enable --now mariadb

MariaDB has been successfully installed, and it is running; now we can proceed with creating a new database and a user for our Bagisto website.

# mysql

There is no password for root at the moment, so that you can log in to MySQL/MariaDB shell without one.

mysql> CREATE DATABASE bagisto;
mysql> GRANT ALL on bagisto.* to bagisto@localhost identified by 'm0d1fyth15';
mysql> FLUSH PRIVILEGES;
mysql> \q

Make sure to create a stronger database password, and replace m0d1fyth15 in the command above with a stronger password.

Step 5. Install PHP

The default version of PHP available in AlmaLinux 9 is version 8. We can use this PHP version to proceed with Bagisto installation.

Run this command to install PHP and the required extensions

# dnf install php-{bcmath,common,curl,fpm,gd,intl,mbstring,mysqlnd,soap,xml,xsl,zip,cli,devel,pear} libsodium-devel

We would also need to install Sodium, and this can be installed using PECL

# pecl install libsodium

To enable Sodium extension, we can add enable it by adding extension=sodium.so in php.ini file, run this command:

# echo "extension=sodium.so" >> /etc/php.ini

You can check and verify the installed PHP version with this command.

# php -v

It will return an output like this:

[root@almalinux9 ~]# php -v
PHP 8.0.20 (cli) (built: Jun 8 2022 00:33:06) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.20, Copyright (c) Zend Technologies
with Zend OPcache v8.0.20, Copyright (c), by Zend Technologies

Step 6. Install Composer

Composer is a package manager for the PHP programming language that can be used for managing dependencies of PHP software and required libraries.

The installation of Composer is fairly easy and straightforward. Simply download and install Composer with these commands:

# curl -sS https://getcomposer.org/installer -o composer-setup.php
# php composer-setup.php --install-dir=/usr/local/bin --filename=composer

That’s it. You have successfully installed Composer on your AlmaLinux server. To check the Composer version, you can run the following command:

# composer -V

Or

# composer --version

Step 7. Install NodeJS

For this tutorial purpose, we are going to install the latest LTS version of NodeJS. Invoke these commands to add the NodeJS repository, then install it.

# curl -sL https://rpm.nodesource.com/setup_lts.x | bash -
# dnf install nodejs -y

NodeJS has been installed, and we can verify the installation by checking the node and vpm versions.

# node -v; npm -v

You should see this output:

[root@almalinux9 ~]# node -v; npm -v
v18.12.1
8.19.2

Step 8. Install Bagisto using Composer

When running composer using the root account, we would receive a warning message. Since we are using the ‘root’ user in this tutorial to install Bagisto, we need to run this command to allow the root to run composer.

# export COMPOSER_ALLOW_SUPERUSER=1

We should be able to run the composer executable without warning. Next, go to /opt; we will install Bagisto in /opt/bagisto

# cd /opt

Execute the command below to start downloading Bagisto.

# composer create-project bagisto/bagisto

Now, we need to modify the .env file to proceed with the installation.

# nano /opt/bagisto/.env

Make sure to edit the followings:

APP_URL=http://localhost
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
DB_PREFIX=

You need to use the MySQL database credentials we created earlier. It should look like this:

APP_URL=http://bagisto.yourdomain.com
DB_DATABASE=bagisto
DB_USERNAME=bagisto
DB_PASSWORD=m0d1fyth15
DB_PREFIX=bgs_

Save the changes, then exit from the editor. Now, we can start the installation.

# cd bagisto
# php artisan bagisto:install

The command above will install Bagisto, and you will see an output similar to this:

Congratulations!
The installation has been finished and you can now use Bagisto.
Go to http://bagisto.yourdomain.com/admin and authenticate with:
Email: admin@example.com
Password: admin123

You can use a web browser and navigate to http://bagisto.yourdomain.com/admin now.

Once logged in, you will be brought to the dashboard.

Step 9. Install SSL/TLS Certificate

This step is optional but highly recommended to complete. This step will walk you through SSL installation from Let’s Encrypt using certbot.

# dnf install certbot python3-certbot-nginx

Prior to generating a new SSL certificate for your bagisto.yourdomain.com, make sure that the domain/subdomain DNS A record is already pointing to your server IP address. If there is an issue when generating a free SSL certificate, most likely, the DNS update is not fully propagated.

# certbot

You will get an output like this; you need to answer the prompts.

[root@almalinux9 bagisto]# certbot

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): you@yourdomain.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: n
Account registered.

Which names would you like to activate HTTPS for?
We recommend selecting either all domains, or all domains in a VirtualHost/server block.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: bagisto.yourdomain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1
Requesting a certificate for bagisto.yourdomain.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/bagisto.yourdomain.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/bagisto.yourdomain.com/privkey.pem
This certificate expires on 2023-03-04.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for bagisto.yourdomain.com to /etc/nginx/conf.d/bagisto.yourdomain.com.conf
Congratulations! You have successfully enabled HTTPS on https://bagisto.yourdomain.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
* Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

That’s it! You have learned how to install Bagisto Ecommerce on Almalinux. Your bagisto website should be accessible at https://bagisto.yourdomain.com.

Of course, you don’t have to install Bagisto Ecommerce on Almalinux if you use one of our Django VPS Hosting services. You can simply ask our expert Linux admins to install Bagisto Ecommerce on Almalinux VPS for you. They are available 24/7 and will take care of your request immediately.

PS. If you liked this post on how to install Bagisto Ecommerce on Almalinux, please share it with your friends on the social networks using the buttons below or simply leave a reply in the comments sections. Thanks.

The post How to Install Bagisto Ecommerce on Almalinux appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-install-bagisto-ecommerce-on-almalinux/feed/ 0
How to Install CouchDB on AlmaLinux https://linuxhostsupport.com/blog/how-to-install-couchdb-on-almalinux/ https://linuxhostsupport.com/blog/how-to-install-couchdb-on-almalinux/#respond Thu, 15 Dec 2022 18:30:00 +0000 https://linuxhostsupport.com/blog/?p=1735 Apache CouchDB is a free yet reliable non-relational or NoSQL database engine. It is written in Erlang language and natively supports data in JSON format. The data can be accessed and queried via the HTTP protocol, making it easier and more scalable than traditional SQL relational databases like MySQL. CouchDB also offers replication capability and […]

The post How to Install CouchDB on AlmaLinux appeared first on LinuxHostSupport.

]]>
Apache CouchDB is a free yet reliable non-relational or NoSQL database engine. It is written in Erlang language and natively supports data in JSON format. The data can be accessed and queried via the HTTP protocol, making it easier and more scalable than traditional SQL relational databases like MySQL. CouchDB also offers replication capability and provides high availability access. This tutorial will show you how to install CouchDB on AlmaLinux.

Prerequisites

  • An AlmaLinux VPS
  • SSH access with root privileges

Step 1: Log in to your server via SSH

First, you will need to log in to your AlmaLinux VPS via SSH as the root user:

ssh root@IP_Address -p Port_number

You will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the system user with sudo privileges.

You can check whether you have the proper AlmaLinux version installed on your server with the following command:

# cat /etc/redhat-release

You will get an output similar to this:

AlmaLinux release 8.7 (Stone Smilodon)

We use ‘root’ in this article when running the shell commands. If you want to use your regular user with sudo privileges to run the commands, make sure to append ‘sudo’ in front of the commands.

Step 2: Update the System

Before starting, you have to make sure that all AlmaLinux OS packages installed on the server are up to date. You can do this by running the following commands:

# dnf update

Step 3. Install CouchDB

In this step, we will install CouchDB from its default repository. First, we need to install yum-utils package on our AlmaLinux:

# dnf install -y yum-utils

Now you can download and enable the CouchDB repository on your server with the following command:

# yum-config-manager --add-repo https://couchdb.apache.org/repo/couchdb.repo

Then, let’s update our local package index again with this command:

# dnf update

You will be prompted to add the GPG key, and you need to press Y to continue.

Next, use the command below to install CouchDB:

# dnf install -y couchdb

That’s it all, and Apache CouchDB has been successfully installed on your server.

Step 4. Configure CouchDB

In this step, we will configure CouchDB to run on all available IP addresses instead of the default 127.0.0.1 and give a password.

Let’s open the configuration file in /opt/couchdb/etc/local.ini

# nano /opt/couchdb/etc/local.ini

Find the [chttpd] section the uncomment the port and bind address. In the default configuration file, CouchDB is set to listen on 127.0.0.1. You can change it to 0.0.0.0, which means it listens on all interfaces. We can also change it to our specific IP address. So, let’s edit these lines:

[chttpd]
#port = 5984
#bind_address = 127.0.0.1

to

[chttpd]
port = 5984
bind_address = 0.0.0.0

Still, in the same file, scroll down and find the [admins] section. In this section, we can modify our CouchDB user and password.

Change these lines

[admins]
;admin = mysecretpassword

to

[admins]
admin = m0d1fyth15

Save the changes and exit from the file editor. Please make a note about your password because once the CouchDB service is running, the password you specified in the configuration file will be hashed.

Next, we can start and enable it to run upon reboot on your AlmaLinux 8 with the following command:

# systemctl enable couchdb
# systemctl start couchdb

CouchDB is now up and running. We can verify this by checking its status.

# systemctl status couchdb

The command above will give you an output like this:

● couchdb.service - Apache CouchDB
Loaded: loaded (/usr/lib/systemd/system/couchdb.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2022-11-15 20:22:16 CST; 19min ago
Main PID: 6493 (beam.smp)
Tasks: 37 (limit: 11384)
Memory: 47.0M
CGroup: /system.slice/couchdb.service
├─6493 /opt/couchdb/bin/../erts-11.2.2.13/bin/beam.smp -K true -A 16 -Bd -- -root /opt/couchdb/bin/.. -progname couchdb -- -home /opt/couchdb -- -boot /opt/couchdb/bin/../re>
├─6505 /opt/couchdb/bin/../erts-11.2.2.13/bin/epmd -daemon
└─6524 erl_child_setup 65536

Nov 15 20:22:16 almalinux.rosehosting.com systemd[1]: Started Apache CouchDB.

Step 5. Access CouchDB

CouchDB is now running, and we can start working on it. We can use CLI (Command Line Interface) to manage our CouchDB databases, or we can also use the GUI. You can navigate to http://YOUR_IP_ADDRESS/_utils/ and then log in using the username and password you specified earlier in the previous step if you prefer to use its GUI.

Enter the username and password. Then you will be brought to the CouchDB dashboard.

You will see no databases in the dashboard because we have not created one. You can now start working and using CouchDB, like creating a database, creating a cluster, or even database replication.

That’s it! You have successfully installed CouchDB on AlmaLinux

If you are one of our web hosting customers and use our managed Linux Hosting, you don’t have to follow this tutorial and install CouchDB on AlmaLinux yourself; our Linux admins will set up and configure a CouchDB VPS for you. They are available 24×7 and will take care of your request immediately, and all you need to do is to submit a ticket.

PS. If you liked this post, please share it with your friends on social networks or simply leave a reply below. Thanks.

The post How to Install CouchDB on AlmaLinux appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-install-couchdb-on-almalinux/feed/ 0
10 Useful cron Commands in Linux With Examples https://linuxhostsupport.com/blog/10-useful-cron-commands-in-linux-with-examples/ https://linuxhostsupport.com/blog/10-useful-cron-commands-in-linux-with-examples/#respond Tue, 15 Nov 2022 18:30:00 +0000 https://linuxhostsupport.com/blog/?p=1730 In this tutorial, we will explain ten useful cron commands in Linux with examples. The cron command is used for scheduling tasks to be executed in a specific period, like a month, day, hour, minute, or even seconds. The cron uses a table of tabs called crontabs which have a list of commands that need […]

The post 10 Useful cron Commands in Linux With Examples appeared first on LinuxHostSupport.

]]>
In this tutorial, we will explain ten useful cron commands in Linux with examples.

The cron command is used for scheduling tasks to be executed in a specific period, like a month, day, hour, minute, or even seconds. The cron uses a table of tabs called crontabs which have a list of commands that need to be executed with their times respectively. These cron commands are used by system administrators mostly, to make their work easier and be sure not to forget to execute something during a specific period of their work.

In this tutorial, we are going to use Ubuntu 20.04, but you can choose any Linux distro you want. Let’s get started!

Prerequisites

  • Fresh install of Ubuntu 20.04 OS
  • User privileges: root or non-root user with sudo privileges

Update the System

Before we start with the ten useful cron commands, we need to update the system packages to the latest versions available.

sudo apt update -y && sudo apt upgrade -y

Once the system is updated, we are ready to show you the basic cron commands in Linux.

1. Manage crond service

To check the status of the crond service, execute the following command:

systemctl status cron.service

You should receive the following output:

root@host:~# systemctl status cron.service
● cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-08-08 23:57:40 CEST; 1 weeks 3 days ago
       Docs: man:cron(8)
   Main PID: 583 (cron)
      Tasks: 1 (limit: 4611)
     Memory: 11.7M
     CGroup: /system.slice/cron.service
             └─583 /usr/sbin/cron -f

For starting, stopping, and restarting the cron service, you can use the following commands respectively:

systemctl start cron.service

systemctl stop cron.service

systemctl restart cron.service

2. List the jobs

To list the jobs for the current user, execute the following command:

crontab -l

The output should look similar to this because we do not have cron jobs set yet:

root@host:/var/www/html# crontab -l
no crontab for root

3. Create your first cron job

To create your first cron job execute the following command:

crontab -e

After executing this command, the file will be opened, and you can paste the following lines of code:

1 0 * * *   root cd /var/www/html && /usr/bin/sh script.sh

Save the file and close it. If you execute the command crontab -l, you will get this:

root@host:/var/www/html# crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
1 0 * * *   cd /var/www/html && /usr/bin/sh script.sh

4. Schedule a job every 10 minutes

To schedule a job to run every 10 minutes, add the following lines with the crontab -e command:

*/10 * * * * root cd /var/www/html && /usr/bin/sh script.sh

This cron will call the script every 10 minutes.

5. Schedule a job every hour

To schedule a cron job to run every hour, add the following lines with the crontab -e command:

0 * * * * root cd /var/www/html && /usr/bin/sh script.sh

6. Schedule a job every day at 10:00 AM

Now, we will show you a different way to schedule a cron job. Open the file /etc/crontab. You should see the following lines of code:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

Now to add the cron job to execute every day at 10:00 AM, just add the following line at the bottom of the file, save it and close it.

0 0 * * * root cd /var/www/html && /usr/bin/sh script.sh

7. Schedule a job At 12:00 AM, only on Friday

To schedule this job, open the /etc/crontab file and paste the following command:

0 0 * * FRI root cd /var/www/html && /usr/bin/sh script.sh

8. Schedule a job for a daily backup

To schedule a daily backup, for example, with some script that will execute commands to generate a daily backup, you do not have to specify intervals. You just need to place the script to the /etc/cron.daily directory on your server:

9. Understanding the cron directories

In the previous example, we explained how to enable daily backup by putting some script into it. What if we want our script to be executed hourly, weekly, or monthly? Do not worry about that. Just execute ls -al /etc/cron and hit tab in your terminal server:

root@host:/var/www/html# ll /etc/cron
cron.d/       cron.daily/   cron.hourly/  cron.monthly/ crontab       cron.weekly/

As you can see, there are directories for different periods where you can place your scripts, which will be executed automatically.

10. Man command for cron

If you want to learn more about the cron, you must execute man cron in your terminal. You should receive complete documentation about the cron command:

CRON(8)                                                               System Manager's Manual                                                               CRON(8)

NAME
       cron - daemon to execute scheduled commands (Vixie Cron)

SYNOPSIS
       cron [-f] [-l] [-L loglevel]

DESCRIPTION
       cron is started automatically from /etc/init.d on entering multi-user runlevels.

OPTIONS
       -f      Stay in foreground mode, don't daemonize.

       -l      Enable  LSB  compliant  names  for  /etc/cron.d  files.   This  setting,  however,  does  not  affect  the  parsing of files under /etc/cron.hourly,
               /etc/cron.daily, /etc/cron.weekly or /etc/cron.monthly.

       -n      Include the FQDN in the subject when sending mails.  By default, cron will abbreviate the hostname.

       -L loglevel
               Tell cron what to log about jobs (errors are logged regardless of this value) as the sum of the following values:

That’s it. You just learned how to set up cron jobs on your own in different ways. If you find this difficult and you want some specific cron at a specific time, just contact our technical support, and they will do the rest. We are available 24/7.

If you liked this post about ten useful cron commands in Linux with examples, please share it with your friends on social networks or simply leave a reply below.

The post 10 Useful cron Commands in Linux With Examples appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/10-useful-cron-commands-in-linux-with-examples/feed/ 0
5 Most Used Echo Commands in Linux With Examples https://linuxhostsupport.com/blog/5-most-used-echo-commands-in-linux-with-examples/ https://linuxhostsupport.com/blog/5-most-used-echo-commands-in-linux-with-examples/#comments Sun, 30 Oct 2022 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=1723 This blog post will show you the five most used echo commands in Linux with examples. The echo command in Linux is a command that outputs the strings passed to its arguments. The echo command is supported on various Linux distributions such as Ubuntu, CentOS, Debian, and other OS like Windows. This command is most […]

The post 5 Most Used Echo Commands in Linux With Examples appeared first on LinuxHostSupport.

]]>
This blog post will show you the five most used echo commands in Linux with examples.

The echo command in Linux is a command that outputs the strings passed to its arguments. The echo command is supported on various Linux distributions such as Ubuntu, CentOS, Debian, and other OS like Windows. This command is most used in shell scripts and batch files to output status text to the screen.

In this tutorial, we will use the latest Ubuntu 22.04 OS, but you can choose any Linux distro per your choice. Let’s get started!

Prerequisites

  • A server with Ubuntu 22.04 OS
  • User privileges: root or non-root user with sudo privileges

Update the System

It is recommended to update the system packages to the latest versions available.

sudo apt update -y && sudo apt upgrade -y

Once the system is updated, we are ready to show you the five most used echo commands in Linux.

Syntax of the echo command

The syntax of the echo command is the following:

echo [option(s)] [string(s)]

The echo command is simple and is being executed with the main word echo using some options and strings next to it.

1. Display simple line to standard output

To display a single line as text on standard output, execute the following echo command with the string:

echo This blog post will teach you about the echo command.

This is how looks the output of this command:

root@host:~# echo This blog post will teach you about the echo command.
This blog post will teach you about the echo command.

2. Print Files and Folders

The echo command can be used to print all files and folders in some directory as an alternative to the ls -al command for listing.

echo *
This is the output of the command above:
root@host:/# echo *
bin boot core dev etc home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sbin snap srv sys tmp usr var

3. Redirect operator to output text in a file

The following command will redirect the output in the file instead of the standard output on the command line.

echo * > outputfile.txt

To check the content of the file, execute the cat outputfile.txt command, and you should receive the same as in the previous paragraph:

root@host:/# cat outputfile.txt
bin boot core dev etc home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sbin snap srv sys tmp usr var

4. Removing Text Spacing

To remove the text spacing in some lines, execute the following command with option -b:

echo -e "This \bblog \bpost \bwill \bhelp \byou \bwith \understanding \bthe \becho \bcommand"

You should get the following output:

root@host:/# echo -e "This \bblog \bpost \bwill \bhelp \byou \bwith \bunderstanding \bthe \becho \bcommand"
Thisblogpostwillhelpyouwithunderstaingtheechocommand

5. Displaying the Text in Multiple Lines

To display the text in multiple lines, execute the following command with option \n.

echo -e "This \nblog \npost \nwill \nhelp \nyou \nwith \nunderstanding \nthe \necho \ncommand"

You should get the following output:

root@host:/# echo -e "This \nblog \npost \nwill \nhelp \nyou \nwith \nunderstaing \nthe \necho \ncommand"
This
blog
post
will
help
you
with
understanding
the
echo
command

These were the most used echo commands on a daily basis by system administrators and other Linux users. If you want to know more about the echo command, just execute the command man echo, and you will get a complete definition of echo and its usage:

root@host:/# man echo
ECHO(1)                                                                    User Commands                                                                    ECHO(1)

NAME
       echo - display a line of text

SYNOPSIS
       echo [SHORT-OPTION]... [STRING]...
       echo LONG-OPTION

DESCRIPTION
       Echo the STRING(s) to standard output.

       -n     do not output the trailing newline

       -e     enable interpretation of backslash escapes

       -E     disable interpretation of backslash escapes (default)

       --help display this help and exit

       --version
              output version information and exit

       If -e is in effect, the following sequences are recognized:

       .
       .
       .
       .
       .

That’s it. You just learned to use the echo command on Linux with examples. Of course, if you need some help with this, you just need to sign up for one of our NVMe plans and submit a support ticket. Our admins will start work on your request immediately. We are available 24/7.

If you liked this post about the five most used echo commands in Linux with examples, please share it with your friends on social networks or simply leave a reply below.

The post 5 Most Used Echo Commands in Linux With Examples appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/5-most-used-echo-commands-in-linux-with-examples/feed/ 1
5 Most Used Touch Commands in Linux With Examples https://linuxhostsupport.com/blog/5-most-used-touch-commands-in-linux-with-examples/ https://linuxhostsupport.com/blog/5-most-used-touch-commands-in-linux-with-examples/#comments Sat, 15 Oct 2022 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=1720 In this tutorial, we are going to show you the most used touch commands in Linux with examples. The touch command is a standard command in Linux operating system used on daily basis by the system administrators, developers, and other users familiar with the Linux command line. With the touch command, we can easily create […]

The post 5 Most Used Touch Commands in Linux With Examples appeared first on LinuxHostSupport.

]]>
In this tutorial, we are going to show you the most used touch commands in Linux with examples.

The touch command is a standard command in Linux operating system used on daily basis by the system administrators, developers, and other users familiar with the Linux command line. With the touch command, we can easily create files, empty files, modify files, timestamps and etc.

In this tutorial, we will execute the touch commands on Ubuntu 20.04 OS, but you can choose any Linux distro. Le’ts get started!

Prerequisites

  • A server with Ubuntu 20.04 OS
  • User privileges: root or non-root user with sudo privileges

Update the System

If you have a fresh installation of Ubuntu 20.04, it is recommended to update the system packages to the latest versions available.

sudo apt update -y && sudo apt upgrade -y

Once the system is updated, we are ready to show you the basic touch commands in Linux.

1. Create a File

To create an empty zero byte file, execute the following command:

touch file.txt

You can check the size of the file:

-rw-r--r--  1 root root 0 Aug 14 22:58 file.txt

2. Change only the access time

To change only the access time to the file, you need to execute the following command:

touch -a file.txt

This command will update the last access modification time and will create the file if it does not exists.

3. Use the timestamp of another file

Sometimes we need to set the same timestamp to a file from another file. To do that, execute the following command:

touch -r file1.txt file2.txt

This command will update the timestamp of file2.txt with the timestamp of file file1.txt.

4. Create a file with a specific timestamp

To create a file and specify the time, you need to execute the following command:

touch -t 202208181118.34 file-time

The command above will create the file-time with a timestamp on August 18, 2022, at 11:18:34 AM.

5. Creating Multiple files

In the above examples, we were creating only a single file. Sometimes we need multiple files to be created. To do that, we can simply use the touch command with multiple file names:

touch file1.txt file2.txt file3.txt

This command will create three files at once:

-rw-r--r--  1 root root    0 Aug 15 11:51 file1.txt
-rw-r--r--  1 root root    0 Aug 15 11:51 file2.txt
-rw-r--r--  1 root root    0 Aug 15 11:51 file3.txt

Learn more about the touch command

In the previous paragraphs, we covered the most used touch commands. There is a brief explanation of the touch command along with options in Linux. To learn more about the touch command, execute the man touch command in your terminal.

man touch

You should get the following output:

TOUCH(1)                                                                   User Commands                                                                   TOUCH(1)

NAME
       touch - change file timestamps

SYNOPSIS
       touch [OPTION]... FILE...

DESCRIPTION
       Update the access and modification times of each FILE to the current time.

       A FILE argument that does not exist is created empty, unless -c or -h is supplied.

       A FILE argument string of - is handled specially and causes touch to change the times of the file associated with standard output.

       Mandatory arguments to long options are mandatory for short options too.

       -a     change only the access time

       -c, --no-create
              do not create any files

       -d, --date=STRING
              parse STRING and use it instead of current time

       -f     (ignored)

       -h, --no-dereference
              affect each symbolic link instead of any referenced file (useful only on systems that can change the timestamps of a symlink)

       -m     change only the modification time

       -r, --reference=FILE
              use this file's times instead of current time

       -t STAMP
              use [[CC]YY]MMDDhhmm[.ss] instead of current time

       --time=WORD
              change the specified time: WORD is access, atime, or use: equivalent to -a WORD is modify or mtime: equivalent to -m

       --help display this help and exit

Congratulations! You learned the basic touch commands with examples applicable to every Linux distribution.

You learned how to create one file or multiple files with specific timestamps. If you find it challenging to understand the touch command and you are not able to manage the files on your server, you can simply contact our epic technical support, and they will do the rest. You only need to sign up for one of our NVMe VPS plans and submit a support ticket. We are available 24/7.

If you liked this post about the five most used touch commands in Linux, please share it with your friends on social networks or simply leave a reply below. Thanks.

The post 5 Most Used Touch Commands in Linux With Examples appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/5-most-used-touch-commands-in-linux-with-examples/feed/ 1