<?xml version="1.0"?>
<rss version="2.0"><channel><title>Others Latest Topics</title><link>https://www.alphagnu.com/forum/17-others/</link><description>Others Latest Topics</description><language>en</language><item><title>Install OpenVPN Open Source in Linux CentOS Ubuntu Debian Amazon Linux</title><link>https://www.alphagnu.com/topic/48-install-openvpn-open-source-in-linux-centos-ubuntu-debian-amazon-linux/</link><description><![CDATA[<p>
	In this tutorial we’ll learn how to install open source openvpn on linux server and run your own VPN server. This is OpenVPN script installer for Debian, Ubuntu, Fedora, CentOS and Arch Linux. This script will let you setup your own VPN server in just a few minutes.
</p>

<p>
	OpenVPN provides flexible VPN solutions to secure your data communications, whether it’s for Internet privacy, remote access for employees, securing IoT, or for networking Cloud data centers. OpenVPN Server software solution can be deployed on-premises using standard servers or virtual server, or on the cloud server.
</p>

<p>
	Why Use Our VPN?
</p>

<ul>
	<li>
		Uses the public Internet to create an economical, isolated, and secure private network
	</li>
	<li>
		Remote access to internal services increases mobile workforce productivity
	</li>
	<li>
		Reduces security risk by preventing unauthorized access to specific network resources
	</li>
	<li>
		Encryption ensures privacy on untrusted Wi-Fi and other public access networks
	</li>
	<li>
		Extends centralized unified threat management to remote networks
	</li>
</ul>

<p>
	DOWNLOAD OpenVPN Connect client from here : <strong><a href="https://openvpn.net/client/" rel="external nofollow">CLICK HERE</a></strong>
</p>

<p>
	Requirements : A vps server with ram 512 Mb will be enough, Virtualization type KVM/hyperv/vmware are recommended. Internet speed 100mbps or 1gbps.
</p>

<p>
	So lets Get started :
</p>

<p>
	Step 1 :
</p>

<p>
	Download the openvpn install script :
</p>

<pre class="ipsCode">mkdir /root/vpn
cd /root/vpn
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
chmod +x openvpn-install.sh</pre>

<p>
	<br />
	Step 2 :
</p>

<p>
	Run the installer :
</p>

<pre class="ipsCode">./openvpn-install.sh</pre>

<p>
	<br />
	Now follow the onscreen instructions, below i’ve tried to cover them most of it :
</p>

<p>
	you’ll be ask to choose the server ip (if you’ve NAT server the ip can be different) press enter :
</p>

<pre class="ipsCode">Welcome to the OpenVPN installer!
The git repository is available at: https://github.com/angristan/openvpn-install

I need to ask you a few questions before starting the setup.
You can leave the default options and just press enter if you are ok with them.

I need to know the IPv4 address of the network interface you want OpenVPN listening to.
Unless your server is behind NAT, it should be your public IPv4 address.
IP address: 123.224.555.222</pre>

<p>
	<br />
	Now it will asks for ipv6 if available hit enter by selecting y :
</p>

<pre class="ipsCode">Checking for IPv6 connectivity...

Your host appears to have IPv6 connectivity.

Do you want to enable IPv6 support (NAT)? [y/n]: y</pre>

<p>
	<br />
	Then it will ask to choose port and prompted with 3 options, I’ll choose Random by typing 3 and it will output some random port remember that port we need it later:
</p>

<pre class="ipsCode">What port do you want OpenVPN to listen to?
   1) Default: 1194
   2) Custom
   3) Random [49152-65535]
Port choice [1-3]: 3</pre>

<p>
	<br />
	Next it will prompt to select UDP or TCP protocol. I’ll recommended to use UDP by selecting 1 for faster speed :
</p>

<pre class="ipsCode">What protocol do you want OpenVPN to use?
UDP is faster. Unless it is not available, you shouldn't use TCP.
   1) UDP
   2) TCP
Protocol [1-2]: 1</pre>

<p>
	<br />
	Next it will ask you to select the DNS provider for VPN connection communication, I’ll select 9 for google dns :
</p>

<pre class="ipsCode">What DNS resolvers do you want to use with the VPN?
   1) Current system resolvers (from /etc/resolv.conf)
   2) Self-hosted DNS Resolver (Unbound)
   3) Cloudflare (Anycast: worldwide)
   4) Quad9 (Anycast: worldwide)
   5) Quad9 uncensored (Anycast: worldwide)
   6) FDN (France)
   7) DNS.WATCH (Germany)
   8) OpenDNS (Anycast: worldwide)
   9) Google (Anycast: worldwide)
   10) Yandex Basic (Russia)
   11) AdGuard DNS (Anycast: worldwide)
   12) NextDNS (Anycast: worldwide)
   13) Custom
DNS [1-12]: 9</pre>

<p>
	<br />
	Next it will ask for if you want to enable compression, its not needed hit enter by selecting n :
</p>

<pre class="ipsCode">Do you want to use compression? It is not recommended since the VORACLE attack make use of it.
Enable compression? [y/n]: n</pre>

<p>
	<br />
	Then it will ask to customize encryption, I’ll leave default settings and hit enter by selecting n :
</p>

<pre class="ipsCode">Do you want to customize encryption settings?
Unless you know what you're doing, you should stick with the default parameters provided by the script.
Note that whatever you choose, all the choices presented in the script are safe. (Unlike OpenVPN's defaults)
See https://github.com/angristan/openvpn-install#security-and-encryption to learn more.

Customize encryption settings? [y/n]: n</pre>

<p>
	<br />
	At this point you’ve completed most of needed option now you’ll be prompted to proceed by clicking any key :
</p>

<pre class="ipsCode">Okay, that was all I needed. We are ready to setup your OpenVPN server now.
You will be able to generate a client at the end of the installation.
Press any key to continue...</pre>

<p>
	<br />
	Now you can see installation is started it will take a minute or two to complete, then the script will ask you to enter the openvpn username client, I'll use alphagnuas client username:
</p>

<pre class="ipsCode">Tell me a name for the client.
The name must consist of alphanumeric character. It may also include an underscore or a dash.
Client name: alphagnu</pre>

<p>
	<br />
	Next it will ask to add password or passwordless login, I’ll choose passwordless client by choosing 1 because auto-reconnect option work with it better :
</p>

<pre class="ipsCode">Do you want to protect the configuration file with a password?
(e.g. encrypt the private key with a password)
   1) Add a passwordless client
   2) Use a password for the client
Select an option [1-2]: 1</pre>

<p>
	<br />
	thats it the script will now end and it will create client-username.ovpn in /root/vpn dir or check the path mentioned by the script , you need to download the .ovpn file to your pc and use it to connect via openvpn client download openvpn connect client from above link. Install the client and import the .ovpn file in client and connect.
</p>

<p>
	Step 3 :
</p>

<p>
	Add the openvpn port to firewall, as i asked you above to remember the openvpn port, you need to add that port to firewall UDP or TCP whatever you chosen the protocol to open list in and out
</p>

<p>
	Step 4 :
</p>

<p>
	To remove openvpn, add new user or to make changes to current user you need to run this script again :
</p>

<pre class="ipsCode">cd /root/vpn
./openvpn-install.sh</pre>

<p>
	<br />
	it will show below options :
</p>

<pre class="ipsCode">Welcome to OpenVPN-install!
The git repository is available at: https://github.com/angristan/openvpn-install

It looks like OpenVPN is already installed.

What do you want to do?
   1) Add a new user
   2) Revoke existing user
   3) Remove OpenVPN
   4) Exit</pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">48</guid><pubDate>Tue, 20 Jun 2023 15:07:14 +0000</pubDate></item><item><title>How to clear Linux RAM memory cache and free up SWAP memory</title><link>https://www.alphagnu.com/topic/61-how-to-clear-linux-ram-memory-cache-and-free-up-swap-memory/</link><description><![CDATA[<p>
	IN this tutorial I’ll show you how you can easily clear ram cache and swap memory to speed up the Linux server.
</p>

<p>
	You all are familiar with word CACHE which usually represents performance benefits like cache can improve website’s loading speed and similarly cache will improve Linux server performance too in some places. Normally cache are managed by Linux Kernel efficiently and will be cleaned overtime when not in use. Cache cleaning is necessary to refresh and free up the system memory so a new version of cache can be built by eliminating old cache. In result it will help your Server to run even faster with fresh cache.
</p>

<p>
	<strong>Let’s get started with the tutorial :</strong>
</p>

<p>
	Please note it is not recommended running Level 3 cache on regular basis, use it when you need to free up memory and cache. It is recommend to use level 1 cache clearing only.
</p>

<p>
	<strong>Here there are 3 levels of RAM cache clearing commands :</strong>
</p>

<p>
	vm.drop_caches=1 : This is will clear pagecache – recommended
</p>

<pre class="ipsCode">sync; echo 1 &gt; /proc/sys/vm/drop_caches</pre>

<p>
	<br />
	vm.drop_caches=2 : This is will clear dentries and inodes
</p>

<pre class="ipsCode">sync; echo 2 &gt; /proc/sys/vm/drop_caches</pre>

