Pages

Saturday, November 19, 2011

How To Add a start up script to be Run at Boot time in Ubuntu


First Save your script in

  /etc/init.d/


then type:


sudo update-rc.d script_name defaults

This script will now run each time you boot up.

Wednesday, November 16, 2011

sort the contents of a text file in place

This will sort the contents of a file without the need to pipe it into a second file.

great for cron jobs



sort -g name_of_file_to_sort.txt -o $_

Monday, November 14, 2011

Dropbox Free 2GB account

Always have your stuff when you need it with Dropbox.
2GB account is free!


Click Here To open an account

Dropbox will allow you to share folders across multiple computers.


Friday, November 4, 2011

Removing old unused Kernels from your Fedora system

Old unused Kernels can take up a fair amount of Disk Space.
to install old ones.


Install yum utils
yum install yum-utils

package-cleanup --oldkernels --count=2

will remove all old kernels except for the last 2.

 Make Amount of Installed Kernels Permanent
Edit /etc/yum.conf and set installonly_limit

 
installonly_limit=2
 

Friday, October 21, 2011

Integrate google contacts into your Mutt address Book

Goobook will alow you to interact with your gmail contacts from the command line and also enable mutt to access them

install goobook
type


easy-install -U goobook

Once installed create .netrc  file in your home folder with the credentials to your google account
Vim ~/.netrc


inside .netrc put the following

machine google.com
login yourgmailaddress@gmail.com
password yourpassword

save the file

to test if it is working type

goobook dump_contacts

this will dump all your contact information from gmail to stn out

to search for a string from your gmail contacts type

goobook query query

eg to search for clive type

goobook query clive

if you want to use goobook from mutt

edit your .muttrc file and add in the following line:

set query_command="goobook query '%s'"

to query the address book from inside mutt use the "Q" key



If you want to be able to use to complete email addresses instead of Ctrl-t add this:
bind editor complete-query
To add email addresses (with "a" key normally bound to create-alias command) add the following line:

macro index,pager A "goobook add" "add the sender address to Google contacts"

If you want to add an email's sender to Contacts, press "a" while it's selected in the index or pager.

Thursday, September 29, 2011

Rename image files according to EXIF date


This will rename all of your pictures in a given folder and prefix the date and time that the picture was taken in front of the file name.
Useful if your camera screws up your naming convention of your pictures, or if you want to simply organize all your pictures by date

yum install exiv2

cd to the folder with all your pictures that you want to rename
and type:

exiv2 -r'%Y%m%d-%H%M_:basename:' rename $(ls)
 
will rename to
 
20110929-2005_DSC_3782.JPG


Friday, September 16, 2011

Install Oracle 11G 32bit on 64bit Rhel 6


 

  





Install the following prerequisites


