Linux switch network to DHCP or Static

I just helped a co-worker regarding this particular task where she wants to switch her network interface from manual static IP to automatic IP by dhcp in a linux client using command line since it does not have x desktop so I quickly wrote following script

you can find your interface name quickly by executing nmcli dev status at the terminal

How to Configure Network Connection Using 'nmcli' Tool

switchStaticToDHCP.sh

requires passing by one argument which is your network interface name.

!/bin/bash
 nmcli con mod $1 ipv4.method auto
 nmcli con mod $1 ipv4.gateway ""
 nmcli con mod $1 ipv4.address ""
 nmcli con down $1
 nmcli con up $1
 dhclient $1

switchStaticToDHCP.sh Your_Network_Interface_Name

eg: bash switchStaticToDHCP.sh enp0s3

switchDHCPToStatic.sh

requires passing by 3 arguments – your network interface name, static ip address, & default gateway ip address.

!/bin/bash
 nmcli con mod $1 ipv4.method manual
 nmcli con mod $1 ipv4.addresses $2/24
 nmcli con mod $1 ipv4.gateway $3
 nmcli con down $1
 nmcli con up $1

swtichDHCPToStatic.sh Your_Network_Interface_Name IP_Address Default_Gateway

eg: bash switchDHCPToStatic.sh enp0s3 192.168.1.168 192.168.1.254

Using self sign certificate with mono in Centos family Linux communicating with IIS Server

sometimes we do not want to pay for the Certificate authority – CA to issue a real certificate or for development, we just want to use a self sign cert that we signed and manually trusted it for testing https traffic just for development environment.

In Windows, we can just click on the self sign cert and it prompts us to where we want to store it which usually should be stored in Trusted Root Authority store.

Windows Cert. Trust - Trusted Root Certification Authorities vs Enterprise  Trust

But where is it in Linux and especially for mono? also I am not going to cover self sign cert for IIS server creation here in this post and I assume you already know how to do it. if you go to IIS manager (inetmgr) you should be able to create it there.

How to Install an SSL/TLS Certificate In Microsoft IIS 8 - The SSL Store™

I wrote a bash script here where it will download your IIS self signed cert from your IIS Server in pem format and then merge it with existing certificate bundle – tls-ca-bundle.pem. Then sync the newly merged cert list to mono store – Trust store

registerIISServerCertSelfSignForMono.sh

#!/bin/bash
echo "Server:Port = $1";

### Download IIS self sign cert in pem format from given server:port
openssl s_client -showcerts -verify 5 -connect $1 < /dev/null | awk '/BEGIN/,/END/{ if(/BEGIN/) out="IISSelfSignCert.pem"; print >out}'

TEMPDIR=/etc/pki/ca-trust/source/temp

### Cleaning up our temp directory
rm -rf $TEMPDIR
mkdir -p $TEMPDIR

### copy our IIS Server self sign cert pem to our temp directory
cp IISSelfSignCert.pem $TEMPDIR

### Merge our IIS self sign cert pem to existing tls ca bundle cert pem
cp /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem $TEMPDIR/MergedCertList.pem

echo -e "\n# $f added for IIS Server Self Sign Cert" >> $TEMPDIR/MergedCertList.pem
cat $TEMPDIR/IISSelfSignCert.pem >> $TEMPDIR/MergedCertList.pem

cat $TEMPDIR/MergedCertList.pem

#now sync with Mono store, Trust store
cert-sync $TEMPDIR/MergedCertList.pem

Execute it at the terminal:

$ registerIISServerCertSelfSignForMono.sh yourServerName:Port

eg:

$ registerIISServerCertSelfSignForMono.sh www.vic-llc.org:443

A lifetime of Babbel Language Learning is on sale for 60% off

Babbel claims they can have you talking confidently in your new language in 30 days — and with the current offer – 60% off, you can put that theory to the test at the lowest possible price. Regularly $499, you can grab a lifetime subscription to Babbel Language Learning right now, including access to all 14 of their language training staples, for only $199, or 60 percent off. Want to learn a new language with a friend? You can grab a 2-pack for $358, or $179 each.

Prices subject to change.