<p>
	<br />
	vm.drop_caches=3 : This is will clear pagecache, dentries and inodes i.e. all cache are cleared
</p>

<pre class="ipsCode">sync; echo 3 &gt; /proc/sys/vm/drop_caches</pre>

<p>
	<br />
	<strong>Clear Swap Memory :</strong>
</p>

<p>
	Clearing swap memory can take time depending disk speed and the size of the swap memory usage, to clear it simply run this command :
</p>

<pre class="ipsCode">swapoff -a &amp;&amp; swapon -a</pre>

<p>
	<br />
	** also don’t use cache clearing command under cron jobs, this commands should be run manually and automation is not recommended.
</p>
]]></description><guid isPermaLink="false">61</guid><pubDate>Thu, 06 Jul 2023 14:23:14 +0000</pubDate></item><item><title>How to check if your Server provider is blocking SMTP Port 25</title><link>https://www.alphagnu.com/topic/11-how-to-check-if-your-server-provider-is-blocking-smtp-port-25/</link><description><![CDATA[<p>
	In this tutorial we’ll check if SMTP port 25 is open for email sending out via Telnet on your Linux machine. Today most of the cloud provider disable the SMTP port 25 to prevent spamming issues. Remember Port 25 is needed to send emails out if it is closed you can’t send email out of the server via any ports despite it is open for you.
</p>

<p>
	Here are the steps to check the SMTP port:
</p>

<p>
	Open the Terminal or ssh on your server.
</p>

<p>
	Type the following command to install telnet if it’s not already installed:
</p>

<p>
	For centos/EL :-
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">yum install telnet</span></pre>

<p>
	<br />
	or for ubuntu/debian :-
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">apt install telnet</span></pre>

<p>
	<br />
	Type the following command and press Enter:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">telnet server.alphagnu.com 25</span></pre>

<p>
	<br />
	use server.alphagnu.com hostname for better results or replace it with remote server ip or hostname
</p>

<p>
	If the port is open, you will see a message like this:
</p>

<pre class="ipsCode">[root@server]# telnet server.alphagnu.com 25
Trying 5.161.42.110...
Connected to server.alphagnu.com.
Escape character is '^]'.
220 server.alphagnu.com</pre>

<p>
	<br />
	This means that the SMTP port 25 is open and you can send emails.
</p>

<p>
	If the port is closed or you cannot connect to the SMTP server, you will see an error message like this after 3-5 minutes of waiting:
</p>

<pre class="ipsCode">[root@cwp ~]# telnet server.alphagnu.com 25
Trying 5.161.42.110...
telnet: connect to address 5.161.42.110: Connection timed out
Trying 2a01:4ff:f0:a15::1...
telnet: connect to address 2a01:4ff:f0:a15::1: Network is unreachable</pre>

<p>
	<br />
	This means that the SMTP port 25 is closed or there is a network restriction and preventing the connection.
</p>

<p>
	If the port is closed, you may need to check your firewall settings or contact your network administrator to troubleshoot the problem.
</p>
]]></description><guid isPermaLink="false">11</guid><pubDate>Fri, 02 Jun 2023 13:57:11 +0000</pubDate></item><item><title>Enable public key authentication and login with SSH keys without Password with PUTTY-PuttyGEN</title><link>https://www.alphagnu.com/topic/56-enable-public-key-authentication-and-login-with-ssh-keys-without-password-with-putty-puttygen/</link><description><![CDATA[<p>
	SSH keys provide a more secure way of logging in compared to using a password alone. While a password can eventually be cracked with a brute-force attack, SSH keys are nearly impossible to decipher by brute force alone. With public key authentication, every computer has (i) a public and (ii) a private “key” (two mathematically-linked algorithms that are effectively impossible to crack).
</p>

<p>
	<strong><span style="font-size:18px;">Setup SSH Keys on your Windows computer/laptop using PuttyGEN</span></strong><br />
	Step 1<br />
	Download PuttyGEN from the <a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html" rel="external nofollow">Homepage website</a>.<br />
	Scroll down until you find puttygen.exe and download either 32 or 64bit version.
</p>

<p>
	Step 2<br />
	Start PuttyGEN by double clicking on its icon
</p>

<p>
	Step 3<br />
	From top menu, click on “Key” and select “SSH-2 RSA” and in the bottom right box change the number 2048 to 4096
</p>

<p>
	Step 4<br />
	Click “Generate” button
</p>

<p>
	Step 5<br />
	Move your mouse pointer around in the blank area of the Key section, below the progress bar (to generate some randomness) until the progress bar is full
</p>

<p>
	Step 6<br />
	Click the “Save public key” button &amp; choose whatever filename you’d like (some users create a folder in their computer named my_keys)
</p>

<p>
	Step 7<br />
	Click the “Save private key” button &amp; choose whatever filename you’d like
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			NOTE! Both public and private files will have to stay on your computer, do not delete them.
		</p>
	</div>
</blockquote>

<p>
	Step 8<br />
	Right-click in the text field labeled Public key for pasting into OpenSSH authorized_keys file and choose Select All, right-click again and choose Copy
</p>

<p>
	Step 9<br />
	Login to your VPS or Dedicated server
</p>

<p>
	Step 10<br />
	Run the following commands:
</p>

<pre class="ipsCode">mkdir ~/.ssh
chmod 0700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 0644 ~/.ssh/authorized_keys</pre>

<p>
	<br />
	Step 11<br />
	Paste the SSH public key which you copied in step 8 into your ~/.ssh/authorized_keys file
</p>

<p>
	<strong><span style="font-size:18px;">Lets setup Putty on your Windows OS</span></strong><br />
	Step 1<br />
	Start PuTTY by double-clicking its executable file
</p>

<p>
	Step 2<br />
	PuTTY’s initial window is the Session Category (navigate PuTTY’s various categories, along the left-hand side of the window)
</p>

<p>
	Step 3<br />
	In the Host Name field, enter the IP address of your VPS or its fully qualified domain name (FQDN)
</p>

<p>
	Step 4<br />
	Enter the port number in the Port field (for added security, consider changing your server’s SSH port to a non-standard port.
</p>

<p>
	Step 5<br />
	Along the left-hand side of the window, select the Data sub-category, under Connection
</p>

<p>
	Step 6<br />
	Specify the username that you plan on using, when logging in to the SSH server, and whose profile you’re saving, in the Auto-login username field
</p>

<p>
	Step 7<br />
	Expand the SSH sub-category, under Connection
</p>

<p>
	Step 8<br />
	Highlight the Auth sub-category and click the Browse button, on the right-hand side of the PuTTY window
</p>

<p>
	Step 9<br />
	Browse your file system and select your previously-created private key
</p>

<p>
	Step 10<br />
	Return to the Session Category and enter a name for this profile in the Saved Sessions field, e.g. user@123.456.78.9 or user@host.yourdomain.tld
</p>

<p>
	Step 11<br />
	Click the Save button
</p>

<p>
	Now you can go ahead and log in to your server and you will not be prompted for a password.
</p>

<p>
	<strong><span style="font-size:18px;">Finally let’s disable username/password login on your vps/dedicated server</span></strong><br />
	Step 1<br />
	Open /etc/ssh/sshd_config
</p>

<pre class="ipsCode">nano /etc/ssh/sshd_config</pre>

<p>
	<br />
	Step 1<br />
	Lets change both “PasswordAuthentication” and “UsePAM” options to “no”
</p>

<pre class="ipsCode">[...]
PasswordAuthentication no
[...]
UsePAM no
[...]</pre>

<p>
	<br />
	Step 2<br />
	Restart your SSH server
</p>

<pre class="ipsCode">service sshd restart</pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">56</guid><pubDate>Tue, 04 Jul 2023 01:36:02 +0000</pubDate></item><item><title>Useful CSF firewall Commands list for System Admins</title><link>https://www.alphagnu.com/topic/74-useful-csf-firewall-commands-list-for-system-admins/</link><description><![CDATA[<p>
	CSF (ConfigServer Security &amp; Firewall) is a popular firewall and security tool for Linux servers. CSF is full featured firewall which contains many features and works on Linux out of the box. Its a Stateful Packet Inspection (SPI) firewall, Login/Intrusion Detection and Security application for Linux servers.
</p>

<p>
	Here are some common commands that you can use with CSF:
</p>

<p>
	<strong>Start CSF:</strong>
</p>

<p>
	To start CSF, use the following command:
</p>

<pre class="ipsCode">csf -s</pre>

<p>
	you can also use systemctl to restart csf and lfd server 
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">systemctl start csf lfd</span></pre>

<p>
	<br />
	<strong>Stop CSF:</strong>
</p>

<p>
	To stop CSF, use the following command:
</p>

<pre class="ipsCode">csf -x</pre>

<p>
	you can also use systemctl to restart csf and lfd server <br />
	 
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">systemctl stop csf lfd</span></pre>

<p>
	<strong>Restart CSF:</strong>
</p>

<p>
	To restart CSF, use the following command:
</p>

<pre class="ipsCode">csf -r</pre>

<p>
	<br />
	you can also use systemctl to restart csf and lfd server 
</p>

<pre class="ipsCode">systemctl restart csf lfd</pre>

<p>
	<strong>Check CSF status:</strong>
</p>

<p>
	To check the status of CSF, use the following command:
</p>

<pre class="ipsCode">csf -status</pre>

<p>
	<br />
	<strong>Allow an IP address:</strong>
</p>

<p>
	To allow an IP address through the firewall, use the following command:
</p>

<pre class="ipsCode">csf -a </pre>

<p>
	<br />
	you can add the comment after the ip with space
</p>

<p>
	example :
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			csf -a 1.1.1.1 allowed by admin
		</p>
	</div>
</blockquote>

<p>
	<strong>Unblock an IP address:</strong>
</p>

<p>
	To unblock an IP address that has been blocked by CSF, use the following command:
</p>

<pre class="ipsCode">csf -dr </pre>

<p>
	<br />
	<strong>Block an IP address:</strong>
</p>

<p>
	To block an IP address, use the following command:
</p>

<pre class="ipsCode">csf -d </pre>

<p>
	<br />
	you can add the comment after the ip with space
</p>

<p>
	example :
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			csf -d 1.1.1.1 blocked by admin
		</p>
	</div>
</blockquote>

<p>
	<strong>View blocked IP addresses:</strong>
</p>

<p>
	To view a list of blocked IP addresses, use the following command:
</p>

<pre class="ipsCode">csf -g</pre>

<p>
	<br />
	to find specific ip in blocked list use below command :
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			csf -g 1.1.1.1
		</p>
	</div>
</blockquote>

<p>
	<strong>Unblock all IP addresses:</strong>
</p>

<p>
	To unblock all IP addresses that have been blocked by CSF, use the following command:
</p>

<pre class="ipsCode">csf -df</pre>

<p>
	<br />
	<strong>Check for updates to csf but do not upgrade :</strong>
</p>

<pre class="ipsCode">csf -c</pre>

<p>
	<br />
	<strong>To update CSF :</strong>
</p>

<pre class="ipsCode">csf -u</pre>

<p>
	<br />
	<strong>To Force update :</strong>
</p>

<pre class="ipsCode">csf -uf</pre>

<p>
	<br />
	<strong>Get an IP’s information country of origin &amp; hostname/ptr :</strong>
</p>

<pre class="ipsCode">csf -i IP</pre>

<p>
	usage :
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			csf -i 1.1.1.1
		</p>
	</div>
</blockquote>

<p>
	Hope this helped and you can add your own commands below in the comment to help others.
</p>
]]></description><guid isPermaLink="false">74</guid><pubDate>Sat, 05 Aug 2023 13:50:24 +0000</pubDate></item><item><title>12 Systemctl commands list for System Admins</title><link>https://www.alphagnu.com/topic/73-12-systemctl-commands-list-for-system-admins/</link><description><![CDATA[<p>
	systemctl is a command-line tool used to manage and control the systemd system and service manager in various Linux distributions. It enables administrators to manage the OS and control the status of services. Further, systemctl is useful for troubleshooting and basic performance tuning.