yum install gnome-icon-theme-2.28.0-2.el6.noarch sgml-common-0.6.3-32.el6.noarch dmz-cursor-themes-0.4-4.el6.noarch libstdc++-devel-4.4.4-13.el6.x86_64 kernel-headers-2.6.32-71.el6.x86_64 elfutils-libelf-devel-0.148-1.el6.x86_64 libgcc-4.4.4-13.el6.i686 nss-softokn-freebl-3.12.7-1.1.el6.i686 glibc-2.12-1.7.el6.i686 mpfr-2.4.1-6.el6.x86_64 libXt-1.0.7-1.el6.x86_64 libXmu-1.0.5-1.el6.x86_64 libXxf86misc-1.0.2-1.el6.x86_64 libXxf86vm-1.1.0-1.el6.x86_64 libaio-0.3.107-10.el6.i686 libstdc++-4.4.4-13.el6.i686 ncurses-libs-5.7-3.20090208.el6.i686 readline-6.0-3.el6.i686 libICE-1.0.6-1.el6.i686 xorg-x11-xauth-1.0.2-7.1.el6.x86_64 cpp-4.4.4-13.el6.x86_64 libtool-ltdl-2.2.6-15.5.el6.x86_64 unixODBC-2.2.14-11.el6.x86_64 ppl-0.10.2-11.el6.x86_64 cloog-ppl-0.15.7-1.2.el6.x86_64 libmcpp-2.7.2-4.1.el6.x86_64 mcpp-2.7.2-4.1.el6.x86_64 xorg-x11-server-utils-7.4-15.el6.x86_64 compat-db42-4.2.52-15.el6.x86_64 compat-db43-4.3.29-15.el6.x86_64 libdmx-1.1.0-1.el6.x86_64 libXxf86dga-1.1.1-1.el6.x86_64 libXv-1.0.5-1.el6.x86_64 libIDL-0.8.13-2.1.el6.x86_64 ORBit2-2.14.17-3.1.el6.x86_64 GConf2-2.28.0-6.el6.x86_64 libbonobo-2.24.2-4.el6.x86_64 gtk2-engines-2.18.4-5.el6.x86_64 shared-mime-info-0.70-4.el6.x86_64 libdaemon-0.14-1.el6.x86_64 avahi-0.6.25-8.el6.x86_64 avahi-glib-0.6.25-8.el6.x86_64 gnome-vfs2-2.24.2-6.el6.x86_64 libtool-ltdl-2.2.6-15.5.el6.i686 unixODBC-2.2.14-11.el6.i686 libuuid-2.17.2-6.el6.i686 libSM-1.1.0-7.1.el6.i686 libXau-1.0.5-1.el6.i686 xorg-x11-utils-7.4-8.el6.x86_64 compat-libstdc++-33-3.2.3-69.el6.x86_64 celt051-0.5.1.3-0.el6.x86_64 libXp-1.0.0-15.1.el6.x86_64 libxcb-1.5-1.el6.i686 libX11-1.3-2.el6.i686 libXext-1.1-3.el6.i686 ConsoleKit-x11-0.4.1-3.el6.x86_64 libXi-1.3-3.el6.i686 xorg-x11-xinit-1.0.9-13.el6.x86_64 libXtst-1.0.99.2-3.el6.i686 libXt-1.0.7-1.el6.i686 compat-libstdc++-33-3.2.3-69.el6.i686 glibc-headers-2.12-1.7.el6.x86_64 glibc-devel-2.12-1.7.el6.x86_64 gcc-4.4.4-13.el6.x86_64 compat-gcc-34-3.4.6-19.el6.x86_64 gnome-themes-2.28.1-6.el6.noarch system-icon-theme-6.0.0-2.el6.noarch system-gnome-theme-60.0.2-1.el6.noarch ncurses-devel-5.7-3.20090208.el6.x86_64 libgnome-2.28.0-11.el6.x86_64 gcc-c++-4.4.4-13.el6.x86_64 readline-devel-6.0-3.el6.x86_64 glibc-devel-2.12-1.7.el6.i686 compat-db-4.6.21-15.el6.x86_64 unixODBC-devel-2.2.14-11.el6.i686 unixODBC-devel-2.2.14-11.el6.x86_64 libaio-devel-0.3.107-10.el6.i686 libaio-devel-0.3.107-10.el6.x86_64 compat-gcc-34-c++-3.4.6-19.el6.x86_64

next you must install the 32 bit version of the Glib libraries

yum install glib-devel.i686

connect to the server with
ssh -X oracle@serverip address

./runInstaller -ignoresysprereq

the Oracle Xwindow will open on your desktop,
follow instructions to complete the installation.











Wednesday, September 14, 2011

Point RHEL 6 installation to Centos6 repositories



Migrating from RHEL6 to CentOS 6






vi /etc/yum.repo.d/centos.repo

[centos]
name=CentOS $releasever - $basearch
baseurl=http://ftp.heanet.ie/pub/centos/6/os/$basearch/
enabled=1

gpgcheck=0


yum remove matahari*


edit /etc/yum.conf

exclude=redhat-logos redhat artwork












mkdir TMP

yum remove rhnlib abrt-plugin-bugzilla
yum remove redhat-release-notes*



rpm -e --nodeps redhat-release redhat-indexhtml

for 64 bit version use
rpm -e --nodeps redhat-release-server.x86_64
rpm -e --nodeps redhat-indexhtml-6-1.el6.noarch



