linux Archives - CloudMinister

How to install and configure Linux Malware Detect (LMD) on Centos Web Panel(CWP) 7 with alert?

Linux Malware Detect(LMD) is a malware detector and scanner for Linux, designed for shared hosting environments. LMD is released under GNU GPLV2 license, it can be installed on cPanel, WHM and Linux environments with together other detection tools such as ClamAV. 

CWP doesn’t provide LMD service in it’s free version, it asks to take CWP pro for LMD service. You can install it from the terminal and scan for malware present in your server.

Prerequisite

CWP

Terminal access

Root user (If not use sudo)

ClamAV

Install Linux Malware Detect (LMD)

Linux Malware Detect is not available in CentOS or Epel repository, you need to install it manually from source, by using the following command:

First go inside tmp directory,

# cd /tmp

Now download and extract it from the source with the help of wget command:

# wget http://www.rfxn.com/downloads/maldetect-current.tar.gz

# tar -xzvf maldetect-current.tar.gz

After downloaded go inside the maldetect directory and run the install script with the following command:

# cd maldetect-*

# ./install.sh

Now make a symlink of the maldet command in the /bin/maldet

# ln -s /usr/local/maldetect/maldet /bin/maldet

# hash -r

Configure Linux Malware Detect (LMD)

LMD has been installed into the /usr/local/maldet/ directory. Open the directory and edit the configuration file conf.maldet with vi editor:

# cd /usr/local/maldetect/

# vi conf.maldet

In this file, edit the following lines to enable various feature and alerts
Enable email alert by changing the value to 1 :

email_alert=”1”
Type your email address :
email_alert=”your@domain.com

We will use the ClamAV clamscan binary as default scan engine because it provides a high-performance scan on large file sets. Change value to 1:
scan_clamscan=”1”
Next, enable quarantining to move malware to the quarantine automatically during the scan process. Chang value to 1:
quarantine_hits=”1”
Change value to 1, to enable clean based malware injections.
quarantine_clean=”1”

Save and exit, you can also change other values based on your requirement.

Testing Linux Malware Detect(LMD)

For testing LMD manual scan with the maldet command, you will use the maldet command to scan the web directory ‘/var/www/html’.
Download some malware file with the help of following commands in web root directory:
# cd /var/www/html
# wget http://www.eicar.org/download/eicar.com.txt
# wget http://www.eicar.org/download/eicar_com.zip

Next, scan the web root directory with the maldet command:

# maldet -a /var/www/html

Check the scan report with the following command:

# maldet –report 18882——-*

Other LMD Command

To ensure Maldet is up-to-date, run the command below:

# maldet -u


You can see the details of the option available by running the following command:

# maldet -h


Perform a scan for specific file extension only:

# maldet -a /var/www/html*.php

Get a list of all reports:

# maldet -e list


Restore files from the quarantine directory.

# maldet -s SCANID

Enable monitoring of a directory.
# maldet -m /var/www/html

CONCLUSION-

The above configuration will show how to configure Linux Malware Detect in CWP and scan for malware data in your server.

How to create Automated Backup for website files with shell script?

Backup

With the help of shell script and crontab you can take automated backup in server with the help of following the document.

Archive the content

Backing up your files using tar is very simple using the following command: 

# tar -cvpzf /backup/backupfilename.tar.gz /data/directory

A real example would be backing up the HTML folder for your website, my case:

# tar -cvpzf /backup/file_name.tar.gz /var/www/html

Tar command explained

tar = Tape archive

c = Create

v = Verbose mode will print all files that are archived.

p = Preserving files and directory permissions.

z = This will tell tar that to compress the files.

f = It allows tar to get the file name.

Now create backup script with the help of vi editor.

Create Backup Script

Now let’s add tar command in a bash script to make this backup process automatic. Also it is good to add some dynamic value in the name to make sure there is no overwriting of backup files. 

E.g. Create the file using the vi editor and paste below script.

# vi /backup.sh

Paste the following script and change your details.

#!/bin/bash