</p>

<p>
	Here are some Commands which need admin/root privilege
</p>

<p>
	service_name is the name of the service you want to perform the action for.
</p>

<p>
	<strong>Start a service:</strong>
</p>

<p>
	To start a service, use the following command:
</p>

<pre class="ipsCode">systemctl start service_name</pre>

<p>
	<br />
	<strong>Stop a service:</strong>
</p>

<p>
	To stop a service, use the following command:
</p>

<pre class="ipsCode">systemctl stop service_name</pre>

<p>
	<br />
	<strong>Restart a service:</strong>
</p>

<p>
	To restart a service, use the following command:
</p>

<pre class="ipsCode">systemctl restart service_name</pre>

<p>
	<br />
	<strong>Enable a service at boot:</strong>
</p>

<p>
	To enable a service to start automatically at boot, use the following command:
</p>

<pre class="ipsCode">systemctl enable service_name</pre>

<p>
	<br />
	<strong>Disable a service at boot:</strong>
</p>

<p>
	To disable a service from starting automatically at boot, use the following command:
</p>

<pre class="ipsCode">systemctl disable service_name</pre>

<p>
	<br />
	<strong>Check the status of a service:</strong>
</p>

<p>
	To check the status of a service, use the following command:
</p>

<pre class="ipsCode">systemctl status service_name</pre>

<p>
	<br />
	<strong>List all running services:</strong>
</p>

<p>
	To list all running services, use the following command:
</p>

<pre class="ipsCode">systemctl list-units --type=service --state=running</pre>

<p>
	<br />
	example :
</p>

<pre class="ipsCode">[root@cwp ~]# systemctl list-units --type=service --state=running
UNIT                     LOAD   ACTIVE SUB     DESCRIPTION
amavisd.service          loaded active running Amavis mail content checker
atd.service              loaded active running Job spooling tools
cbpolicyd.service        loaded active running CWP Policyd for Postfix
clamd.service            loaded active running clamd scanner () daemon
console-getty.service    loaded active running Console Getty
crond.service            loaded active running Command Scheduler
cwp-phpfpm.service       loaded active running The PHP FastCGI Process Manager
cwpsrv-phpfpm.service    loaded active running The PHP FastCGI Process Manager
cwpsrv.service           loaded active running CentOS Web Panel service (daemon)
dbus.service             loaded active running D-Bus System Message Bus
dovecot.service          loaded active running Dovecot IMAP/POP3 email server
getty@tty2.service       loaded active running Getty on tty2
httpd.service            loaded active running Web server Apache
lfd.service              loaded active running ConfigServer Firewall &amp; Security - lfd
mariadb.service          loaded active running MariaDB 10.11.2 database server
named.service            loaded active running Berkeley Internet Name Domain (DNS)
nginx.service            loaded active running nginx - high performance web server
opendkim.service         loaded active running DomainKeys Identified Mail (DKIM) Milter
php-fpm81.service        loaded active running The PHP FastCGI Process Manager
php-fpm82.service        loaded active running The PHP FastCGI Process Manager
postfix.service          loaded active running Postfix Mail Transport Agent
pure-ftpd.service        loaded active running Pure-FTPd FTP server
rsyslog.service          loaded active running System Logging Service
saslauthd.service        loaded active running SASL authentication daemon.
spamassassin.service     loaded active running Spamassassin daemon
sshd.service             loaded active running OpenSSH server daemon
systemd-journald.service loaded active running Journal Service
systemd-logind.service   loaded active running Login Service
systemd-udevd.service    loaded active running udev Kernel Device Manager
varnish.service          loaded active running Varnish Cache, a high-performance HTTP accelerator
xinetd.service           loaded active running Xinetd A Powerful Replacement For Inetd</pre>

<p>
	<br />
	<strong>Find a service name use grep :</strong>
</p>

<pre class="ipsCode">systemctl list-units --type=service --state=running | grep keyword</pre>

<p>
	<br />
	example :
</p>

<pre class="ipsCode">[root@server ~]# systemctl list-units --type=service --state=running | grep php
php-fpm81.service        loaded active running The PHP FastCGI Process Manager
php-fpm82.service        loaded active running The PHP FastCGI Process Manager</pre>

<p>
	<br />
	<strong>List all failed services:</strong>
</p>

<p>
	To list all running services, use the following command:
</p>

<pre class="ipsCode">systemctl list-units --type=service --state=failed</pre>

<p>
	<br />
	example :
</p>

<pre class="ipsCode">[root@cwp ~]# systemctl list-units --type=service --state=failed
  UNIT                           LOAD   ACTIVE SUB    DESCRIPTION
* systemd-sysctl.service         loaded failed failed Apply Kernel Variables
* systemd-vconsole-setup.service loaded failed failed Setup Virtual Console
* vzquota.service                loaded failed failed LSB: Start vzquota at the end of boot</pre>

<p>
	<br />
	<strong>To Stop/masking a service strictly so no one or other programs can start it :</strong>
</p>

<pre class="ipsCode">systemctl mask service_name</pre>

<p>
	<br />
	<strong>To unmasking a service and undo :</strong>
</p>

<pre class="ipsCode">systemctl unmask service_name</pre>

<p>
	<br />
	<strong>Reload systemd configuration:</strong>
</p>

<p>
	To reload the systemd configuration after changes is done or to just reload it, use the following command:
</p>

<pre class="ipsCode">systemctl daemon-reload</pre>

<p>
	<br />
	<strong>View service logs:</strong>
</p>

<p>
	To view the logs of a service, use the following command:
</p>

<pre class="ipsCode">journalctl -u service_name</pre>

<p>
	<br />
	example :
</p>

