Reply
Thread Tools
Posts: 86 | Thanked: 24 times | Joined on Jan 2008
#1
Hey-oh, I've gotten tons of useful information from this forum, so I'll try to provide some of the things I've come up with, starting with my bashrc file. The thing is, I've been reluctant to post tips because most of what I've done is based on years of using Linux, so I'll try to make everything as easy to understand as possible.

For those using BASH and xterm, I've been using a modified version of the bashrc file that I use on my workstations. I use a number of aliases, and for those who are new to working in a terminal, aliases are an easy way to create shortcuts for commands you use on the command line. Instead of typing out an entire command, you just type the alias. Also, my bashrc file provides an easy way to set the colors for the prompt. Instead of figguring color codes, you just need to change the color names in the prompt settings.

You'll need to install BASH (in maemo-extras) to use these. You'll also need to install 'coreutils-gnu' (from Titan: http://maemo.org/packages/view/coreutils-gnu/) for many of these to work. Secondly, I use a central bashrc file that I link to both the 'user' and 'root' accounts. So, put your bashrc file in /etc/, and then as root:

Code:
rm /root/.bashrc
ln -s /etc/bashrc /root/.bashrc
rm /home/user/.bashrc
ln -s /etc/bashrc /home/user/.bashrc
To make bash your default shell:
Code:
echo "bash" >> /home/user/.profile
echo "bash" >> /root/.profile
Note: I believe there are other ways of setting coreutils-gnu and BASH as default. The above works for me.

This is an abbreviated bashrc file I use. I've added lots of comments to try to make it easier to understand. IMPORTANT -- I use these; however, if you are not sure what you're doing, please be careful. Also be careful of the line breaks. The long lines below are wrapped. You'll need to add and edit this as root:

Download: http://burmashave.net/media/files/bashrc.gz

/etc/bashrc :

Code:
# /etc/.bashrc: executed by bash(1) for non-login shells.

# This attempts to set wrapping properly on remote shells.
shopt -s checkwinsize

# This sets default file permissions for new files.
umask 022

# This sets nano as the default editor. (May not be needed)
export EDITOR="/usr/bin/nano -w"

#
# Set colors for prompt
#

# Color Codes
col_bold="\033[1m"
col_red="\033[1;31m"
col_green="\033[1;32m"
col_yellow="\033[1;33m"
col_blue="\033[1;34m"
col_purple="\033[1;35m"
col_cyan="\033[1;36m"
col_normal="\033[0;39m"

# Prompt Settings
# PS1
if [ $USER == "root"  ]
  then
    PS1="\[${col_red}\]\u@n900 \[${col_blue}\]\W \$ \[${col_normal}\]"
  else
    PS1="\[${col_purple}\]\u@n900 \[${col_blue}\]\W \$ \[${col_normal}\]"
fi

export PS1

# SSH aliases
# I use aliases to make SSH connections easier. 
# This is an example. Edit for your own.
#alias some_machine='/usr/bin/ssh -l myuser 10.0.0.10'

#
# General Aliases
#

# I sometimes use this to keep alive SSH connections.
# Replace IP address with IP address of the SSH target.
alias alive='ping 10.0.0.10'

# This synchronizes time, and can be used by fcron.
# See http://tf.nist.gov/tf-cgi/servers.cgi for more servers.
alias synctime='ntpdate -b nist1-ny.ustiming.org'

# This ensures ls shows color. (You'll need to install 'dir_colors'from Titan)
alias ls='ls --color=auto'

# Sometimes, I want ls without color
alias lsc='ls --color=never'

# Find files recursively by name. Use quotation marks if using wildcards.
# Example: fn "*some_file_name*"
alias fn='/usr/bin/find ./ -name'

# Set df to default to human readable totals
alias df='df -h'

# Edit bashrc file
alias ebash='/usr/bin/nano -w /etc/bashrc'

# Find specific process. I use this one a lot. Wildcards not needed.
# Example: psg trackerd
alias psg='ps -e | grep'

# Find a previously executed command. I also use this one a lot.
# Wildcards not needed.
# Example: recal cp
# To execute a previous command, precede the command number with a bang (!)
# Example: !527
alias recal='history | grep'

# Prevent nano from wrapping long lines.
alias nano='/usr/bin/nano -w'


#
# Maemo Specific Aliases
#

# Clear the tracker databases
alias clearcache='tracker-processes --hard-reset'
# Make it easy to jump to specific file system locations
alias hm='cd /home/user'
alias md='cd /home/user/MyDocs'
alias im='cd /home/user/MyDocs/.images'

#
# ls Colors
#

# The default ls colors make some entries difficult to read, 
# especially because so many directories are world-readable.
# These are the colors I use. You can use the info at this link:
# http://linux-sxs.org/housekeeping/lscolors.html
# to customize these colors

LS_COLORS='di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:tw=01;42:ow=01;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.zip=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.cpio=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.avi=01;35:*.flv=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.mid=00;36:*.midi=00;36:*.mp3=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36'
export LS_COLORS

# 
# PATH's
#

# These are custom PATH's. I think the most important is the first.
# It causes the gnu-core utilities to be used instead of the ones in
# BusyBox. Also, I use '/usr/local/bin' and '/usr/local/sbin' for 
# my scripts.
export PATH="/usr/bin/gnu:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin"

Last edited by burmashave; 2011-01-15 at 21:10.
 

The Following 4 Users Say Thank You to burmashave For This Useful Post:
Posts: 838 | Thanked: 3,384 times | Joined on Mar 2009
#2
Originally Posted by burmashave View Post

To make bash your default shell:
Code:
echo "bash" >> /home/user/.profile
echo "bash" >> /root/.profile
Note: I believe there are other ways of setting coreutils-gnu and BASH as default. The above works for me.
That works for me too, but I didn't like it, because then I must use 'exit;exit' to 'exit'.

So this is my way:
Code:
ln -s /etc/bashrc /root/.bash_profile
ln -s /etc/bashrc /home/user/.bash_profile
And change file /etc/passwd
-/bin/sh
+/bin/bash
For root and user.


And I prefer nano with -c (always show row number in bottom bar) and -x (hidden help-bar)
 
Posts: 838 | Thanked: 3,384 times | Joined on Mar 2009
#3
Originally Posted by epitaph View Post
Exit to what? From root to user? From root/user to desktop? Can you elaborate? Thank you!
All of these close only bash and drop me to sh.
a) exit when closing xterminal
b) exit when disconnecting ssh-connection from computer
c) exit when ending root-usage

I have started /bin/sh first (from login) and then /bin/bash (from .profile), so I think this is very normal behaving.
 
Posts: 838 | Thanked: 3,384 times | Joined on Mar 2009
#4
Originally Posted by epitaph View Post
What about my former post? Did you read it? Did you consider to patch gainroot script? I don't have this problem and I don't like your solution!
I saw patched gainroot, but I didn't understand it. And I do not understand how it can prevent other exit-cases than root->user. But if it works for you and you do not have any problem with 'exit', my solution (or workaround) is totally useless for you.
 
Reply


 
Forum Jump


All times are GMT. The time now is 09:44.