The Code Breaker: Jennifer Doudna, Gene Editing, and the Future of the Human Race

CRISPR Pioneer Jennifer Doudna Headlines NHGRI 25th Anniversary Celebration  | NIH Intramural Research Program
Image: Crispr

Biochemist Jennifer Doudna and her collaborators discovered a tool that can edit DNA, known as CRISPR. It has already been deployed to cure diseases, fight the coronavirus pandemic of 2020, and make inheritable changes in babies’ genes. The development of CRISPR will hasten our transition to the next great innovation revolution, says author David Wheeler. Wheeler: Children who study digital coding will be surpassed by those who study the code of life. Should we use our new evolution-hacking powers to make us less susceptible to viruses, prevent deafness and blindness, or enhance the IQ, height , memory and the muscles of the babies? The key to innovation is connecting basic science to our everyday lives, he says, moving discoveries from labs to our bedsides in ways that respect our moral values, he writes. The book is a thrilling detective tale that involves the most profound wonders of nature, from the origins of life to the future of our species.

Apophis asteroid will not hit Earth for 100 years, Nasa says

NASA has been monitoring an asteroid called Apophis for 17 years. They discovered the 335-metre space rock in 2004 and put it on their list of most hazardous asteroids. They originally said it could kill over 10 million people if it hit Earth in 2029. However, their latest prediction is that Earth will be safe from it for the next 100 years. It will come within 20,000 miles of Earth on April 13, 2029, when it will be at its closest point to the planet. The scientists used radar to predict the asteroid’s orbit around the sun. The space rock is currently 10.6 million miles away from Earth.

What if you returns exit code -1 in bash, will bash take it as -1?

Actually no, if we return -1 in bash, it will be interpreted as 255 per https://tldp.org/LDP/abs/html/exitcodes.html

if I can go back in time, I would never return exit code -1 for a failure in Linux. 1 would be ideal in this case.

Let write a simple bash script test – to copy non-existent file

the execution will fail and exit status code is 1 as expected so let’s modify this script and return the exit status code to -1.

Since we alter our script by checking if exit code is not zero, we instead return -1. As a result, bash interprets it as out of range since exit takes only integer args in the range 0 – 255 and therefore interprets it as 255 instead of -1.

Scientists have discovered stem cells that are vital in hair regeneration

Seven ways … to avoid hair loss | Men's hair | The Guardian

Scientists have discovered stem cells that are vital in hair regeneration process. They hope to adapt the stem cells to create a therapy for hair loss. Millions of people worldwide suffer from baldness. Baldness predominantly affects men and affects up to 85 per cent of men by the age of 50. The scientists are now embarking on clinical research and laboratory trials. They observed that hair growth was a cyclical process within the follicle. They used 220 combinations of chemicals to make the hair regrow naturally. The research could lead to hair follicle regeneration therapy in the near future, scientists say.  

No photo description available.

Denmark will build an artificial island 80km off its western coast in the North Sea

Denmark To Build World's First Energy Island In The North Sea

Denmark will build an artificial island 80km off its western coast in the North Sea. The island will be the size of 18 football fields and cost around $34 billion to build. It will produce enough electricity to power three million homes and help make Denmark carbon neutral. Denmark is Europe’s largest oil-producing country and will end its reliance on fossil fuels within three decades. It is expected to be in operation by 2033 and will help reduce CO2 emissions.

Pigs are intelligent enough to play video games

pigs playing video games

Scientists at Purdue University taught pigs to play video games. In the game, the player scores points for maneuvering a cursor using a joystick so as to hit a colored target. The player is in the middle of what looks like an abstract representation of a room, surrounded by four blue walls. Each wall, running the length of the screen, is a potential target, and the player need to hit any wall to complete the stage. Almost all of the pigs got to the one-sided target, though some did get to the small one- sided one-box target.  Purdue University’s online course on how to play games with pigs, with videos and tips on how-to videos can be taught with pigs. The online course is available online at: www.purdue.org/video-game-teaches. World of Boarcraft is a video game set up to mimic the behavior of a wild boar. The video game’s makers hope to attract more people to the animal kingdom.