<pre class="ipsCode">[root@cwp ~]# journalctl -u httpd
-- Logs begin at Wed 2023-05-05 18:48:58 EDT, end at Sat 2023-05-06 15:20:01 EDT. --
Aug 04 04:25:14 cwp.onefinehost.com systemd[1]: Stopping Web server Apache...
Aug 04 04:25:14 cwp.onefinehost.com systemd[1]: Stopped Web server Apache.
Aug 04 04:25:14 cwp.onefinehost.com systemd[1]: Starting Web server Apache...
Aug 04 04:25:14 cwp.onefinehost.com systemd[1]: Started Web server Apache.
Aug 04 04:25:14 cwp.onefinehost.com systemd[1]: Reloading Web server Apache.
Aug 04 04:25:14 cwp.onefinehost.com systemd[1]: Reloaded Web server Apache.
Aug 04 04:25:15 cwp.onefinehost.com systemd[1]: Reloading Web server Apache.
Aug 04 04:25:15 cwp.onefinehost.com systemd[1]: Reloaded Web server Apache.
Aug 04 04:25:17 cwp.onefinehost.com systemd[1]: Stopping Web server Apache...</pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">73</guid><pubDate>Sat, 05 Aug 2023 13:43:32 +0000</pubDate></item><item><title>Disable dangerous PHP functions and improve PHP security - CWP Centos, debian, ubuntu</title><link>https://www.alphagnu.com/topic/68-disable-dangerous-php-functions-and-improve-php-security-cwp-centos-debian-ubuntu/</link><description><![CDATA[<p>
	In this tutorial we'll learn how you can disable dangerous PHP functions. Disabling dangerous PHP functions can help improve the security of your web application by preventing potential exploits and attacks. However, it's important to be cautious when disabling functions, as it may impact the functionality of your application. Only disable functions that are truly unnecessary and represent a significant security risk. Here are some steps you can take to disable dangerous PHP functions:
</p>

<p>
	Use PHP Configuration (php.ini): Many PHP functions can be disabled or restricted through the PHP configuration file (<strong>php.ini</strong>). Access to this file is usually restricted to server administrators, so you may need to contact your hosting provider or server administrator to make changes.
</p>

<p>
	<span style="font-size:16px;"><strong>Using php.ini or .user.ini :</strong></span>
</p>

<p>
	Look or add the <strong>disable_functions</strong> directive in the <strong>php.ini </strong>or in<strong> .user.ini</strong> file and list/add the functions you want to disable, separated by commas. For example:
</p>

<pre class="ipsCode">disable_functions = exec,system,passthru,popen,proc_open,shell_exec</pre>

<p>
	**you need to restart Apache or php-fpm service after you added this directive.
</p>

<p>
	<span style="font-size:16px;"><strong>Using .htaccess when using Apache php DSO - mod_php module : </strong></span>
</p>

<p>
	Use .htaccess (Apache): If you're using the Apache web server, you can also disable PHP functions via the .htaccess file in your web application's root directory. However, this method requires the "mod_php" module to be enabled, and you should have the necessary permissions to modify .htaccess.
</p>

<p>
	Add the following line to your .htaccess file to disable a function:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">php_flag disable_functions "exec, system, passthru, popen, proc_open, shell_exec"</span></pre>

<p>
	**restart Apache service after you've added this directive.
</p>

<p>
	Please note <span>: </span>Regularly update your PHP version and libraries, apply security patches to your CMS/scripts, and follow secure coding practices to build a robust and secure web application
</p>
]]></description><guid isPermaLink="false">68</guid><pubDate>Sat, 29 Jul 2023 01:28:42 +0000</pubDate></item><item><title>Check Internet Speed of the Server via Linux Command &#x2013; SpeedTest-CLI</title><link>https://www.alphagnu.com/topic/59-check-internet-speed-of-the-server-via-linux-command-%E2%80%93-speedtest-cli/</link><description><![CDATA[<p>
	In this tutorial we’ll test and check the server network connection speed via speedtest-cli (Speedtest by Ookla), the best thing is you can directly install the speedtest python package to your Linux distro and run the test via terminal command isn’t is awesome.
</p>

<p>
	This will also help you to determine that what exactly network speed your server provider is providing. Without waiting lets get started. Difficulty level : super easy
</p>

<p>
	<strong>For Centos/EL 7/centos 8 stream/centos 9 stream</strong>
</p>

<pre class="ipsCode">curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
yum install speedtest</pre>

<p>
	to run the speedtest type below command : 
</p>

<pre class="ipsCode">speedtest</pre>

<p>
	**accept the license by typing "yes"
</p>

<p>
	<strong>For Ubuntu/Debian <span>:</span></strong>
</p>

<pre class="ipsCode">sudo apt-get install curl
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
sudo apt-get install speedtest</pre>

<p>
	to run the speedtest type below command : 
</p>

<pre class="ipsCode">speedtest</pre>

<p>
	**accept the license by typing "yes"
</p>

<p>
	<strong>For other OS : </strong>
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">mkdir -p /usr/local/ookla
cd /usr/local/ookla
wget https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-x86_64.tgz
tar zxvf ookla-speedtest-1.2.0-linux-x86_64.tgz</span></pre>

<p>
	to run the speedtest type below command : 
</p>

<pre class="ipsCode">cd /usr/local/ookla
./speedtest</pre>

<p>
	**accept the license by typing "yes"
</p>

<p>
	<strong>it will show the speed results like below : </strong>
</p>

<pre class="ipsCode">Speedtest by Ookla

      Server: Frontier - Ashburn, VA (id: 14229)
         ISP: Hetzner Online GmbH
Idle Latency:     0.32 ms   (jitter: 0.00ms, low: 0.31ms, high: 0.32ms)
    Download: 17904.35 Mbps (data used: 9.7 GB)
                  1.25 ms   (jitter: 0.27ms, low: 0.34ms, high: 1.86ms)
      Upload: 16385.81 Mbps (data used: 15.5 GB)
                  2.86 ms   (jitter: 0.79ms, low: 0.68ms, high: 7.50ms)
Packet Loss:     0.0%
  Result URL: https://www.speedtest.net/result/c/524965dc-5310-4b38-9ce6-218bf4de7d0b</pre>

<p style="text-align:center;">
	<img alt="524965dc-5310-4b38-9ce6-218bf4de7d0b.png.d055cd8c543b798fa2f5902b505f1a2b.png" class="ipsImage ipsImage_thumbnailed" data-fileid="9" style="height:auto;" width="750" src="https://www.alphagnu.com/uploads/monthly_2023_07/524965dc-5310-4b38-9ce6-218bf4de7d0b.png.d055cd8c543b798fa2f5902b505f1a2b.png" loading="lazy" height="397.5">
</p>
]]></description><guid isPermaLink="false">59</guid><pubDate>Tue, 04 Jul 2023 02:12:51 +0000</pubDate></item><item><title>How to Install MSSQL Express Server In CWP Centos 7/8 Stream Almalinux 7/8  Rockylinux 7/8</title><link>https://www.alphagnu.com/topic/58-how-to-install-mssql-express-server-in-cwp-centos-78-stream-almalinux-78-rockylinux-78/</link><description><![CDATA[<p>
	In this tutorial we’ll learn how to install MSSQL express server in centos/EL 7/8 stream OS easily. Microsoft SQL Server Express is a version of Microsoft’s SQL Server relational database management system that is free to download, distribute and use. It comprises a database specifically targeted for embedded and smaller-scale applications.
</p>

<p>
	To install MSSQL express edition follow the below steps :
</p>

<p>
	First install some dependencies :-
</p>

<pre class="ipsCode">yum install python2 compat-openssl10 openssl-devel</pre>

<p>
	Second make python 2 default alternative interpreter :
</p>

<pre class="ipsCode">alternatives --config python</pre>

<p>
	Third Microsoft MSSQL repo :
</p>

<p>
	For Centos 7/EL7 :
</p>

<pre class="ipsCode">curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo</pre>

<p>
	or Centos 8/EL8/AlmaLinux/RockyLinux :
</p>

<pre class="ipsCode">curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo</pre>

<p>
	Fourth Install MSSQL express server :
</p>

<pre class="ipsCode">yum install mssql-server</pre>

<p>
	Fifth Run mssql-conf via below command and choose the Express edition and accept the licensing and terms by typing “yes” :
</p>

<pre class="ipsCode">/opt/mssql/bin/mssql-conf setup</pre>

<p>
	** choose “Express” by typing the number you see Infront of it, also choose/enter the password fo “SA” user
</p>

<p>
	Sixth enable MSSQL to run on boot :
</p>

<pre class="ipsCode">systemctl enable mssql-server</pre>

<p>
	you can restart, start and stop mssql-server as below :
</p>

<pre class="ipsCode">systemctl start mssql-server
systemctl stop mssql-server
systemctl restart mssql-server</pre>

<p>
	Install the SQL Server command-line tools
</p>

<p>
	<strong>To install sqlcmd follow this :</strong>
</p>

<p>
	For Centos 7/EL7 :
</p>

<pre class="ipsCode">curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo</pre>

<p>
	For 8/EL8/AlmaLinux/RockyLinux :
</p>

<pre class="ipsCode">curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo</pre>

<p>
	Then install the sqlcmd tool :
</p>

<pre class="ipsCode">yum remove unixODBC-utf16 unixODBC-utf16-devel -y &amp;&amp; yum install mssql-tools unixODBC-devel -y</pre>

<p>
	Now set the environment variable :
</p>

<pre class="ipsCode">echo 'export PATH="$PATH:/opt/mssql-tools/bin"' &gt;&gt; ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' &gt;&gt; ~/.bashrc</pre>

