Monday, May 22, 2017

Change a string in a file based on line number

I came across this situation where I needed to change the timeout of a certain command alone in a script temporarily and automatically. I came across a solution using sed

sed -i "24s/timeoutValue1/timeValue2/" fileName

Ref:
Replace String Based on Line Number

Thursday, May 18, 2017

Changing the size of wallpaper in RHEL 7

I was trying to change my wallpaper and put up the new image. But it was zoomed in and I couldn't figure out how to change from zoomed to scaled.

On googling, I found the link below. You need dconf-editor to do this. Open up dconf-editor and go to

org -> gnome -> desktop -> background

and there you can change from zoomed to scaled.


Ref:
Cant change size of wallpaper (stock or from home/pictures) 13.10 using gnome3


Thursday, May 11, 2017

How to search for multiple strings in a file using grep

I wanted to search for both ERROR and FAIL in a file using grep.

Came across this:

grep -E "ERROR|FAIL" filename

Or
grep "ERROR\|FAIL" filename

For searching a file for lines not containing a string

grep -v "PASS" filename 

Reference:
Grep OR, AND and NOT operators

Saturday, January 23, 2016

Upgrading from Fedora 22 to Fedora 23

I got a new laptop today and was trying to install Fedora 23 on it. However, I wasn't able to get to Fedora 23 and had to install Fedora 22 and upgrade to Fedora 23. I found the instructions online and proceeded.

Upgrading from Fedora 22 to Fedora 23

Monday, November 30, 2015

Renew or release DHCP IP address

Recently I had an issue with the network on one of my test machines. After some debugging and some help, we figured out that the DHCP IP address needed to be released and renewed. 

I ran the following command:
sudo dhclient eth0

Wednesday, October 21, 2015

Search for results excluding a word

To search for something excluding a certain word or phrase, use
grep -v "word" <file or location>
For example, the results of a grep search can include a lot of results which are not relevant. Eliminate those by using grep -v

 grep "blah" filename | grep -v "foo"

This will get you results with "blah" but nothing with "blah" and "foo" in them. 
 
 

Wednesday, August 12, 2015

Get public IP address of your computer

Open up the Terminal Application and run the command below to get the public IP address of your computer
dig +short myip.opendns.com @resolver1.opendns.com

Reference:
How to find my public IP address from command line on linux