TIME=`date +%b-%d-%y`                                                # This Command will read the date.

BK_FILENAME=backup-domainname.com-$TIME.tar.gz    # The filename including the date.

SOURCE=/var/www/html                                                 # Source backup folder.

DESCT=/backup                                                           # Destination of backup file.

tar -czf $DESCT/$BK_FILENAME $SOURCE

Note: The only risk that can occur is to get out of disk memory if the source folder is big, but you can configure it by removing file after 30 days or any number of days with the help of the find command.

find /backup -type f -name ‘*.gz’ -mtime +15 -exec rm {} \;

Automation

In Linux, we can easily use the cron jobs in order to schedule task and perform the above backup task easily.                The cron jobs line has 6 parts see below explanation: Minutes Hours Day of Month Month Day of Week Command 0 to 59 0 to 23 1 to 31 1 to 12 0 to 6 Shell Command Open crontab editor utility:
#
crontab -e 

Note: the edit rules are similar with vi editor.
Paste the following text in the editor:
# M H DOM M DOW CMND
00 04 * * * /bin/bash /backup.sh
This will run the script every day at 04:00:00.
Check the rules of crontab with the help of the following command:
#
Crontab -l 

CONCLUSION

After the above configuration, you can take backup automatically and remove it in some specific period of time.

Linux/Unix

Linux is a clone of Unix operating system, it is a multi-user operating system, which can be accessed by many users at a time.

Linux Server Management

Linux server management service is a cost-effective mixture for the application-based server. Essential applications deployed on Linux servers need the right management solutions or tools. Large enterprises and end-users require robust Linux servers to manage applications for their business.

In this tutorial, you will learn the very basic Linux commands that will help you to get more familiar with the Linux command line. This will also help you to sharpen the commands line in Linux as well as also help you in enhancing your capability of getting an expert in this field.

Commands

The commands in Linux have the following syntax:

$command options arguments

 

 Bash/shell: Program that provides text-only interface.

 Terminal: A terminal window

 Command-line   : Anything that takes input

 Console: Physical instrument panel

1) $ls                           :  Used to show the folders & web files

2) $ls -a                      : List all the files and folders.

3) $ls -l                        :Used to list folders with permissions

Linux / Unix basic commands for beginners

4) $ls Do*   : Listing all the folders starting with Do also print inside files

5) $ls .*       : Listing all the files starting with (.)

 Linux / Unix basic commands for beginners

6) $ls -a       : listing all the folders and files, including hidden files

7) $cd          : To jump in the folder

8) $cd ..       : To go back to the folder.

9) $cd ../..    : To jump back to the two directories.

10) $mkdir     : To make the directory/folder

11) $mkdir -p : To make the directory/folder one to one inside in it.

Example:

Linux / Unix basic commands for beginners

12) $mkdir -vp : to make the directory and it will print the dir. created.

              Example-

 Linux / Unix basic commands for beginners

13) $touch pop : to make the new file(pop) in folder

14) $touch grapes oranges : to make a recursive file(grapes,oranges) in a folder.

15) $mv : to move the file from source to destination.

16) $cp : to copy a file from one folder to another.

17) $rm : Delete the file or folder

18) $rm -r file name/ :  Remove the folder

19) $rm -r a b c : remove the files from the folder

20) $whereis (command name) : To find the actual path of the command.

21) $echo -e “paul nlikes necho”

Linux / Unix basic commands for beginners

  • It will print each char in next line

22) $ x=paul

23) $ echo  “ $x nlikes necho”

 Linux / Unix basic commands for beginners

  • It will also print the x value

Find command

Find command is used to search and locate the list of files and directories based on conditions you specify for files that match the arguments. Find can be used in a variety of conditions like you can find files by permissions, users, groups, file type, date, size, and other possible criteria

 

Note: (.) is for the current directory

24.) $ find . -name file_name / dir._name

    Used to find the file/directory in the current directory

Linux / Unix basic commands for beginners

25.) $ find . -type f/d -empty

    To find the empty dir/ file     ** f for file & d for directory