<p>
	<br />
	Now update the current shell environment :
</p>

<pre class="ipsCode">source ~/.bashrc</pre>

<p>
	example :
</p>

<p>
	you can connect to SA user with below command :
</p>

<pre class="ipsCode">sqlcmd -S localhost -U SA -P 'YourPassword'</pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">58</guid><pubDate>Tue, 04 Jul 2023 01:46:23 +0000</pubDate></item><item><title>How to scan for malwares and viruses with maldet in Linux</title><link>https://www.alphagnu.com/topic/57-how-to-scan-for-malwares-and-viruses-with-maldet-in-linux/</link><description><![CDATA[<p>
	Maldet is a malware scanner for Linux servers. It detects varieties of infections and malwares within your scripts (php and etc) and in server. To scan for viruses with Maldet, follow these steps:
</p>

<p>
	<strong>Log in to your Linux server as the root user.</strong>
</p>

<p>
	Install Maldet by running the following command:
</p>

<pre class="ipsCode">wget http://www.rfxn.com/downloads/maldetect-current.tar.gz
tar -xzf maldetect-current.tar.gz
cd maldetect-*/
sh install.sh</pre>

<p>
	<br />
	Update Maldet with the latest malware definitions by running the following command:
</p>

<pre class="ipsCode">maldet -u</pre>

<p>
	<br />
	To scan a specific directory, run the following command:
</p>

<pre class="ipsCode">maldet -a /path/to/directory</pre>

<p>
	<br />
	Replace “/path/to/directory” with the path to the directory you want to scan.
</p>

<p>
	To scan all files on the server, run the following command:
</p>

<pre class="ipsCode">maldet -a /
#or
maldet -a /home
#or
maldet -a /home/user/public_html</pre>

<p>
	<br />
	Note that this can take a long time to complete, depending on the size of your server and the number of files.
</p>

<p>
	Maldet will output any suspicious files it finds. If it finds a file that it suspects is malware, it will quarantine it automatically if enable. You can view the quarantine list by running the following command:
</p>

<pre class="ipsCode">maldet --quarantine list</pre>

<p>
	<br />
	If you want to restore a file from quarantine, run the following command:
</p>

<pre class="ipsCode">maldet --quarantine restore ID</pre>

<p>
	<br />
	Replace “ID” with the ID of the file you want to restore, which you can find in the quarantine list.
</p>

<p>
	That’s it! You’ve successfully scanned for viruses with Maldet.
</p>

<p>
	<strong>For more advance malware/virus scanning and cleaning you can contact me (paid service low price)</strong>
</p>
]]></description><guid isPermaLink="false">57</guid><pubDate>Tue, 04 Jul 2023 01:40:07 +0000</pubDate></item><item><title>Enable and install WDDX extension in PHP 7.4</title><link>https://www.alphagnu.com/topic/54-enable-and-install-wddx-extension-in-php-74/</link><description><![CDATA[<p>
	In this tutorial we’ll install WDDX php extension in php 7.4. This extension is DEPRECATED and REMOVED as of PHP 7.4. Lets find what is WDDX ? – WDDX (Web Distributed Data eXchange) is a programming language-, platform- and transport-neutral data interchange mechanism designed to pass data between different environments and different computers.
</p>

<p>
	No worry we can still install WDDX extension in php 7.4 follow this easy guide to this :Step 1 :
</p>

<p>
	Building and installing WDDX php extension <span>:</span>
</p>

<p>
	<span>Step 1 <span>:</span></span>
</p>

<pre class="ipsCode">wget https://github.com/php/pecl-text-wddx/archive/master.zip -O wddx.zip
unzip wddx.zip
cd pecl-text-wddx-master
phpize
./configure
make
make install</pre>

<p>
	 
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			** find the proper path for phpize and add prefix for the php-config eg :<br />
			suppose you’ve installed php in /opt/alt/php/ then replace this
		</p>

		<p>
			/opt/alt/php/usr/bin/phpize<br />
			./configure --with-php-config=/opt/alt/php/usr/bin/php-config
		</p>
	</div>
</blockquote>

<p>
	Step 2 :
</p>

<p>
	Enabling WDDX php extension<br />
	In php.ini add this following line to enable WDDX :
</p>

<pre class="ipsCode">extension=wddx.so</pre>

<p>
	<br />
	Restart apache/php-fpm/php-handler service done.
</p>

<p>
	Step 3 :
</p>

<p>
	Check wddx is installed correctly and loaded via this command :
</p>

<pre class="ipsCode">php -m | grep wddx</pre>

<p>
	<br />
	If loaded successfully then result will look like :
</p>

<pre class="ipsCode">[root@mysterydata]# php -m | grep wddx
wddx</pre>

<p>
	<br />
	Or check via php info page
</p>
]]></description><guid isPermaLink="false">54</guid><pubDate>Sat, 24 Jun 2023 08:55:05 +0000</pubDate></item><item><title>How to send mails from different Static/Dedicated IP in Postfix - CWP Linux Centos</title><link>https://www.alphagnu.com/topic/52-how-to-send-mails-from-different-staticdedicated-ip-in-postfix-cwp-linux-centos/</link><description><![CDATA[<p>
	This topic is about the mail sending from different dedicated/static IP in CWP Postfix and Linux server using postfix MTA. Suppose you've two or more dedicated static IP and you want to host websites in One Ip and use the second Ip to send Emails only for this you need to make changes to Postfix config like Below <span>: </span>
</p>

<p>
	<span><strong>Step 1 <span>: </span></strong></span>
</p>

<p>
	Edit postfix master config <strong> /etc/postfix/master.conf</strong> <span>: </span>
</p>

<pre class="ipsCode">nano /etc/postfix/master.conf</pre>

<p>
	<span><strong>Step 2 <span>: </span></strong></span>
</p>

<p>
	<span><span>Find this lines and add this config : </span></span>
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			<span><span>smtp      unix  -       -       n       -       -       smtp</span></span>
		</p>
	</div>
</blockquote>

<p>
	<span><span>and </span></span>
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			<span><span>relay     unix  -       -       n       -       -       smtp</span></span>
		</p>
	</div>
</blockquote>

<p>
	and below this two lines add this config : 
</p>

<pre class="ipsCode">  -o smtp_bind_address=124.12.12.12</pre>

<p>
	replace the ip with your second IP or the Ip you want to send email from
</p>

<p>
	so the config will look like <span>: </span>
</p>

<pre class="ipsCode">smtp      unix  -       -       n       -       -       smtp
  -o smtp_bind_address=124.12.12.12 

relay     unix  -       -       n       -       -       smtp
  -o smtp_bind_address=124.12.12.12
  -o fallback_relay=</pre>

<p>
	<strong>Step 3 : </strong>
</p>

<p>
	Restart postfix service : 
</p>

<pre class="ipsCode">systemctl restart postfix</pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">52</guid><pubDate>Sat, 24 Jun 2023 08:42:02 +0000</pubDate></item><item><title>Postfix add Dedicated Static IP per user for mail sending out CWP Linux Ubuntu</title><link>https://www.alphagnu.com/topic/45-postfix-add-dedicated-static-ip-per-user-for-mail-sending-out-cwp-linux-ubuntu/</link><description><![CDATA[<p>
	in this tutorial I’ll show you how you can assign user account ip for mail sending under postfix mail server. It will be good if you’re providing mail services to your use.
</p>

<p>
	Suppose you’ve one ip configured for mail server and a user who sends lots of spam or his/her website got infected and sending spam from the infected scripts this leads to main mail ip for email sending will quickly get into blacklisted and all other genuine users who are using safe practices for mail sending will suffer because of that bad user. To cope with this situation you need to have per ip basis configuration for user if one user ip get blacklisted then other users will not be affected and you can bait that bad user by disabling mail sending.
</p>

<p>
	Lets get started with the configuration before you configure ensure you’ve Multi ips are attached in your server network.
</p>

<p>
	Create file called <strong>sdd_transport_maps.regexp</strong> in <strong>/etc/postfix/</strong>:
</p>

<pre class="ipsCode">/@user1-domain\.tld$/       username1:
/@user2-domain\.tld$/       username2:
/@user3-domain\.tld$/       username3:</pre>

<p>
	<br />
	<strong>replace</strong> /@user1-domain\.tld$/ with domain.tld eg : /@alphagnu\.com$/<br />
	<strong>replace</strong> <strong>username1</strong> with account username alphagnu<br />
	you can add like this for multi users and domains.
</p>

<p>
	Now In <strong>/etc/postfix/master.cf </strong>create and add special transport lines called user1, user2, user3 and more user as per need :
</p>

<pre class="ipsCode">username1  unix -       -       n       -       -       smtp
   -o smtp_bind_address=10.10.10.1
   -o smtp_helo_name=user1-domain.tld
   -o syslog_name=postfix-username1

username2  unix -       -       n       -       -       smtp
   -o smtp_bind_address=10.10.10.2
   -o smtp_helo_name=user2-domain.tld
   -o syslog_name=postfix-username2

username3  unix -       -       n       -       -       smtp
   -o smtp_bind_address=10.10.10.3
   -o smtp_helo_name=user3-domain.tld
   -o syslog_name=postfix-username3</pre>

