Archive

Archive for the ‘Tips & Tricks’ Category

Add date & time to your bash history

Print Friendly, PDF & Email

We all know the “history” command that display the list of commands you previously entered.  But have you ever wish to know when these commands were entered ?  This useful tip, will require only  a few seconds to put in place and will now add the date and time in your history file.

Output of history command before the change to .bashrc

Output of history command before the change to /etc/bashrc

Read more…

Categories: Tips & Tricks

yum tips and tricks

Print Friendly, PDF & Email

The “yum” is a powerful and useful command. We will present here some options of this command. Hopefully, you will find these tips helpful and that you learn something.

Applying only security update

To be able to apply only security update on your server, we first need to install a plugin for this purpose. You can install it with this command:

yum install yum-security

After that, we can use this plugin to update your computer to the latest security fixes :

yum update --security

Applying all update except the kernel update

On some system, you may want to apply all update, except the one concerning the kernel.  To put this exception , add the following line to the file /etc/yum.conf ;

echo 'exclude=kernel*' >> /etc/yum.conf

Applying all update except the kernel update

In order to enable the automatic update system run following commands:

chkconfig --add yum-autoupdate
service yum-autoupdate start

In order to disable the system run:

service yum-autoupdate stop
chkconfig --del yum-autoupdate
Categories: Tips & Tricks

Search and replace multiple files

Print Friendly, PDF & Email

In the example below we are replacing every occurrence of mama with papa in all .html files in current path using Perl.

perl -pi -e "s/mama/papa/g;" *.html

We do the same thing here but make a copy of original file for backup.

perl -pi -e.bak "s/mama/papa/g;" *.html
Categories: Tips & Tricks