Archive for the ‘Linux tips’ Category

Linux Tip: Some useful GNU/Linux tweaks

Tuesday, August 18th, 2009

GNU/Linux is a great customizable Operating System, so are we can really customizing to our needs, well, many of us are not bothering to modify the defaults. I found some tweeks while searching for some thing else. Here are some of them which might come in handy at times.

  1. Change FileManager: Though nautilus is a great file manager, but some prefer other file managers like a thunar, dolphin, PCMan, etc may be for speed, looks or whatever. Here is a way to do it.
    Open Terminal, type in command gconf-editor to open gnome configuration editor.
    In gconf-editor navigate through / –> desktop –> gnome –> session –> required_components –> double click on filemanager and change the value to new file manager command. You can also change panel, window manager navigating through same path.
    (more…)

Linux Tip: Email Alert on Root Partition Almost Full

Friday, August 14th, 2009

GNU/Linux is known for its stability and reliability, but there are times when a GNU/Linux system may not work at all due to not having enough space on its root partition without any notification. So how will one know that this is the error, unless one has troubleshooting experiences. Don’t worry there is a simple solution. The following command will echo the amount of disk space used on root partition

echo df / | grep / | awk ‘{ print $5}’

Description: df / —> disk free of root partition,   grep / —>select line with root partition,  awk ‘{ print $5}’ —> gets the 5th parameter.

Now you can create a script, which can be added to crontab and email you whenever the disk free space is less than critical amount say 10%. Here is a sample script,

#!/bin/bash
CURRENT=$(df / | grep / | awk ‘{ print $5}’ | sed ’s/%//g’)
THRESHOLD=90

if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
mail -s “Disk Space Alert” mail@domainname.com << EOF
Your root partition remaining free space is critically low. Used: $CURRENT%
EOF
fi (more…)

Linux Tip: Password protect Windows GRUB entries

Tuesday, August 4th, 2009

After a GNU/Linux operating system installation, we install a boot loader usually GRUB. For security we prevent single user more and GRUB console but never care for a Windows based OS like XP, if there is one. So the intruder can log into windows and access our data easily. But there is a solution for locking Windows OS like XP, here is how it is,

Open menu.lst file

vi /boot/grub/menu.lst

Replace

title        Windows XP Home
rootnoverify    (hd0,X)
savedefault
chainloader    +1

With

title        Windows XP Professional x64 Edition
rootnoverify    (hd0,2)
savedefault
chainloader    +1
lock
password –md5 <pasword-hash>

Where password-hash can be generated shown below

type in grub as root in command line, a grub console will open, then type this

grub>md5crypt

Password: password

Encrypted: $1$QQwJ9/$p35XqOCfCgrpbQDsFgIaL1 —> This is password-hash for password

This can be extended for other grub entries

Linux Tip: How to change bash shell primary & secondary prompts

Wednesday, July 29th, 2009

Command line is most important for any GNU/Linux advanced user, so why don’t we customize the prompts which is displayed on terminal all the time? well, here is how to do it.

  • Primary Prompt is stored in variable PS1,
    1. To view, type the command: $echo $PS1
    2. To modify, type the command: $export PS1=”example:~$”
  • Secondary Prompt is stored in variable PS2,
    1. To view, type the command: $echo $PS2
    2. To modify, type the command: $export PS2=”>>”

Linux Tip: Bash history related commands

Monday, July 27th, 2009

Here are some handy history related commands,

  • history: this command shows the list of commands which were keyed in previously on command line.
    If you want last 10 to be displayed: history | tail -10, ~/bash_history file stores the history.
    E.g. $history | tail -5    —> Displays the last 5 commands keyed in.
  • !!: Repeat previous command
    E.g. $!!   —> Executes previously executed command
  • !string: Repeat the previous command from the history whose first chars match string
    E.g. $!ca —> Executes the previous executed command starting with ca, say cat command

  • !n: Repeat the nth command from the history
    E.g. $!500 —> Executes 500th command in the history file

CC License
This work by Mallikarjun is licensed under a Creative Commons Attribution 2.5 India.