<p>
	<br />
	Replace <strong>smtp_bind_address</strong> ip with the dedicated ip for the user account.
</p>

<p>
	eg :
</p>

<pre class="ipsCode">alphagnu  unix -       -       n       -       -       smtp
   -o smtp_bind_address=10.10.10.1
   -o smtp_helo_name=alphagnu.com
   -o syslog_name=postfix-alphagnu</pre>

<p>
	<br />
	In <strong>/etc/postfix/main.cf</strong> add <strong>sender_dependent_default_transport_maps</strong> line:
</p>

<pre class="ipsCode">sender_dependent_default_transport_maps = regexp:/etc/postfix/sdd_transport_maps.regexp</pre>

<p>
	<br />
	reload/ restart postfix
</p>

<pre class="ipsCode">service postfix restart</pre>

<p>
	<br />
	that’s it you’re done configuring it test by sending email.
</p>
]]></description><guid isPermaLink="false">45</guid><pubDate>Tue, 20 Jun 2023 14:45:07 +0000</pubDate></item><item><title>How to Check Linux VPS or Dedicated Server Disk I/O Speed via this Simple Commands</title><link>https://www.alphagnu.com/topic/49-how-to-check-linux-vps-or-dedicated-server-disk-io-speed-via-this-simple-commands/</link><description><![CDATA[<p>
	Now a days who doesn’t want speedy websites, for this you need a good server configuration whether it is VPS or dedicated server all servers have DISK attached to hold your website’s files and data and the Disk I/O (Input/Output) is one of the main requirement for speedy websites i.e. how quickly server can read and write data to it.
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			A good Disk can give you performance benefits and boost your website’s speed and ranking.
		</p>
	</div>
</blockquote>

<p>
	Most server provider now a days provides SSD or SSD cached disk space even some provider also dealing with old magnetic HDD Disk to there clients which can hold data of 100-500 GBs (even TBs), hold on is that worth it?
</p>

<p>
	In this article we’ll check DISK I/O speed of your server (VPS/Dedicated) via this simple commands.
</p>

<p>
	<strong>Commands to check DISK I/O speed <span>:</span></strong>
</p>

<p>
	<strong><span style="font-size:18px;">Command 1 :</span></strong>
</p>

<pre class="ipsCode">dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync &amp;&amp; rm -rf test</pre>

<p>
	<br />
	eg. output :
</p>

<pre class="ipsCode">[root@vpn ~]# dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync &amp;&amp; rm -rf test
16384+0 records in
16384+0 records out
1073741824 bytes (1.1 GB) copied, 1.95918 s, 548 MB/s</pre>

<p>
	<br />
	here you can see disk speed is incredibly fast enough “548 MB/s”  as this is pure SSD disk and of course a good Server provider.
</p>

<p>
	If your Disk speed is lower than 80/85 mbps Consider moving to another provider.
</p>

<p>
	<span style="font-size:18px;"><strong>Command 2 :</strong></span>
</p>

<p>
	To Check Disk I/O latency using ioping
</p>

<p>
	A tool to monitor I/O latency in real time. It shows disk latency in the same way as ping shows network latency.
</p>

<p>
	<strong>Installation on Centos and Ubuntu OS :</strong>
</p>

<p>
	Centos
</p>

<pre class="ipsCode">yum install epel-release
yum install ioping</pre>

<p>
	<br />
	Ubuntu/Debian
</p>

<pre class="ipsCode">apt-get install ioping</pre>

<p>
	<br />
	<strong>Run this command to start DISK I/O Latency test:</strong>
</p>

<pre class="ipsCode">ioping -c 15 .</pre>

<p>
	<br />
	eg. output
</p>

<pre class="ipsCode">[root@vpn ~]# ioping -c 15 .
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=1 time=71.9 us (warmup)
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=2 time=111.3 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=3 time=99.3 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=4 time=131.8 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=5 time=134.5 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=6 time=102.8 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=7 time=116.0 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=8 time=117.0 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=9 time=117.0 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=10 time=112.4 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=11 time=122.4 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=12 time=97.8 us (fast)
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=13 time=125.6 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=14 time=118.8 us
4 KiB &lt;&lt;&lt; . (simfs /dev/simfs): request=15 time=128.6 us

--- . (simfs /dev/simfs) ioping statistics ---
14 requests completed in 1.64 ms, 56 KiB read, 8.56 k iops, 33.4 MiB/s
generated 15 requests in 14.0 s, 60 KiB, 1 iops, 4.29 KiB/s
min/avg/max/mdev = 97.8 us / 116.8 us / 134.5 us / 11.0 us</pre>

<p>
	<br />
	Here the average I/O Latency is 116.8 milliseconds (lower is better)
</p>

<p>
	<strong>You can also check latency of the disk by this command :</strong>
</p>

<pre class="ipsCode">ioping -c 10 -s 1M /tmp</pre>

<p>
	<br />
	<strong>TO Measure disk sequential speed :</strong>
</p>

<pre class="ipsCode">ioping -RL /</pre>

<p>
	<br />
	or by disk name :
</p>

<pre class="ipsCode">ioping -RL /dev/sda</pre>

<p>
	<br />
	<strong>TO measure DISK seek Rate :</strong>
</p>

<pre class="ipsCode">ioping -R /</pre>

<p>
	<br />
	or by disk name :
</p>

<pre class="ipsCode">ioping -R /dev/sda</pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">49</guid><pubDate>Tue, 20 Jun 2023 15:14:57 +0000</pubDate></item><item><title>How to Flush and Delete Postfix Mail Queue</title><link>https://www.alphagnu.com/topic/46-how-to-flush-and-delete-postfix-mail-queue/</link><description><![CDATA[<p>
	This is short tutorial for clearing and deleting the mail queue from command line. Postfix is the mail server which is used to send mails, time to time there will increase in mail queue which contains failed email in order to check and clear the mail queue just run this following command from terminal/ssh.
</p>

<p>
	To check mail queue:
</p>

<pre class="ipsCode">mailq</pre>

<p>
	<br />
	To remove all mail from the queue:
</p>

<pre class="ipsCode">postsuper -d ALL</pre>

<p>
	<br />
	To remove all mails in the deferred queue:
</p>

<pre class="ipsCode">postsuper -d ALL deferred</pre>

<p>
	EXTRA <span>: </span>
</p>

<p>
	<span>To delete or remove maildrop queues run this command <span>: </span></span>
</p>

<pre class="ipsCode">find /var/spool/postfix/maildrop/ -type f | xargs rm  -rf</pre>

<p>
	SCRIPT <span>:</span>
</p>

<p>
	Also you can use this script to delete mail queue which contain certain keyword or email id :
</p>

<pre class="ipsCode">cd /root
touch mailq-del.pl
chmod 775 mailq-del.pl
nano mailq-del.pl</pre>

<p>
	<br />
	and add this below code in mailq-del.pl and save it :
</p>

<pre class="ipsCode">#!/usr/bin/perl
 
$REGEXP = shift || die "no email-adress given (regexp-style, e.g. bl.*\@gmail.com)!";
 
@data = qx&lt;/usr/sbin/postqueue -p&gt;;
for (@data) {
  if (/^(\w+)(\*|\!)?\s/) {
     $queue_id = $1;
  }
  if($queue_id) {
    if (/$REGEXP/i) {
      $Q{$queue_id} = 1;
      $queue_id = "";
    }
  }
}
 
#open(POSTSUPER,"|cat") || die "couldn't open postsuper" ;
open(POSTSUPER,"|postsuper -d -") || die "couldn't open postsuper" ;
 
foreach (keys %Q) {
  print POSTSUPER "$_\n";
};
close(POSTSUPER);</pre>

<p>
	<br />
	example usage of script :
</p>

<pre class="ipsCode">cd /root
./mailq-del.pl example@gmail.com
or
./mailq-del.pl keyword</pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">46</guid><pubDate>Tue, 20 Jun 2023 14:49:01 +0000</pubDate></item><item><title>Install Latest FFMPEG 6.0 version in CentOS stream 9/8 centos 7 Ubuntu 22.04/20.04 CWP Cpanel Plesk Ispconfig hestiacp</title><link>https://www.alphagnu.com/topic/42-install-latest-ffmpeg-60-version-in-centos-stream-98-centos-7-ubuntu-22042004-cwp-cpanel-plesk-ispconfig-hestiacp/</link><description><![CDATA[<p>
	In this tutorial we’ll install latest version of FFmpeg 6.0 "Von Neumann", in Centos/linux/ubuntu/debian server also it will work in CWP, Cpanel and ispconfig and other centos supported control panel. I’ve gotten many requests and mails upon how to install ffmpeg and here is the guide.
</p>

<p>
	FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge.
</p>

<p>
	Its pretty simple to Install Latest version of FFMPEG Just follow this steps :
</p>

<p>
	Ensure you’re running kernel 3.2.x and above. Check kernel version via this command “uname -sr“
</p>

<p>
	Supported operating systems :
</p>

<p>
	EL/Centos 7/centos 8 stream/centos 9 stream
</p>

<p>
	Ubuntu 18.04/20.4/latest os