Linux / Unix basic commands for beginners
Linux / Unix basic commands for beginners

26) $ find . -mtime  -1

   To find the file/directory which is made within one day

Linux / Unix basic commands for beginners

27) $ find . -mtime  +1

   To find the file/dir. which was made 1 day ago

28) $find . -mmin 1

   To find the file/dir. which was made 1 min ago/  To find the file/dir which is made within 1 min.

Linux / Unix basic commands for beginners

 

29) $ find ./ type d/f -name file/dir

   To find the directory / file

        ** f for file and d for directory

 

30) $ find . *.extension

   To find the all file which is with the assigned extension.

        ** here there is no .jpg file available

Linux / Unix basic commands for beginners

 

31) $ find dir.name

   To show all the files and directories

Linux / Unix basic commands for beginners

32) $ find -iname “char*”

   To find all the files and dir. starting with the f* and -i not including case sensitivity

Linux / Unix basic commands for beginners

33) $ find ./ -type f/d -iname “f*”

   To find file or directory with disable case sensitivity and listing files / dir with f*

Linux / Unix basic commands for beginners

34) $ find . -size +0

   This will show the file presented in the current directory which is more than 0 mega byte.

         ** G = GB

         ** K= KB

Linux / Unix basic commands for beginners

35) $ du -sh file/dir

    It will give the size of the file or directory in KB

Vi editor

Linux / Unix basic commands for beginners

After $ vi d1 write the text by pressing (I for Insert )click→ Esc→ shift + :→ wq → Enter

Linux / Unix basic commands for beginnersLinux / Unix basic commands for beginners

GREP – Global Regular Expression Print

“It allow us to search text within files in a system”

36) $ grep [binary digit] file_name

   It will search the binary number which are inserted in the square bracket.

Linux / Unix basic commands for beginners

37) $ grep -w “string” file_name

   It will only show the valid text inserted in the inverted commas.

Linux / Unix basic commands for beginners

38) $ grep -i “string” file_name

   It is non-case sensitive command (  -i )

Linux / Unix basic commands for beginners

39) $ grep “string” file_name

   Show all the matching text.

Linux / Unix basic commands for beginners

40) $grep -win “string” file_name

   Show at which line the text resides.

Linux / Unix basic commands for beginners

41) $ grep -win -B 4 “string” file_name

  Show the 4 line before the inserted text.

Linux / Unix basic commands for beginners

Show the 2 lines above and below the text.

Linux / Unix basic commands for beginners

Show the 2 lines after the text

42) $ grep -win -A2 ‘String” d1

Linux / Unix basic commands for beginners

