Linux configuration files
Here are a few useful Linux configuration files to get your installation setup and working just fine.
~/.vimrc. This is to setup the VIM editor and make it easier to use for the average Linux user.
" ~/.vimrc (configuration file for vim only) " skeletons function! SKEL_spec() 0r /usr/share/vim/current/skeletons/skeleton.spec language time en_US if $USER != '' let login = $USER elseif $LOGNAME != '' let login = $LOGNAME else let login = 'unknown' endif let newline = stridx(login, "\n") if newline != -1 let login = strpart(login, 0, newline) endif if $HOSTNAME != '' let hostname = $HOSTNAME else let hostname = system('hostname -f') if v:shell_error let hostname = 'localhost' endif endif let newline = stridx(hostname, "\n") if newline != -1 let hostname = strpart(hostname, 0, newline) endif exe "%s/specRPM_CREATION_DATE/" . strftime("%a\ %b\ %d\ %Y") . "/ge" exe "%s/specRPM_CREATION_AUTHOR_MAIL/" . login . "@" . hostname . "/ge" exe "%s/specRPM_CREATION_NAME/" . expand("%:t:r") . "/ge" setf spec endfunction autocmd BufNewFile *.spec call SKEL_spec() " filetypes filetype plugin on filetype indent on " ~/.vimrc ends here set nu set wrap |
My comprehensive ~/.bashrc file. This will really help out when using the bash shell on Linux.
#!/bin/bash # mode:shell-script # sh-shell:bash # Modified to work on Open Solaris. Much better than FreeBSD. # There are still problems with ls but I am working on that. # Bejiitas Wrath ~/.bashrc. [ -f /etc/bashrc ] && . /etc/bashrc [ -f /etc/profile ] && . /etc/profile if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi OSRELEASE=`uname -ir`; LD_LIBRARY_DIR=$LD_LIBRARY_DIR:/home/gandalf/opt/lib PATH=$PATH:/home/gandalf/opt/bin NUM=`mynum`; # Author: John Cartwright. # Website: http://members.tripod.com/bejiitas_wrath/ # I am including many useful if statements in this # .bashrc so that if a needed program is not installed # it will still give some alternate output. # try to set DISPLAY smart (from Hans) :) # From a SUSE .bashrc file. if test -z "$DISPLAY" -a "$TERM" = "xterm" -a -x /usr/bin/who ; then WHOAMI="`/usr/bin/who am i`" _DISPLAY="`expr "$WHOAMI" : '.*(\([^\.][^\.]*\).*)'`:0.0" if [ "${_DISPLAY}" != ":0:0.0" -a "${_DISPLAY}" != " :0.0" \ -a "${_DISPLAY}" != ":0.0" ]; then export DISPLAY="${_DISPLAY}"; fi unset WHOAMI _DISPLAY fi if [ "$PS1" ]; then export HISTCONTROL=ignoredups export EDITOR=vim # Which one suits you? export WINDOWMANAGER=gnome-session export DOOMWADDIR="/usr/local/games" # For doom! # These two examples from bash-doc. export PAGER="/usr/bin/less" export LESS="-i -e -M -P%t?f%f :stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-..." shopt -s checkwinsize alias dir='ls --format="vertical"' alias vdir='ls --format="long"' alias me='who am i' alias verbosetree='tree -A -s -p -f --dirsfirst' alias psverbose='ps u a x f g' alias ll='ls -l | sort -nr' alias la='ls -A' alias l='ls -CF' alias dsize="du -ack | sort -nr | head -n 20" alias psview="pstree -a -u -G -l -h -p" # These following functions from http://www.die.net/doc/linux/abs-guide/sample-bashrc.html function my_ip() # get IP adresses. Bracket on next line C style... { MY_IP=$(/sbin/ifconfig ppp0 | awk '/inet/ { print $2 } ' | sed -e s/addr://) MY_ISP=$(/sbin/ifconfig ppp0 | awk '/P-t-P/ { print $3 } ' | sed -e s/P-t-P://) } function lowercase() # move filenames to lowercase. { for file ; do filename=${file##*/} case "$filename" in */*) dirname==${file%/*} ;; *) dirname=.;; esac nf=$(echo $filename | tr A-Z a-z) newname="${dirname}/${nf}" if [ "$nf" != "$filename" ]; then mv "$file" "$newname" echo "lowercase: $file --> $newname" else echo "lowercase: $file not changed." fi done } function badlink() # From Atomic magazine #43 August 2004. { DEFAULT=$(tput sgr0); FILELIST=.badlink.list [ -e $FILELIST ] && $( rm -fr $FILELIST ) function checklink() { for badlink in $1/*; do [ -h "$badlink" -a ! -e "$badlink" ] && echo \ \"$badlink\" >> $FILELIST [ -d "$badlink" ] && checklink $badlink done } for directory in `pwd`; do if [ -d $directory ] ; then checklink $directory; fi done if [ -e $FILELIST ] ; then for line in $(cat $FILELIST); do echo $line | xargs -r rm | echo -e "$line -removed" done rm -fr $FILELIST else printf "Bad symlinks not found." fi } # End atomic function. # Setting the value of the Xterm title. # Only if we are in X... if [ $DISPLAY ] ; then PROMPT_COMMAND='echo -ne "\033]0;${USER}@${OSRELEASE}: ${PWD}\007"' fi # Done... case $TERM in # Testing for either xterm or rxvt or uxvt or uxterm... # etc. Works in a xterm on Open Solaris just fine.. *term | *xvt ) PS1='\n[ \e[041m\e[40m\e[37m\e[1m\u@${OSRELEASE}\e[41m\e[0m ]\n[ \e[033mJobs \j.\e[0m \ \e[30m\e[41m\e[1m\e[33mPWD: \w. \s \V.\e[0m ] [\e[4m \#-:\$ \e[0m]\n-> ' ;; esac fi # Outside of X we use this! if [ "$TERM" == "linux" ]; then PS1='\e[31m\e[40m\e[37m\e[1m\u@${OSRELEASE}.\e[0m\n \e[30m\e[41m\e[1m\e[33mPWD: \ \w.\e[0m \s.\n \V. \# \$> ' fi # Outside of xinit we use this! For Open Solaris. Which rules over FreeBSD Btw. if [ "$TERM" == "sun-color" ]; then PS1='\u@${OSRELEASE}.\n PWD: \w. \s.\n \V. \# \$> ' fi # The following code from http://www.die.net/doc/linux/abs-guide/sample-bashrc.html if [ "${BASH_VERSION%.*}" \< "2.05" ]; then echo "You will need to upgrade to version 2.05 for programmable completion" return fi shopt -s extglob # necessary set +o nounset # otherwise some completions will fail complete -A hostname rsh rcp telnet rlogin r ftp ping disk complete -A command nohup exec eval trace gdb complete -A command command type which complete -A export printenv complete -A variable export local readonly unset complete -A enabled builtin complete -A alias alias unalias complete -A function function complete -A user su mail finger complete -A helptopic help # currently same as builtins complete -A shopt shopt complete -A stopped -P '%' bg complete -A job -P '%' fg jobs disown complete -A directory mkdir rmdir complete -A directory -o default cd complete -f -d -X '*.gz' gzip complete -f -d -X '*.bz2' bzip2 complete -f -o default -X '!*.gz' gunzip complete -f -o default -X '!*.bz2' bunzip2 complete -f -o default -X '!*.pl' perl perl5 complete -f -o default -X '!*.ps' gs ghostview ps2pdf ps2ascii complete -f -o default -X '!*.dvi' dvips dvipdf xdvi dviselect dvitype complete -f -o default -X '!*.pdf' acroread pdf2ps complete -f -o default -X '!*.+(pdf|ps)' gv complete -f -o default -X '!*.texi*' makeinfo texi2dvi texi2html texi2pdf complete -f -o default -X '!*.tex' tex latex slitex complete -f -o default -X '!*.lyx' lyx complete -f -o default -X '!*.+(jpg|gif|xpm|png|bmp)' xv gimp complete -f -o default -X '!*.mp3' mpg123 complete -f -o default -X '!*.ogg' ogg123 #=====================================================================================# # This is a 'universal' completion function - it works when commands have # a so-called 'long options' mode , ie: 'ls --all' instead of 'ls -a' _universal_func () { case "$2" in -*) ;; *) return ;; esac case "$1" in \~*) eval cmd=$1 ;; *) cmd="$1" ;; esac COMPREPLY=( $("$cmd" --help | sed -e '/--/!d' -e 's/.*--\([^ ]*\).*/--\1/'| \ grep ^"$2" |sort -u) ) } complete -o default -F _universal_func ldd wget bash id info _make_targets () { local mdef makef gcmd cur prev i COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} # if prev argument is -f, return possible filename completions. # we could be a little smarter here and return matches against # `makefile Makefile *.mk', whatever exists case "$prev" in -*f) COMPREPLY=( $(compgen -f $cur ) ); return 0;; esac # if we want an option, return the possible posix options case "$cur" in -) COMPREPLY=(-e -f -i -k -n -p -q -r -S -s -t); return 0;; esac # make reads `makefile' before `Makefile' if [ -f makefile ]; then mdef=makefile elif [ -f Makefile ]; then mdef=Makefile else mdef=*.mk # local convention fi # before we scan for targets, see if a makefile name was specified # with -f for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do if [[ ${COMP_WORDS[i]} == -*f ]]; then eval makef=${COMP_WORDS[i+1]} # eval for tilde expansion break fi done [ -z "$makef" ] && makef=$mdef # if we have a partial word to complete, restrict completions to # matches of that word if [ -n "$2" ]; then gcmd='grep "^$2"' ; else gcmd=cat ; fi # if we don't want to use *.mk, we can take out the cat and use # test -f $makef and input redirection COMPREPLY=( $(cat $makef 2>/dev/null | awk 'BEGIN {FS=":"} /^[^.# ][^=]*:/ {print $1}' | tr -s ' ' '\012' | sort -u | eval $gcmd ) ) } complete -F _make_targets -X '+($*|*.[cho])' make gmake pmake _configure_func () { case "$2" in -*) ;; *) return ;; esac case "$1" in \~*) eval cmd=$1 ;; *) cmd="$1" ;; esac COMPREPLY=( $("$cmd" --help | awk '{if ($1 ~ /--.*/) print $1}' | grep ^"$2" | sort -u) ) } complete -F _configure_func configure # cvs(1) completion _cvs () { local cur prev COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} if [ $COMP_CWORD -eq 1 ] || [ "${prev:0:1}" = "-" ]; then COMPREPLY=( $( compgen -W 'add admin checkout commit diff \ export history import log rdiff release remove rtag status \ tag update' $cur )) else COMPREPLY=( $( compgen -f $cur )) fi return 0 } complete -F _cvs cvs _killall () { local cur prev COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} # get a list of processes (the first sed evaluation # takes care of swapped out processes, the second # takes care of getting the basename of the process) COMPREPLY=( $( /usr/bin/ps -u $USER -o comm | \ sed -e '1,1d' -e 's#[]\[]##g' -e 's#^.*/##'| \ awk '{if ($0 ~ /^'$cur'/) print $0}' )) return 0 } complete -F _killall killall killps # End: Bejiitas Wrath .bashrc. |
Sample ~/.bash_profile that contains a line to set the PATH variable to include the ~/bin directory to allow the user to execute binaries from their home directory.
# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin export PATH |
My ~/.bash_aliases file. You need this to go with the ~/.bashrc above.
alias cls='clear' alias lu='ls -Fula' alias tarunpack='tar -zxvf' alias bz2unpack='tar -jxvf' alias me='who am i' alias verbosetree='tree -A -s -p -f --dirsfirst' alias psverbose='ps u a x f g' alias dsize="du -ack | sort -nr | head -n 20" alias psview="pstree -a -u -G -l -h -p" alias dir='ls -Fula' |
An ~/.Xdefaults file to setup various Xorg settings automatically. Especially to configure the Xterm settings.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! !! User Specific Settings !! !! !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! !! File: ~/.Xdefaults !! !! Version: Indy-1.0.0 !! !! Last modified: June 1st 2017 !! !! !! !! By who: Eric Masson !! !! Contact: eric.masson@genirix.com !! !! !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! *toolchest.clientDecoration: title -border *toolchest.clientFunctions: -resize -minimize -maximize ! *toolchest*fontList: -adobe-helvetica-bold-o-normal--14-* *toolchest*renderTable: xft *toolchest*xft*fontType: FONT_IS_XFT *toolchest*xft*fontName: Sans *toolchest*xft*fontSize: 10 *toolchest*xft*fontStyle: normal !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! New cursor resources for Desktop, ViewKit and MaXX Desktop based applications. !! !! *pointerColor: the foreground color !! *pointerColorBackground: the background or the border !! !! The default (fallback) colors for the foreground and backround are red !! and white respectively. Both 5Dwm and toolchest make used of these !! resources to setup their cursors appearance. All MaXX applications !! will make used of these resources to garanty an even look and feel. ! *pointerColor: red *pointerColorBackground: white *darkBackground: true !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! !! USER OVERRIDE for 5DWM WINDOWS MANAGER Settings !! !! !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! *rootButtonClick: True *showFeedback: move placement restart quit *keyboardFocusPolicy: explicit ! *keyboardFocusPolicy: pointer ! *interactivePlacement: False *freezeOnConfig: False *moveOpaque: True *sessionClientDB: .mwmclientbd *useIconBox: false !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! Generic Motif Widgets Settings ! *XmScale.highlightThickness: 0 ! *XmScrolledWindow.borderWidth: 1 *XmMessageBox*XmScale.slidingMode: XmTHERMOMETER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! !! X11 Application Specific Settings (client) !! !! !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! *renderTable: xft ! *xft*fontType: FONT_IS_XFT ! *xft*fontName: Sans-8 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! XTerm, winterm, gnome-terminal Settings ! *XTerm*saveLines: 5000 *XTerm*scrollBar: True *xterm*VT100.Translations: #override\n\ <KeyPress>Prior : scroll-back(1,page)\n\ <KeyPress>Next : scroll-forw(1,page) ! end of .Xdefaults |
The ~/.bash_logout file is another one that is very useful, it runs commands when the user logs out. Put together, these files would be very good to setup a nice Linux user account.