Tuesday 5 February 2013

Changing Command Prompt in Linux

Problem: Changing Command Prompt in Linux.
Solution: By default when you logged into terminal. You will see prompt as "[root@mydesktop build]#" (i.e)
[user@hostname current-workingdir]#. If you want to change these prompt settings change the environment variable PS1

To know default value:
[root@mydesktop build]# echo $PS1
[\u@\h \W]\$
To change value:
[root@mydesktop build]#export PS1='[\u@dragon \W]\$'
[root@dragon build]#

The values are lost when terminal is closed. To persist values for ever update file "/root/.bashrc"
My Bash file:
[root@dragon ~]#cat .bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
export PS1='[\u@dragon \W]\$'


Monday 4 February 2013

set mysql root user password

Problem: Set password for mysql root user
Solution: The default installation of mysql on CentOS doesnt set password for root user. To set password for root user type below command.



 [root@dragon ~]# mysqladmin -u root password root 

The password for the root user we are setting here is root