43) $ grep -winr “string” ./*

   [centos@localhost ~]$ grep -winr “cat” ./*

   It will show all the files and folders with the string.

AWK command (Aho, Weinberger and Kernighan)

 

It is just a scripting language used to it doesn’t require compilation time and it generates reports by processing file. It is beneficial for pattern searching and processing files.

Various programming concepts offered by AWK are:

     1) Output formatting

     2) Inbuilt variables

     3) Pattern matching

     4) String operations

     5) Arithmetic operations

Basic syntax

# awk options ‘selection _criteria {action }’ input-file > output-file

Awk assign some variables for each field.

→ $0 denotes the whole file

→ $1 denotes the first field

→ $2 denotes the second field

     And $3,$4,$5…..so on for every field.

Commands related AWK

 

44) # awk ‘{print $variable}’ file_name

   This command will print the field according to the variable

Linux / Unix basic commands for beginners

Linux / Unix basic commands for beginners
Linux / Unix basic commands for beginners

45) # awk –version

   We can also check the version of the awk.

         # awk -F: ‘{print $variable}’ filename

This will print the file without the separator (i.e. [:])

Linux / Unix basic commands for beginners

Linux / Unix basic commands for beginners

46) # echo “string” | awk ‘{$variable=”string”; print  $variable}’

    This will replace the string manish to raghav  and print the whole string.

 

Linux / Unix basic commands for beginners

47) # cat file_name | awk ‘{$variable=”string”; print $variable}’

   This command  will replace the particular string which is in field 2 and  print the whole file content.

Linux / Unix basic commands for beginners

48) # awk ‘/string/’ file_name 

   This command will show each line that contains the following word i.e.( or )

Linux / Unix basic commands for beginners

49) # awk ‘$variable==”char” {print $variable}’ file_name

   T

his will print 5th field if the field 1 value matches the value 300 in the file.

Linux / Unix basic commands for beginners

CUT command

 

The cut command basically a Unix command line utility which extracts section from each line.

Basically the cut command slices a line and extracts the text.

50) # cat -b variable file_name

     This cut command will extract the following byte (-b) from the file.

Linux / Unix basic commands for beginners
Linux / Unix basic commands for beginners

51) # cut -d ‘delimiter’ -f field/ranges/sequence file_name

   This command will show the following fields/ranges from the file

   if -d option is not used then it prints whole line:

Linux / Unix basic commands for beginners

Linux / Unix basic commands for beginners

52) # cut -c variable file_name

   This command will print each character from the file starting from 1st field.

Linux / Unix basic commands for beginners

53) # cut –complement -d “  “ -f variable file_name

   This command will print each field except the 3rd field

Linux / Unix basic commands for beginners

54) # echo field >> file_name

   This command will permanently add on the field at last into the file

Linux / Unix basic commands for beginners

55) # cut -d “ “ -fvariable file_name

    This command will show only the 3rd field from the file

Linux / Unix basic commands for beginners

SED command

 

It is also called stream editor, it is a powerful linux/unix utility tool used for text manipulation, finding, deletion, saving permanently, etc.

s: means substitute

g: means globally

56) # sed ‘s/string1/string2/g’ file_name

   This command will change the string1 to string2

Linux / Unix basic commands for beginners

57) # sed /bstring1b/string2/g’ file_name

   This will replace the exact matching word list into raghav in the file.

Linux / Unix basic commands for beginners

58) # sed ‘s/^string1/string2/g’ file_name

   This command will change the value which ends with $ sign in the file.

Linux / Unix basic commands for beginners

Deletion 

 

59) # sed ‘/word/d’ file_name

  This command will delete the particular line which consists of the particular word.

   ‘d’ denotes the delete.

Linux / Unix basic commands for beginners

Saving permanently to the file

 

60) # sed -i ‘s/char1/char2/g’ file_name

Linux / Unix basic commands for beginners

-i → use this -i ,if you want to change or modify directly to the file

        This -i can be used at the above sed commands this will permanently save every modification in the file.

 

Conclusion: By following this tutorial you will get the basic understanding of Linux commands

How to Choose the Right VPS Provider?

First, we need to know

WHAT IS VPS SERVERS? “

VPS server refers to a virtual private server that could be a distinctive hosting technology that sits nicely between many small and medium businesses.
In other words, the VPS server gives you the best out of best, effective results for the company, without cross-cutting of your pocket
VPS has its Operating system, dedicated storage, and dedicated RAM and CPU resources at an affordable price.
VPS servers emphasize the virtual machines, however running software on the physical server.
VPS hosting is where you have more than just one piece of servers from the same single dedicated server. This can be observed as renting a room in the apartment. You are utilizing resources in that single rented room for the sake of your needs.
VPS hosting is generally used by startups, online businesses, large personal sites and ideal for small businesses.
VPS hosting is great if you are growing your website, you just have to choose the plan that matches your ambition and the rest of the things will be handled by the hosting company i.e us.

How to choose the correct service plan and the provider?

There are a few more points that are very crucial that must be kept in mind.

Access governed to the root: This means that the server has full access that we can manage or configure it in our own way.

Affordable Price: Renting VPS means maximizing the server utilization as you just rent what is required to you. Having the VPS server is not enough, the good VPS provider is the one who regularly manages your pocket with more efficient resources.

Technical support: One of the positive attributes of a Virtual Private Server is you get complete control on the VPS. After all the things are to be set after the question arises for the support, not all the companies have the skills to provide the on-time support. Every client wants his work to be on time, so choose wisely the VPS provider, because the big giants in the hosting world are not able to give the nice support to his clients, but the small companies have the great ability to provide the wonderful support system. Therefore they can be a better choice as a hosting provider.

Managed or Unmanaged Plan: VPS hosting approaches with 2 types: Managed and Unmanaged.

Managed VPS hosting is a remote environment where the provider handles the setup, administration, management of the server or the platform applications. Where Unmanaged VPS is fully under the control of the customer. Here the customer has full root access and manages all security constraints, software Installations, and resource monitor.
or we can also say that fully managed vps hosting is good for the client because he need not have to worry about the technical details about the server which runs on the internet, while in self-managed VPS hosting the customer have to do worry about the because entire thing is to be managed by the client only he needs the physical server from the host.

VPS hosting vs Dedicated server hosting

VPS Hosting

how to choose the write vps provider
VPS hosting vs dedicated server hosting

VPS hosting uses virtualisation technology to provide you with dedicated (private) resources on a server with multiple vps users. It is more secure than the shared hosting, where you don’t get the dedicated server space. However it is less costly that the dedicated server hosting

Dedicated Hosting

A dedicated server is a server that’s literally dedicated to your own personal use. You’ll have rights to all of the resources of the machine, and you’ll be able to configure the hosting environment however you wish.

Conclusion:

These are all the factors that make a vital role while choosing a VPS server.

How to Choose the Right VPS Provider ?

In this we will tell you how to apply NAT setting in CWP panel

NAT is short for Network Address Translation

Why the NAT is important?

NAT is a very important aspect of firewall security. It conserves the number of public addresses used within an organisation, and it allows for stricter control of access to resources on both sides of the firewall

Like in AWS there is public and private network, so nating is enabled by default

Prerequisites: – Centos 7, user with root privileges

Step 1:- Login in CWP panel.

How to apply NAT setting in cwp panel

Step 2:- Go to CWP setting and click on Edit setting.

How to apply NAT setting in cwp panel

Step 3:- Scroll down and click on activate NAT-ed network configuration.

How to apply NAT setting in cwp panel

Step 4:- Click on save changes.

How to apply NAT setting in cwp panel

Step 5:- Go to dashboard and restart CWP services and apace service.

 How to apply NAT setting in cwp panel

Conclusion: Finally you will learn to apply NAT setting on CWP panel.

CentOS Web Panel

 A Free Web Hosting control panel designed for quick and easy management of Linux Dedicated & Linux VPS Server offers a huge number of options and features for remote server management services in its control panel package.

 

Please follow this link to see the CWP feature.

 

Installation CWP steps

Pre Requirements

– CWP supports static IP addresses. We do not support dynamic, sticky, or internal IP addresses.

– CWP does not provide an uninstaller. After you install CWP, you must reinstall the Linux VPS server to remove it.

– Only install CWP on a freshly installed operating system without any configuration changes.

System Requirement 

1. Setup Hostname

     # hostnamectl set-hostname admin.domain_name.com

2. Setup Server IP addresses

    -Setup fix ip to cwp server

3. Hardware Requirement
-32 bit operating systems require a minimum of 512 MB RAM
-64 bit operating systems require a minimum of 1024 MB RAM (recommended)
-Recommended System: 4 GB+ RAM so you would have the full functionality such as Anti-virus scan of emails.

4. Preparing server install some require packages like:-
# yum -y install wget vim
# yum -y update

5. Download cwp script file

     # wget http://centos-webpanel.com/cwp-el7-latest

6. Run cwp script

    # sh cwp-el7-latest

How to install centos web panel on CentOS 7

Note: wait for 5 to 10 min to complete the script and after copy all cwp details

7. After installation set root password to login in cwp panel using

     # passwd root

8. Open cwp panel in the browser using https://SERVER_IP:2031

How to install centos web panel on centos 7

conclusion

you can manage your all domain & website using remote server management in cwp panel with all security features.

Get started with CloudMinister Today