Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi. its now doin' 1 week that I'm usin' linux (Mandriva). It's my first nix OS and i decided to edit my .bashrc. I Think i'm the first to paste a .bashrc example script . This can maybe cool to add a place on the forum just for .bashrc scripting!!! So here is my personal .bashrc
NORMAL USERs (/home/frz/.bashrc)
Quote:
# .bashrc
# User specific aliases and functions
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Prompt konsol shell
PS1="[\u@\H \W] "
#### Perso ####
#############
# Défini les couleurs
BLACK='\e[0;30m'
BLUEF='\e[0;34m'
BLUEP='\e[1;34m'
GREENF='\e[0;32m'
GREENP='\e[1;32m'
CYANF='\e[0;36m'
CYANP='\e[1;36m'
REDF='\e[0;31m'
REDP='\e[1;31m'
PURPLEF='\e[0;35m'
PURPLEP='\e[1;35m'
BROWNF='\e[0;33m'
BROWNP='\e[1;33m'
GRAYF='\e[0;37m'
GRAYP='\e[1;37m'
YELLOW='\e[1;33m'
WHITE='\e[1;37m'
NC='\e[0m' # No Color
# Message de bienvenue
clear
# Message de bienvenue
if [ "$USER" = "mathieu" ]; then
echo -e "${REDP}Welcome master. You are logged on $HOSTNAME.${NC}"
uname -a
echo ""
else
echo -e "${REDP}Welcome $USER. You are logged on $HOSTNAME.${NC}"
uname -a
echo ""
fi
# Aliases (variables)
alias home='cd /home'
alias frz='cd ~'
alias desktop='cd /home/frz/Desktop'
alias frzd='cd /home/frz/Desktop/frz'
alias lsa='ls -Al' # List all files (+hidden files)
# Functions
function cmds() # savoir mes commandes
{
echo -e "\n${REDP}Liste des commandes:"
echo -e "${GREENP} -Alias-"
echo -e "${BLUEP}aliasp: ${NC}Liste les commandes alias persos."
echo -e "\n${GREENP} -Functions-"
echo -e "${BLUEP}clog: ${NC}Clear les logs."
echo -e "${BLUEP}info: ${NC}Informations sur la session ouverte et l'ordinateur."
echo ""
}
function aliasp() #savoir mes alias
{
echo -e "\n${REDP}Liste des aliases persos:"
echo -e "${BLUEP}home: ${NC}Dossier home (~)."
echo -e "${BLUEP}frz: ${NC}Dossier frz."
echo -e "${BLUEP}desktop: ${NC}Dossier Desktop."
echo -e "${BLUEP}frzd: ${NC}Dossier frz sur le desktop."
echo -e "${BLUEP}lsa: ${NC}Liste tout les fichiers + fichiers cachés."
echo ""
}
function colors()
{
echo -e "\n${REDP}Code de couleurs:"
echo -e "${BLUEF}BLUEF ${NC}<--> ${BLUEP}BLUEP"
echo -e "${GREENF}GREENF ${NC}<--> ${GREENP}GREENP"
echo -e "${CYANF}CYANF ${NC}<--> ${CYANP}CYANP"
echo -e "${REDF}REDF ${NC}<--> ${REDP}REDP"
echo -e "${PURPLEF}PURPLEF ${NC}<--> ${PURPLEP}PURPLEP"
echo -e "${BROWNF}BROWNF ${NC}<--> ${BROWNP}BROWNP"
echo -e "${GRAYF}GRAYF ${NC}<--> ${GRAYP}GRAYP"
echo -e "${YELLOW}YELLOW"
echo -e "${WHITE}WHITE"
echo -e "${NC}NC (NO COLOR)"
echo ""
}
function info() # avoir les infos dla session ouverte et pc
{
echo -e "\nYou are logged on ${BLUEP}$HOSTNAME"
echo -e "\n${REDP}Additionnal information:$NC " ; uname -a
echo -e "\n${REDP}Users logged on:$NC " ; w -h
echo -e "\n${REDP}Current date :$NC " ; date
echo -e "\n${REDP}Machine stats :$NC " ; uptime
echo -e "\n${REDP}Memory stats :$NC " ; free
my_ip 2>&- ;
echo -e "\n${REDP}Local IP Address :$NC" ; echo ${MY_IP:-"Not connected"}
echo -e "\n${REDP}ISP Address :$NC" ; echo ${MY_ISP:-"Not connected"}
echo ""
}
function clog() # Clear les logs
{
if [ "$UID" = "0" ]; then # 0 = level r00t
cd /var/log
cat /dev/null > messages
cat /dev/null > wtmp
echo -e "${REDP}Logs cleaned up.${NC}"
echo ""
else
echo -e "${REDP}That cmd request a r00t access.${NC}"
echo ""
fi
}
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Prompt konsol shell
PS1="[\u@\H \W] "
#### Perso ####
#############
# Défini les couleurs
BLACK='\e[0;30m'
BLUEF='\e[0;34m'
BLUEP='\e[1;34m'
GREENF='\e[0;32m'
GREENP='\e[1;32m'
CYANF='\e[0;36m'
CYANP='\e[1;36m'
REDF='\e[0;31m'
REDP='\e[1;31m'
PURPLEF='\e[0;35m'
PURPLEP='\e[1;35m'
BROWNF='\e[0;33m'
BROWNP='\e[1;33m'
GRAYF='\e[0;37m'
GRAYP='\e[1;37m'
YELLOW='\e[1;33m'
WHITE='\e[1;37m'
NC='\e[0m' # No Color
# Message de bienvenue
if [ "$UID" = "0" ]; then
echo -e "${REDP}Your are not logged as r00t on $HOSTNAME.${NC}"
uname -a
echo ""
else
echo -e "${REDP}Welcome $USER. You are logged on $HOSTNAME.${NC}"
uname -a
echo ""
fi
# Aliases (variables)
alias home='cd /home'
alias frz='cd ~'
alias desktop='cd /home/frz/Desktop'
alias frzd='cd /home/frz/Desktop/frz'
alias lsa='ls -Al' # List all files (+hidden files)
# Functions
function cmds() # savoir mes commandes
{
echo -e "\n${REDP}Liste des commandes:"
echo -e "${GREENP} -Alias-"
echo -e "${BLUEP}aliasp: ${NC}Liste les commandes alias persos."
echo -e "\n${GREENP} -Functions-"
echo -e "${BLUEP}clog: ${NC}Clear les logs."
echo -e "${BLUEP}info: ${NC}Informations sur la session ouverte et l'ordinateur."
echo ""
}
function aliasp() #savoir mes alias
{
echo -e "\n${REDP}Liste des aliases persos:"
echo -e "${BLUEP}home: ${NC}Dossier home (~)."
echo -e "${BLUEP}frz: ${NC}Dossier frz."
echo -e "${BLUEP}desktop: ${NC}Dossier Desktop."
echo -e "${BLUEP}frzd: ${NC}Dossier frz sur le desktop."
echo -e "${BLUEP}lsa: ${NC}Liste tout les fichiers + fichiers cachés."
echo ""
}
function colors()
{
echo -e "\n${REDP}Code de couleurs:"
echo -e "${BLUEF}BLUEF ${NC}<--> ${BLUEP}BLUEP"
echo -e "${GREENF}GREENF ${NC}<--> ${GREENP}GREENP"
echo -e "${CYANF}CYANF ${NC}<--> ${CYANP}CYANP"
echo -e "${REDF}REDF ${NC}<--> ${REDP}REDP"
echo -e "${PURPLEF}PURPLEF ${NC}<--> ${PURPLEP}PURPLEP"
echo -e "${BROWNF}BROWNF ${NC}<--> ${BROWNP}BROWNP"
echo -e "${GRAYF}GRAYF ${NC}<--> ${GRAYP}GRAYP"
echo -e "${YELLOW}YELLOW"
echo -e "${WHITE}WHITE"
echo -e "${NC}NC (NO COLOR)"
echo ""
}
function info() # avoir les infos dla session ouverte et pc
{
echo -e "\nYou are logged on ${BLUEP}$HOSTNAME"
echo -e "\n${REDP}Additionnal information:$NC " ; uname -a
echo -e "\n${REDP}Users logged on:$NC " ; w -h
echo -e "\n${REDP}Current date :$NC " ; date
echo -e "\n${REDP}Machine stats :$NC " ; uptime
echo -e "\n${REDP}Memory stats :$NC " ; free
my_ip 2>&- ;
echo -e "\n${REDP}Local IP Address :$NC" ; echo ${MY_IP:-"Not connected"}
echo -e "\n${REDP}ISP Address :$NC" ; echo ${MY_ISP:-"Not connected"}
echo ""
}
function clog() # Clear les logs
{
if [ "$UID" = "0" ]; then # 0 = level r00t
cd /var/log
cat /dev/null > messages
cat /dev/null > wtmp
echo -e "${REDP}Logs cleaned up.${NC}"
echo ""
else
echo -e "${REDP}That cmd request a r00t access.${NC}"
echo ""
fi
}
You can also make just one bashrc with more if, elif, then, else in the /etc/ U must change the welcome message! Example:
Quote:
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# by default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
umask 002
else
umask 022
fi
# are we an interactive shell?
if [ "$PS1" ]; then
case $TERM in
xterm*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
;;
*)
;;
esac
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
if [ -z "$loginsh" ]; then # We're not a login shell
# Not all scripts in profile.d are compatible with other shells
# TODO: make the scripts compatible or check the running shell by
# themselves.
if [ -n "${BASH_VERSION}${KSH_VERSION}${ZSH_VERSION}" ]; then
for i in /etc/profile.d/*.sh; do
if [ -x $i ]; then
. $i
fi
done
fi
fi
fi
# Message de bienvenue
if [ "$UID" = "0" ]; then
echo -e "${REDP}You are not logged as r00t on $HOSTNAME.${NC}"
echo ""
elif [ "$USER" = "mathieu" ]; then
echo -e "${REDP}Welcome master. You are logged on $HOSTNAME.${NC}"
uname -a
echo ""
else
echo -e "${REDP}Welcome $USER. You are logged on $HOSTNAME.${NC}"
uname -a
echo ""
fi
# Aliases (variables)
alias home='cd /home'
alias frz='cd ~'
alias desktop='cd /home/frz/Desktop'
alias frzd='cd /home/frz/Desktop/frz'
alias lsa='ls -Al' # List all files (+hidden files)
# Functions
function cmds() # savoir mes commandes
{
echo -e "\n${REDP}Liste des commandes:"
echo -e "${GREENP} -Alias-"
echo -e "${BLUEP}aliasp: ${NC}Liste les commandes alias persos."
echo -e "\n${GREENP} -Functions-"
echo -e "${BLUEP}clog: ${NC}Clear les logs."
echo -e "${BLUEP}info: ${NC}Informations sur la session ouverte et l'ordinateur."
echo ""
}
function aliasp() #savoir mes alias
{
echo -e "\n${REDP}Liste des aliases persos:"
echo -e "${BLUEP}home: ${NC}Dossier home (~)."
echo -e "${BLUEP}frz: ${NC}Dossier frz."
echo -e "${BLUEP}desktop: ${NC}Dossier Desktop."
echo -e "${BLUEP}frzd: ${NC}Dossier frz sur le desktop."
echo -e "${BLUEP}lsa: ${NC}Liste tout les fichiers + fichiers cachés."
echo ""
}
function colors()
{
echo -e "\n${REDP}Code de couleurs:"
echo -e "${BLUEF}BLUEF ${NC}<--> ${BLUEP}BLUEP"
echo -e "${GREENF}GREENF ${NC}<--> ${GREENP}GREENP"
echo -e "${CYANF}CYANF ${NC}<--> ${CYANP}CYANP"
echo -e "${REDF}REDF ${NC}<--> ${REDP}REDP"
echo -e "${PURPLEF}PURPLEF ${NC}<--> ${PURPLEP}PURPLEP"
echo -e "${BROWNF}BROWNF ${NC}<--> ${BROWNP}BROWNP"
echo -e "${GRAYF}GRAYF ${NC}<--> ${GRAYP}GRAYP"
echo -e "${YELLOW}YELLOW"
echo -e "${WHITE}WHITE"
echo -e "${NC}NC (NO COLOR)"
echo ""
}
function info() # avoir les infos dla session ouverte et pc
{
echo -e "\nYou are logged on ${BLUEP}$HOSTNAME"
echo -e "\n${REDP}Additionnal information:$NC " ; uname -a
echo -e "\n${REDP}Users logged on:$NC " ; w -h
echo -e "\n${REDP}Current date :$NC " ; date
echo -e "\n${REDP}Machine stats :$NC " ; uptime
echo -e "\n${REDP}Memory stats :$NC " ; free
my_ip 2>&- ;
echo -e "\n${REDP}Local IP Address :$NC" ; echo ${MY_IP:-"Not connected"}
echo -e "\n${REDP}ISP Address :$NC" ; echo ${MY_ISP:-"Not connected"}
echo ""
}
function clog() # Clear les logs
{
if [ "$UID" = "0" ]; then # 0 = level r00t
cd /var/log
cat /dev/null > messages
cat /dev/null > wtmp
echo -e "${REDP}Logs cleaned up.${NC}"
echo ""
else
echo -e "${REDP}That cmd request a r00t access.${NC}"
echo ""
fi
}
Of course.. n00bs can learn A LOT with that on bashrc files dude.
Yeah. Like this:
Code:
function clog() # Clear les logs
{
if [ "$UID" = "0" ]; then # 0 = level r00t
cd /var/log
cat /dev/null > messages
cat /dev/null > wtmp
- Who "invented" this function or what distribution ships this as "standard"?
- Why do you think would zeroeing out logs and records be "better" than using standard logrotate utility?
Of course.. n00bs can learn A LOT with that on bashrc files dude.
Yeah. Like this:
Code:
function clog() # Clear les logs
{
if [ "$UID" = "0" ]; then # 0 = level r00t
cd /var/log
cat /dev/null > messages
cat /dev/null > wtmp
- Who "invented" this function or what distribution ships this as "standard"?
- Why do you think would zeroeing out logs and records be "better" than using standard logrotate utility?
What are you saying?, i posted that to look better with others merits, and you're telling people that publicly?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.