</p>

<p>
	Debian 9/10/11
</p>

<p>
	and linux running kernel 3.2.x or above
</p>

<p>
	Move/backup currently installed FFMPEG :
</p>

<pre class="ipsCode">mv /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg.bak
mv /usr/local/bin/ffprobe /usr/local/bin/ffprobe.bak
mv /usr/bin/ffmpeg /usr/bin/ffmpeg.bak
mv /usr/bin/ffprobe /usr/bin/ffprobe.bak
mv /usr/bin/qt-faststart /usr/bin/qt-faststart.bak
mv /usr/local/bin/qt-faststart /usr/local/bin/qt-faststart.bak</pre>

<p>
	<br />
	Download Latest version of FFMPEG :
</p>

<pre class="ipsCode">cd /usr/local
rm -rf  ffmpeg
wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
tar xf ffmpeg-release-amd64-static.tar.xz
rm -rf ffmpeg-release-amd64-static.tar.xz
mv ffmpeg-* ffmpeg</pre>

<p>
	<br />
	Now create symlinks for ffmpeg and ffprobe bin file :
</p>

<pre class="ipsCode">ln -s /usr/local/ffmpeg/ffmpeg /usr/local/bin/ffmpeg
ln -s /usr/local/ffmpeg/ffprobe /usr/local/bin/ffprobe
ln -s /usr/local/ffmpeg/qt-faststart /usr/local/bin/qt-faststart
ln -s /usr/local/ffmpeg/ffmpeg /usr/bin/ffmpeg
ln -s /usr/local/ffmpeg/ffprobe /usr/bin/ffprobe
ln -s /usr/local/ffmpeg/qt-faststart /usr/bin/qt-faststart</pre>

<p>
	<br />
	Change the permission for the files :
</p>

<pre class="ipsCode">chmod 755 /usr/local/ffmpeg/ffmpeg
chmod 755 /usr/local/ffmpeg/ffprobe
chmod 755 /usr/local/ffmpeg/qt-faststart</pre>

<p>
	<br />
	Use this FFMPEG and FFPROBE path in your script/application :
</p>

<p>
	FFMPEG path :
</p>

<pre class="ipsCode">/usr/local/bin/ffmpeg</pre>

<p>
	<br />
	FFPROBE path :
</p>

<pre class="ipsCode">/usr/local/bin/ffprobe</pre>

<p>
	<br />
	Thats it you can now use FFMPEG and ffprobe Latest version, check version by typing “ffmpeg” :
</p>

<pre class="ipsCode">[root@server local]# /usr/local/bin/ffmpeg
ffmpeg version 6.0-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...</pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">42</guid><pubDate>Sun, 11 Jun 2023 09:27:25 +0000</pubDate></item><item><title>Install Stable Composer In Linux CWP Ubuntu Debian</title><link>https://www.alphagnu.com/topic/41-install-stable-composer-in-linux-cwp-ubuntu-debian/</link><description><![CDATA[<p>
	Install composer quickly and learn how to update composer and use different php version paths with composer, Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
</p>

<p>
	Composer can be installed in your server quickly and its very easy to install :-
</p>

<p>
	Installation of Composer<br />
	Switch into the /usr/local/bin directory.
</p>

<pre class="ipsCode">cd /usr/local/bin</pre>

<p>
	<br />
	Download and installing Stable version of Composer by using cURL :
</p>

<pre class="ipsCode">curl https://getcomposer.org/composer-stable.phar -o composer</pre>

<p>
	<br />
	Fix the permission also this will create global access to composer i.e. user having shell access can execute composer :
</p>

<pre class="ipsCode">chmod 755 /usr/local/bin/composer</pre>

<p>
	<br />
	For ubuntu/debian you need to follow this steps :
</p>

<pre class="ipsCode">ln -s /usr/local/bin/composer /usr/bin/composer</pre>

<p>
	<br />
	That’s it composer is successfully installed.
</p>

<p>
	you can now use composer command in shell to execute.
</p>

<p>
	Check Composer version :
</p>

<pre class="ipsCode">composer -V</pre>

<p>
	<br />
	eg. :
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			[root@server bin]# composer -V<br />
			Do not run Composer as root/super user! See <a href="https://getcomposer.org/root" rel="external nofollow">https://getcomposer.org/root</a> for details<br />
			Continue as root/super user [yes]? yes<br />
			Composer version 2.0.7 2020-11-13 17:31:06
		</p>
	</div>
</blockquote>

<p>
	<br />
	Update composer upon new version releases :<br />
	to update composer you just need to run this command :
</p>

<pre class="ipsCode">composer self-update</pre>

<p>
	<br />
	**it will update to stable latest version
</p>

<p>
	<strong>Run different php version with the composer :</strong><br />
	you need to user the full path for php bin and composer path with the composer sub command we use “install” command here as eg:
</p>

<pre class="ipsCode">/path/to/php-bin /usr/local/bin/composer update
/path/to/php-bin /usr/local/bin/composer install</pre>

<p>
	<br />
	For CWP run composer as php selector and php-fpm selector :
</p>

<p>
	For CWP php selector :
</p>

<pre class="ipsCode">/opt/alt/php56/usr/bin/php /usr/local/bin/composer install
/opt/alt/php70/usr/bin/php /usr/local/bin/composer install
/opt/alt/php71/usr/bin/php /usr/local/bin/composer install
/opt/alt/php72/usr/bin/php /usr/local/bin/composer install
/opt/alt/php73/usr/bin/php /usr/local/bin/composer install
/opt/alt/php74/usr/bin/php /usr/local/bin/composer install
/opt/alt/php80/usr/bin/php /usr/local/bin/composer install
/opt/alt/php81/usr/bin/php /usr/local/bin/composer install
/opt/alt/php82/usr/bin/php /usr/local/bin/composer install</pre>

<p>
	<br />
	For CWP php-fpm selector :
</p>

<pre class="ipsCode">/opt/alt/php-fpm56/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm70/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm71/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm72/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm73/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm74/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm80/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm81/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm82/usr/bin/php /usr/local/bin/composer install</pre>

<p>
	<br />
	For Cpanel/WHM :
</p>

<pre class="ipsCode">ea-php71 /usr/local/bin/composer install
ea-php72 /usr/local/bin/composer install
ea-php73 /usr/local/bin/composer install
ea-php74 /usr/local/bin/composer install
ea-php80 /usr/local/bin/composer install
ea-php81 /usr/local/bin/composer install
ea-php82 /usr/local/bin/composer install</pre>

<p>
	<br />
	For other panel’s multi php refer to the official docs and paths for the php bin file
</p>

<p>
	<strong>Troubleshoot :</strong><br />
	if you get below error then php is not installed in default location you need to specify the path for php bin
</p>

<pre class="ipsCode">/usr/bin/env: ‘php’: No such file or directory</pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">41</guid><pubDate>Thu, 08 Jun 2023 13:39:08 +0000</pubDate></item><item><title>How to upgrade PostgreSQL to Latest version PostgreSQL 15 in CWP Centos 7/8/Almalinux 8/RockyLinux 8</title><link>https://www.alphagnu.com/topic/38-how-to-upgrade-postgresql-to-latest-version-postgresql-15-in-cwp-centos-78almalinux-8rockylinux-8/</link><description><![CDATA[<p>
	In this tutorial I’ll show you how you can upgrade PostgreSQL from older version to latest version at the time of writing 13 is the latest version, This is tested in CWP and other servers running centos 7 and 8 i.e. el7/el8.
</p>

<p>
	The upgrade procedure is little bit complicated and you need to follow the below steps one by one :
</p>

<p>
	<strong>Step 1 :</strong>
</p>

<p>
	Backup all the data
</p>

<pre class="ipsCode">mkdir /home/pgsql
chown -R postgres:postgres /home/pgsql
su - postgres
pg_dumpall &gt; /home/pgsql/backup
exit</pre>

<p>
	<br />
	Step 2 :
</p>

<p>
	Uninstalling/removing the current version of PostgreSQL :
</p>

<pre class="ipsCode">systemctl stop postgresql
mv /var/lib/pgsql/data/ /home/pgsql/data.old
rpm -e --nodeps postgresql postgresql-devel postgresql-libs postgresql-server</pre>

<p>
	<br />
	If you already installed from official repo i.e. version 9,10,11 and 12 (skip this steps if you didn’t used official repo to install pgsql) do this :
</p>

<pre class="ipsCode">systemctl stop postgresql-#
mv /var/lib/pgsql/#/data/ /home/pgsql/#/data.old
rpm -e --nodeps postgresql# postgresql#-devel postgresql#-libs postgresql#-server
replace “#”with the version number i.e. 9/10/11/12/13/14</pre>

<p>
	Step 3 :
</p>

<p>
	Now install the Latest version of PostgreSQL :
</p>

<p>
	EL7/Centos 7 :
</p>

<pre class="ipsCode">yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install -y yum-utils centos-release-scl-rh
yum-config-manager --disable centos-sclo-rh
yum --enablerepo=centos-sclo-rh install llvm-toolset-7-clang
yum install postgresql15-server postgresql15-devel</pre>

