If you are writing a Bash shell script, you should read command-line arguments into an array for some time. This allows us to process any number of arguments provided when the script is run. This makes the script adaptable to different use cases. Instead of dealing with fixed variables like $1, $2, $3, etc., you can work with any number of arguments more dynamically using bash for loop or bash while loop, depending upon your needs. Arrays make it simple to loop through each argument and perform operations on them, whether basic printing or complex processing. Bash provides a mapfile (readarray command) internal built-in command to read lines from a file into an array variable. Let us see how to use mapfile to read all command line arguments into an array.
[continue reading…]

CentOS, RHEL (Red Hat Enterprise Linux), Fedora and other clones of RHEL, such as Oracle, Alma, and Rocky, offer support for version pinning. This feature allows developers and system administrators to lock a particular package to a specific version, preventing it from being automatically updated by yum or dnf commands. Sometimes, it is necessary to protect packages from being updated to newer versions to avoid incompatibility issues with your applications. For example, you can lock down PHP version 8.3.6 and avoid using updated PHP version 8.4. Let us see how to lock a package to a specific version, only exclude a package from yum update or dnf update on a CentOS, RHEL, Fedora, and friends.
[continue reading…]

Here’s a quick tip for vim users. You can perform find and replace operations within a visual selection in Vim for text or code block. Visual selection for finding and replacing text in Vim allows developers and Linux/Unix users precise and efficient text editing. It’s handy when you want to change specific portions of text or code blocks within a larger file without affecting other occurrences. This method required to minimizing manual search and reducing the risk of unintended code or text modifications. Let us see how to find and replace in Vim visual mode selection.
[continue reading…]

Unhide is a little handy forensic tool to find hidden processes and TCP/UDP ports by rootkits / LKMs or by another hidden technique. This tool works under Linux, Unix-like system, and MS-Windows operating systems. From the man page:

It detects hidden processes using three techniques:

  1. The proc technique consists of comparing /proc with the output of /bin/ps.
  2. The sys technique consists of comparing information gathered from /bin/ps with information gathered from system calls.
  3. The brute technique consists of bruteforcing the all process IDs. This technique is only available on Linux 2.6 kernels.

[continue reading…]

Sometimes you need to verify that certain features are supported on your OpenSSH server and client. For example, not all versions of OpenSSH (SSHD server) and ssh client will support 2FA YubiKey or SFTP chroot jail support. To check the OpenSSH SSHD server and ssh client version, pass the -V option and it will display the version number and exit to the CLI:
$ /usr/sbin/sshd -V
$ /usr/bin/ssh -V

Unfortunately, I ran into unknown option -- V option. Let us see how to resolve this quickly, especially on an older version of BSD and Linux/Unix systems.
[continue reading…]

All developers and Unix users know how to use an ssh client. OpenSSH is a widely used implementation of Secure Shell (SSH) Internet communication protocol. Back in the old days, Unix folks used Telnet which was insecure. On the other hand, SSH allows exchanging data using a secure channel between two hosts. Therefore, every Linux and Unix server running cloud or at home needs an OpenSSH server for management and IT automation. Regrettably, the popularity of SSH servers and client also brings various security issues. I wrote about “Top 20 OpenSSH Server Best Security Practices” a long time ago. Today, I will talk about ssh server and client auditing tools that anyone can use to the hardened standard SSH server and client configuration for security issues.
[continue reading…]

A web stack is nothing but collection of many open source software such as an operating system, Web server, database server, server side programming language. The most commonly known web stacks is LAMP. It is an acronym for a solution stack of free, open source software, referring to the first letters of Linux (operating system), Apache Web server, MySQL database software and PHP (or sometimes Perl or Python). All of our security related tutorials recommends running different network services on separate systems or vm instance. Naturally, this limits the number of other services that can be cracked in the event that an attacker is able to successfully exploit a software flaw in one network service. This is also one of the most requested article via email. In this guide, I will explain how to setup a solution that can serve static content, dynamic content, database, and caching by running on separate servers or vm instance.
[continue reading…]