Tuesday 4 February 2020

Download and Install Virtualmin/Webmin on centos/ubuntu

I am writing this blog as virtualmin/webmin is now being popular to manage Ubuntu and CentOS easily for normal users.
Virtualmin with webmin provides comprehensive command line interface, full API, sysadmin-friendly defaults, auditing, unmatched security features, Virtualmin is built on top of, and integrated with, Webmin. Webmin is the world's most popular Linux/UNIX systems management UI.
There are dozens of options for choosing how the new user interface behaves, allowing you to more thoroughly customize your experience and that of your users.

Lets we start the virtualmin installation now

All we need to have a freshly (highly recommended) installed Linux box installed with OS supported by virtualmin as mentioned below.

CentOS/RHEL 6 and 7 on i386 and x86_64
Debian 9 and 10 on i386 and amd64
Ubuntu 16.04 LTS and 18.04 LTS on i386 and amd64 (non-LTS releases are not supported)
ref : https://www.virtualmin.com/os-support.html
Now install wget if not available in your Linux OS.
For Ubuntu
$sudo apt install wget


For CentOS
$sudo yum install wget

Now we need to download script to start virtualmin installation.
wget http://software.virtualmin.com/gpl/scripts/install.sh
Its time to start installation now. Execute below command to run downloaded script.
sudo /bin/sh install.sh
The install script may ask you some questions. If your system does not have a fully qualified hostname, the script will ask you to provide one. Or, if your system doesn't have enough memory for the installation type you've chosen, it'll offer to create a swap file.

Now you can login to your virtualmin control panel with https://hostname-or ip:10000/.

e.g, https://localhost:10000/

Sunday 2 February 2020

For loop in bash



  • How do I use bash for loop to repeat certain task under Linux / UNIX operating system? How do I set infinite loops using for statement? How do I use three-parameter for loop control expression?
  • A ‘for loop’ is a bash programming language statement which allows code to be repeatedly executed. A for loop is classified as an iteration statement i.e. it is the repetition of a process within a bash script. For example, you can run UNIX command or task 5 times or read and process list of files using a for loop. A for loop can be used at a shell prompt or within a shell script itself.

or loop syntax
Numeric ranges for syntax is as follows:
for VARIABLE in 1 2 3 4 5 .. N
do
 command1
 command2
 commandN
done
OR
for VARIABLE in file1 file2 file3
do
 command1 on $VARIABLE
 command2
 commandN
done
OR
for OUTPUT in $(Linux-Or-Unix-Command-Here)
do
 command1 on $OUTPUT
 command2 on $OUTPUT
 commandN
done
This type of for loop is characterized by counting. The range is specified by a beginning (#1) and ending number (#5). The for loop executes a sequence of commands for each member in a list of items. A representative example in BASH is as follows to display welcome message 5 times with for loop
#!/bin/bash
for i in 1 2 3 4 5
do
   echo "Welcome $i times"
done

Sometimes you may need to set a step value (allowing one to count by two’s or to count backwards for instance). Latest bash version 3.0+ has inbuilt support for setting up ranges
#!/bin/bash
for i in {1..5}
do
   echo "Welcome $i times"
done
Bash v4.0+ has inbuilt support for setting up a step value using {START..END..INCREMENT} syntax:
#!/bin/bash
echo "Bash version ${BASH_VERSION}..."
for i in {0..10..2}
  do 
     echo "Welcome $i times"
 done
Sample outputs:
Bash version 4.0.33(0)-release...
Welcome 0 times
Welcome 2 times
Welcome 4 times
Welcome 6 times
Welcome 8 times
Welcome 10 times

Could not start a new session. Response code 500. Message: Failed to read marionette port

There is bug in firefox binary installed using apt/snap, I faced same issue when I installed firefox from apt package respository. I solved ...