cd TMP

wget http://mirror.centos.org/centos/6/os/x86_64/Packages/centos-release-6-0.el6.centos.5.x86_64.rpm

wget http://mirror.centos.org/centos/6/os/x86_64/Packages/centos-indexhtml-6-1.el6.centos.noarch.rpm

wget http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-3.2.27-14.el6.centos.noarch.rpm

wget http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm

rpm -Uvh *.rpm
cd ..
rm -rf TMP
yum clean all
yum upgrade

voila, your Redhat machine can now get updated from the Centos repositories

Tuesday, August 30, 2011

Spliting 1 large MKV file into 2 smaller MKV files


Lets say you have a 6GB MKV file that you want to split into 2 X 3GB MKV files

mkvtoolnix to the rescue

install mkvtoolnix

yum install mkvtoolnix

once installed cd into the directory that has the file you want to split
lets say the file is called thor.mkv
to split it into 2 files of 3GB each simply type the following.

mkvmerge --split size 3g thor.mkv -o thor1.mkv
hit enter

you will land up with 2 extra files thor1.mkv and thor2.mkv, each 3gb in size (the original file will also still be in the directory


Tuesday, June 7, 2011

Rsync


Backing up data using rsync command

I have stopped using scp to copy files from computer to computer and far prefer to use rsync.
rsync command uses the same format as scp, (so there is no learning curve and if you are used to using scp, then switching to rsync is no trouble at all) rsync has the benefit of being able to continue from a failed copy, and also has a wealth of other advantages over scp.

rsync is a great tool for backing up and restoring files.

Example of the remote server and folder that needs to be backup or copied:
Remote host name: server.example.com
Remote folder: /home/serverfolder/
Remote user: user1


rsync -arv user1@serverexample.com:/home/serverfolder/ /home/cgerada

(/home/cgerada is the local folder path of the machine I am on and to were I want to copy to)
or to copy into the directory that I am currently in you could type
rsync -arv user1@serverexample.com:/home/serverfolder/ .

Here is what the "-arv" option does:
a = archive - means it preserves permissions (owners, groups), times, symbolic links, and devices.
r = recursive - means it copies directories and sub directories
v = verbose - means that it prints on the screen what is being copied
add --progress at the end of the command to get a running tally of what's going on
eg
rsync -avr * /media/usb/ --progress

another good example

rsync -avr --progress --delete --log-file=/var/log/$(date +%Y%m%d)_rsync.log user1@serverexample.com:/home/folder/ /home/folder/

will create a log file and document the progress into the logfile
-- delete will delete on the destination server what ever files have been deleted from the source  (it wont delete files on your source server, only destination)


Excluding files


rsync -avr --exclude '*.iso' source/ destination/


Will Exclude all iso files


or you can write it like this , it doesn't matter, it still works
rsync -avr source/ destination/ --exclude '*.iso' --progress 




Thursday, December 2, 2010

Output your microphone to a remote computer’s speaker

dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp

This will output the sound from your microphone port to the ssh target computer’s speaker port. The sound quality is bad, so you will hear a lot of hissing,
but it works.

Email alert on Root Login

This will allow you to be notified instantly via email whenever someone logs into your server as root.

ssh into your server

su to root

sudo -i

or su -

cd to /root

cd /root

edit your .bashrc file

vim .bashrc

add the following to the end of the file

echo 'ALERT - Root Shell Access (YourserverName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" you@yourdomain.com

Replace YourServerName with the name of your server.

Replace you@yourdomain.com with the email address you want the alerts sent to.

:x to save and exit

logout from your server, close the connection and log back in.

You will receive an email alert of the root login after a few minutes.

Saturday, November 27, 2010

Mutt Tips

searching in mutt

* ~f brucewayne :From: matches "brucewayne"
* ~s party : messages with subject containing "party"
* ~d <2w : messages less than two weeks old. Also: year, month, week, day.
* ~t clarkk : To: matches clarkk (useful for sent-mail folders)
* ~O : old (i.e. unread but not new) messages.
~N is new unread.
~U is unread, i.e. both together.
* ~p : messages addressed to you (useful if your inbox is bombarded with mailing list or system report activity).
* ~p ~U : for messages to you you haven't read yet.
* . : matches everything. In effect, remove the limit.


l limit messages matching
l all show all messages
:set sort=from sort messages by "From"
:set sort=threads sort messages by "Thread"
:set sort=date sort messages by "Date"


mailbox "=cgerada" will show alerts in cgerada mailbox

Friday, November 26, 2010

Bash Cheat Sheet

 !! - Last command (usefull if you forget to run a command as sudo)
 sudo !!  (runs last command as sudo)
 !foo - Run most recent command starting with 'foo...' (ex. !ps, !mysqladmin)
 !foo:p - Print command that !foo would run, and add it as the latest to
 command history
 !$ - Last 'word' of last command ('/path/to/file' in the command 'ls -lAFh
 /path/to/file', '-uroot' in 'mysql -uroot')
 !$:p - Print word that !$ would substitute
 !* - All but first word of last command ('-lAFh /path/to/file' in the command
 'ls -lAFh /path/to/file', '-uroot' in 'mysql -uroot')
 !*:p - Print words that !* would substitute

 ^foo^bar - Replace 'foo' in last command with 'bar', print the result, then
 run. ('mysqladmni -uroot', run '^ni^in', results in 'mysqladmin -uroot')

 {a,b,c} passes words to the command, substituting a, b, and c sequentially
 (`cp file{,.bk}` runs `cp file file.bk`)

 Ctrl + a - Jump to the start of the line
 Ctrl + b - Move back a char
 Ctrl + c - Terminate the command
 Ctrl + d - Delete from under the cursor
 Ctrl + e - Jump to the end of the line
 Ctrl + f - Move forward a char
 Ctrl + k - Delete to EOL
 Ctrl + l - Clear the screen
 Ctrl + r - Search the history backwards
 Ctrl + R - Search the history backwards with multi occurrence
 Ctrl + t - Transpose the current char with the previous
 Ctrl + u - Delete backward from cursor
 Ctrl + w - Delete backward a word
 Ctrl + xx - Move between EOL and current cursor position
 Ctrl + x @ - Show possible hostname completions
 Ctrl + z - Suspend/ Stop the command
 Ctrl + x; Ctrl + e - Edit line into your favorite editor

 Alt + < - Move to the first line in the history  Alt + > - Move to the last line in the history
 Alt + ? - Show current completion list
 Alt + * - Insert all possible completions
 Alt + / - Attempt to complete filename
 Alt + . - Yank last argument to previous command
 Alt + b - Move backward
 Alt + c - Capitalize the word
 Alt + d - Delete word
 Alt + f - Move forward
 Alt + l - Make word lowercase
 Alt + n - Search the history forwards non-incremental
 Alt + p - Search the history backwards non-incremental
 Alt + r - Recall command
 Alt + t - Transpose the current word with the previous
 Alt + u - Make word uppercase
 Alt + back-space - Delete backward from cursor

 (Here "2T" means Press TAB twice)
 $ 2T - All available commands(common)
 $ (string)2T - All available commands starting with (string)
 $ /2T - Entire directory structure including Hidden one
 $ (dir)2T - Only Sub Dirs inside (dir) including Hidden one
 $ *2T - Only Sub Dirs inside without Hidden one
 $ ~2T - All Present Users on system from "/etc/passwd"
 $ $2T - All Sys variables
 $ @2T - Entries from "/etc/hosts"
 $ =2T - Output like ls or dir
 .bash_profile = sourced by login shell,
 .bashrc = sourced by all shells,
 .bash_aliases = should be sourced by .bashrc

Run something:
 for i in a b c; do $i 'hello'; done

Do something on a bunch of files:
 for i in *.rb; do echo $i; done

If syntax:
 if [ -e .ssh ]; then echo "hi"; fi

file check flags:
 -e:  file exists
 -f:  regular file (non directory)
 -d:  directory
 -s:  non-zero file
 -x:  execute permission

Avoid duplicates in your history:
 export HISTIGNORE="&:ls:ls *:[bf]g:exit"

Wednesday, November 10, 2010

SMBCLIENT

smbclient -L servername
will show you all available samba / windows shares

To connect to a windows or samba share type

smbclient \\\\servername\\share -U username

you will be asked for your windows password for the username specified

once connected smbclient works like an FTP client

type help for a list of commands.

Keep in mind, you'll need a leading "\" before spaces (ex: My\ Filename.txt).

or alternatively put your filenames in quotes eg "My Filename.txt"

once connected
to copy directories and subdirectories type
recurse

to not be asked (prompted)if you want to replace files. type
prompt

Example:
smbclient '\\server\share'
    mask ""
    recurse ON
    prompt OFF
    cd 'path\to\remote\dir'
    lcd '~/path/to/download/to/'

    mget *

or, all on one line,


smbclient '\\server\share' -N -c 'prompt OFF;recurse ON;cd 'path\to\directory\';lcd '~/path/to/download/to/';mget *'

Wednesday, November 3, 2010

Setting UP VNC server on a CentOs or Redhat server


To set up VNC properly, so that you have access to the local
default X console of your server as if you are sitting in front
of the physical server.
follow these steps.

On the server, type vncpasswd as root to set a VNC password.
You will use this password when connecting with vncviewer

Edit the file /etc/X11/xorg.conf

In the stanza called Screen, add this line:
Option "passwordFile" "/root/.vnc/passwd"

then
add in the following lines at the end of the file:

Section "Module"
Load "glx"
Load "dbe"

Load "extmod"

Load "freetype"

Load "type1"

Load "dri"
Load "vnc"
EndSection

save the file

Allow the ports in the iptables Firewall
by typing the following:

system-config-securitylevel

In the "Other ports", add the following range.

5900-5904

Save and close the tool then restart the firewall by typing the following:
service iptables restart or /etc/init.d/iptables restart

type

chkconfig vncserver on

to have vncserver automatically start when the server next boots up.

Then finally RESTART the server.




Friday, October 29, 2010

recovering from a read only / mount

When the boot process aborts upon failing to find a removed or failed hard disk due to the system not finding the device that your /etc/fstab file references , it asks for a password and gives you the option to drop into maintenance mode , however when in maintenance mode you are unable to edit your /etc/fstab file to fix the problem since your / partition is mounted Read only!

to fix the situation simply type

mount -n -o remount /
will remount the / partition in rw mode and you can now edit /etc/fstab and remove the
line with the faulty disk or wrong entry, and then reboot as normal.

Sunday, August 22, 2010

Encrypt a file whilst in Vim


Encrypt File in Vim
Save and encrypt the current file:
:X
Enter encryption key: ********
Enter same key again: ********
Once you’ve encrypted a file using :X, the next time you open that file, Vim
will prompt for the encryption key.

Tuesday, May 25, 2010

How to Upgrade from Fedora 12 to Fedora 13 (32 bit and 64 bit versions)


Do the following as root.

download latest fedora repos

For 32 bit version type:

wget ftp://download.fedora.redhat.com/pub/fedora/linux/releases/13/Everything/i386/os/Packages/fedora-release-13-1.noarch.rpm

or for 64 bit version type:

wget ftp://download.fedora.redhat.com/pub/fedora/linux/releases/13/Everything/x86_64/os/Packages/fedora-release-13-1.noarch.rpm

import gpg-key

rpm --import ftp://download.fedora.redhat.com/pub/fedora/linux/releases/13/Everything/i386/os/RPM-GPG-KEY-fedora-i386

or for 64 bit version type:

rpm --import ftp://download.fedora.redhat.com/pub/fedora/linux/releases/13/Everything/x86_64/os/RPM-GPG-KEY-fedora-i386

install rpmlibs dependency. Required to install fedora-release-13

yum install rpm-libs -y

upgrade fedora release

rpm -Uvh fedora-release-13-1.noarch.rpm

upgrade fedora distro

yum upgrade -y

Reboot and Enjoy