Monday, March 2, 2015

Creating a Local Yum Repository Using an ISO Image


To create a local yum repository (for example, if a system does not have Internet access or don't have valid subscription with Redhat),

1) Copy the iso file to your rhel server for example into /root/installer

cp  /media/dvd/rhel-server-6.5-x86_64-dvd.iso   /root/installer/

2) Mount the iso to a mount point for example /media/dvd

mount -o loop  /root/installer/rhel-server-6.5-x86_64-dvd.iso  /media/dvd

3) Create a repo file /etc/yum.repos.d/dvd.repo, entries may looks like this

[Server]
name=rhel6.5
baseurl=file:///media/dvd/Server
enabled=1
gpgcheck=0

[HighAvailability]
name=rhel6.5
baseurl=file:///media/dvd/HighAvailability
enabled=1
gpgcheck=0

[ResilientStorage]
name=rhel6.5
baseurl=file:///media/dvd/ResilientStorage
enabled=1
gpgcheck=0

[ScalableFileSystem]
name=rhel6.5
baseurl=file:///media/dvd/ScalableFileSystem
enabled=1
gpgcheck=0


4) Save the content and list repo in your rhel server

yum repo list

If everything is ok, you may start installing packages using the repo, for example to install apache web server (httpd)

yum -y install httpd

Thursday, February 26, 2015

Renaming multiple files in single command in Linux


In Linux renaming a file or two is very simple with 'mv' but how about hundred or thousand in one shot?

Here I have list of files:

doc1.TXT.read
doc2.TXT.read
doc3.TXT.read
doc4.TXT.read
doc5.TXT.read
doc6.TXT.read
doc7.TXT.read
doc8.TXT.read

Now, I want to rename it to doc1.txt, doc2.txt so on and so forth i.e changing the capital .TXT to lower case .txt and remove the .read extension

for f in *.TXT.read ; do mv -i "$f" "${f%%.*}.txt" ; done

The result will be:

doc1.txt
doc2.txt
doc3.txt
doc4.txt
doc5.txt
doc6.txt
doc7.txt
doc8.txt

And there you have it !!