<p>
	<br />
	EL8/Centos 8 :
</p>

<pre class="ipsCode">dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf -qy module disable postgresql
dnf install postgresql15-server postgresql15-devel</pre>

<p>
	<br />
	Step 4 :
</p>

<p>
	Now copying the configuration file to new installation of PostgreSQL :
</p>

<p>
	Centos 7/8/EL7/EL8 :
</p>

<pre class="ipsCode">su - postgres
mv /var/lib/pgsql/15/data/pg_hba.conf /var/lib/pgsql/15/data/pg_hba.conf.bak
wget -O https://www.alphagnu.com/upload/pg_hba.conf /var/lib/pgsql/15/data/pg_hba.conf
chown -R postgres:postgres /var/lib/pgsql/15/data/pg_hba.conf
/usr/pgsql-15/bin/initdb
exit</pre>

<p>
	<br />
	if you have used official repo to install pgsql (skip this step if you didn’t installed any pgsql from official repo before) :
</p>

<pre class="ipsCode">su - postgres
/usr/pgsql-15/bin/initdb
cp /home/pgsql/#/data.old/pg_hba.conf /var/lib/pgsql/15/data/
cp /home/pgsql/#/data.old/postgresql.conf /var/lib/pgsql/15/data/
exit</pre>

<p>
	<br />
	replace “#” with version number you used above
</p>

<p>
	Step 5 :
</p>

<p>
	Now start PostgreSQL and enable it to start on boot :
</p>

<pre class="ipsCode">systemctl enable postgresql-15
systemctl start postgresql-15</pre>

<p>
	<br />
	Step 6 :
</p>

<p>
	Restore the previous backups done in Step 1
</p>

<pre class="ipsCode">su - postgres
psql -d postgres -f /home/pgsql/backup</pre>

<p>
	<br />
	Step 7 :
</p>

<p>
	Create symlink of new version of service :
</p>

<pre class="ipsCode">systemctl stop postgresql
rm -rf /usr/lib/systemd/system/postgresql.service
ln -s /usr/lib/systemd/system/postgresql-15.service /usr/lib/systemd/system/postgresql.service
systemctl daemon-reload
systemctl stop postgresql-15.service
systemctl enable postgresql
systemctl restart postgresql</pre>

<p>
	<br />
	EXTRA upgrading phpPgAdmin in CWP :
</p>

<pre class="ipsCode">cd /usr/local/cwpsrv/var/services
yum install cwpPgphp -y
yum reinstall cwpPgphp -y
mv phpPgAdmin phpPgAdmin.bak
wget https://github.com/phppgadmin/phppgadmin/releases/download/REL_7-13-0/phpPgAdmin-7.13.0.zip
unzip phpPgAdmin-7.13.0.zip
mv phpPgAdmin-7.13.0 phpPgAdmin
rm -rf phpPgAdmin-7.13.0.zip</pre>
]]></description><guid isPermaLink="false">38</guid><pubDate>Wed, 07 Jun 2023 14:38:14 +0000</pubDate></item><item><title>How to add Swap memory in Linux OS CentOS Ubuntu Debian CWP HestiaCP</title><link>https://www.alphagnu.com/topic/35-how-to-add-swap-memory-in-linux-os-centos-ubuntu-debian-cwp-hestiacp/</link><description><![CDATA[<p>
	In this Topic we’re going to add Swap space to Linux OS (RHEL, CentOS, Ubuntu) to prevent memory full issues. Swap is important when your server frequently going out of memory and got hanged (OOM) this can cause MySQL database corruption and many issues with the server. Before we get started I like to inform that this tutorial is <strong>only valid for KVM/XEN/VMWARE/Dedicated type servers.</strong> For Openvz and other container based servers this tutorial will not work.
</p>

<p>
	Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
</p>

<p>
	Protection against <strong>OOM (out of memory)</strong> errors, crashes, memory-related system unpredictability/instability.<br />
	Increases available memory to the system and allows more programs to be run concurrently &amp; more safely<br />
	Prevent server non responsiveness/ hangs
</p>

<p>
	<br />
	<strong>Step 1 :</strong><br />
	Follow this commands one by one :
</p>

<pre class="ipsCode">cd /var
touch swap.img
chmod 600 swap.img</pre>

<p>
	<br />
	<strong>STEP 2 :</strong><br />
	We’ll create 1GB (1024MB) of Swap :
</p>

<pre class="ipsCode">dd if=/dev/zero of=/var/swap.img bs=1024k count=1000</pre>

<p>
	<br />
	if you want to create 2 gb swap increase the “count” value to “2000” for 3gb increase “count” to : “3000”
</p>

<p>
	###############<br />
	2gb eg. :
</p>

<pre class="ipsCode">dd if=/dev/zero of=/var/swap.img bs=1024k count=2000</pre>

<p>
	<br />
	3gb eg. :
</p>

<pre class="ipsCode">dd if=/dev/zero of=/var/swap.img bs=1024k count=3000</pre>

<p>
	<br />
	###############<br />
	result will look like this :
</p>

<pre class="ipsCode">[root@srv1 var]# dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 3.30777 s, 317 MB/s</pre>

<p>
	<br />
	<strong>STEP 3 :</strong><br />
	Creating swap img file :
</p>

<pre class="ipsCode">mkswap /var/swap.img</pre>

<p>
	<br />
	result will look like this :
</p>

<pre class="ipsCode">[root@srv1 var]# mkswap /var/swap.img
Setting up swapspace version 1, size = 1023996 KiB
no label, UUID=5813e8e7-1034-4700-84c2-c06905e26535</pre>

<p>
	<br />
	<strong>STEP 4 :</strong><br />
	Enabling Swap :
</p>

<pre class="ipsCode">swapon /var/swap.img</pre>

<p>
	<br />
	Checking Swap :
</p>

<pre class="ipsCode">free -h
[root@srv1 var]# free -h
              total        used        free      shared  buff/cache   available
Mem:           1.9G        260M        144M         27M        1.6G        1.5G
Swap:          999M          0B        999M</pre>

<p>
	<br />
	<strong>Step 5 :</strong><br />
	making it Enable during server boot, run the below command which will add entry in /etc/fstab :
</p>

<pre class="ipsCode">echo "/var/swap.img    none    swap    sw    0    0" &gt;&gt; /etc/fstab</pre>

<p>
	<br />
	All done, you just enabled Swap partition on your server. let me know how it goes as i tried to make the tutorial as simple as could be.
</p>

<p>
	<strong>TO create/modify/delete existing swap first off the swap :</strong>
</p>

<p>
	Swap Off :
</p>

<pre class="ipsCode">swapoff -a</pre>

<p>
	<br />
	Then delete the swap file :
</p>

<pre class="ipsCode">rm -rf /var/swap.img</pre>

<p>
	<br />
	After deleting follow the STEPs above from very first (Skip Step 5 if already executed this command before) .
</p>
]]></description><guid isPermaLink="false">35</guid><pubDate>Sun, 04 Jun 2023 19:14:04 +0000</pubDate></item><item><title>Find Big File and Directories via command line in Linux</title><link>https://www.alphagnu.com/topic/13-find-big-file-and-directories-via-command-line-in-linux/</link><description><![CDATA[<p>
	In this tutorial we’ll learn how to find big files in Linux, you can use the find command with the du command to search for the files. Here’s how to do it:
</p>

<p>
	Open a terminal/ssh window.
</p>

<p>
	Navigate to the directory where you want to search for big files. For example, to search for big files in your server root / directory, type:
</p>

<pre class="ipsCode">cd /</pre>

<p>
	<br />
	Type the following command to list all files in the current directory and its subdirectories, sorted by size:
</p>

<pre class="ipsCode">du -ah . | sort -rh | head -n 30</pre>

<p>
	<br />
	This command uses the du command to calculate the size of each file and the sort command to sort the results in reverse order. The head command is used to show only the first 30 results.
</p>

<p>
	The output will show the size of each file in a human-readable format (such as “1.5M” or “10G”) and the path to the file.
</p>

<p>
	You can modify the command to search for big files in a specific directory or to show more or fewer results. For example, to search for big files in the /home and /var/log directories and show the first 100 results, type:
</p>

<pre class="ipsCode">du -ah /home | sort -rh | head -n 100
#or
du -ah /var/log | sort -rh | head -n 100</pre>

<p>
	<br />
	<strong>Bonus command:</strong><br />
	To find big files all over the server disk / :
</p>

<p>
	find / -mount -size +1024k -type f -exec ls -alh {} \;|sort -rnb -k 5|more<br />
	example :
</p>

<pre class="ipsCode">[root@server ~]# find / -mount -size +1024k -type f -exec ls -alh {} \;|sort -rnb -k 5|more
-rw-r--r-- 1 clamupdate clamupdate 185M May  6 04:23 /var/lib/clamav/daily.cld
-rw-r--r-- 1 clamupdate clamupdate 163M Sep 22  2021 /var/lib/clamav/main.cvd
-rw------- 1 root mail 137M May  6 16:09 /var/spool/mail/root</pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">13</guid><pubDate>Fri, 02 Jun 2023 14:04:22 +0000</pubDate></item></channel></rss>
