Linux Configurations. My general Linux tips and commands page.

  1. Linux Configurations.

Linux Configurations.

CD burning Tutorial. (Updated!) Burning Ghost Images.

Playing DVD discs on Debian Testing.

The Debian Stable distribution is a very fast and reliable distribution to play multimedia, the best player is the mplayer program. Install the mplayer application by typing su -c “apt-get install mplayer mplayer-gui”. Then the libdvdcss library which is necessary for playing DVD discs may be installed by visiting this page: http://download.videolan.org/pub/libdvdcss/1.2.9/ and downloading the libdvdcss-1.2.9.tar.bz2 tarball. Once this is downloaded, open a terminal window, navigate to the folder containing the tarball and unpack it thusly: tar -jxvf libdvdcss-1.2.9.tar.bz2, then enter the folder created and compile the library thusly.

./configure --prefix=/usr/local
make
make install

Once this is completed the DVD playback will work.

Finding out which package contains which utility on OpenSuse.

bash ~/$ cnf locate
 
locate: searching ...
The program 'locate' can be found in following packages:
  * findutils-locate [ path: /usr/bin/locate, repository: zypp (openSUSE-11.3 11.3-1.82) ]
  * findutils-locate [ path: /usr/bin/locate, repository: zypp (repo-oss) ]
 
Try installing with:
    sudo zypper install findutils-locate

Updating the Linux packages.

This is very easy on OpenSuse 11.3, just type these commands into a terminal prompt as root and press ENTER. This will update the package repositories and then download any required package updates and install them.

OpenSuse.

sudo zypper ref && sudo zypper up

Ubuntu.

sudo apt-get update && sudo apt-get upgrade

Copying a file in Linux.

Just type this command in the Terminal to copy a file such as a textfile from
one file to another. Like using /bin/cp.

/bin/dd bs=1 if=file1.txt of=file2.txt

Linux mencoder usage.

This script is off the mplayer mailing lists, it will encode a video into mpeg4 format that will play perfectly on a Sony Ericsson mobile phone. I have been looking for something like this for a while. The 3gp format is alright, but
mpeg4 is the way of the future. I am using 24 frames per second instead of 15, that looks better. I have a Sony Ericsson G502 and I had a W910i and this worked on both of them. You do not need more than 320×240 to view on a small mobile
screen, this gives you good quality.

#!/bin/sh
 
mencoder vidin.avi -ofps 24 -oac lavc -ovc lavc -lavcopts vglobal=1:\
aglobal=1:acodec=libfaac:abitrate=98:vcodec=mpeg4:level=31 -of lavf \
-lavfopts format=mp4 -vf scale=320:240 -o vidout.mp4

This is my mencoder.conf file which you put into the ~/.mplayer folder. I
have got these settings from various places on the web and I have only tried out
the mpeg4 profile yet but it worked perfectly transcoding a youtube video
download that had poor audio and video sync. Fixed it right up. You use these
profiles by typing, mencoder -profile [profilename] e,g mencoder -profile mpeg4.
Makes things easier.

[dvd-ntsc]
    profile-desc="MPEG2 (NTSC DVD) video AC3 audio"
    ovc=lavc=yes
    lavcopts=vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=18:vstrict=0:acodec=ac3:abitrate=192:autoaspect=yes
    of=mpeg=yes
    mpegopts=format=dvd:tsaf=yes
    vf=scale=720:480,harddup,softskip
    ofps=30000/1001
    srate=48000
    af=lavcresample=48000
    oac=lavc=yes
 
[dvd-ntsc-hq]
    profile-desc="MPEG2 HQ (NTSC DVD) video AC3 audio"
    profile=dvd-ntsc
    lavcopts=trell=yes:mbd=2:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:cbp=yes:mv0=yes:vqmin=1:lmin=1:dc=10
 
[mpeg4]
    profile-desc="MPEG4 video"
    ovc=lavc=1
    oac=mp3lame=1
    ovc=lavc=1
    oac=mp3lame=1
    lameopts=preset=standard
    lavcopts=vcodec=mpeg4:vbitrate=1200
 
[x264-mp4]
    profile-desc="H.264     MP4 DvD Rip Wide AAC (2.35:1) (960:400) Good files size and picture"
    vf=pullup,softskip,pp=fd,scale=960:-10,crop=960:400,hqdn3d,harddup
    lavfopts=format=mp4
    ovc=x264=yes
    x264encopts=level_idc=40:dct_decimate:me=hex:me_range=16:keyint=250:keyint_min=25:fast_pskip:partitions=all:8x8dct=yes:direct_pred=auto:nomixed_refs:trellis=1:nob_pyramid:b_adapt=1:weight_b:bframes=0:threads=auto:frameref=1:subq=6:crf=22
    ofps=29.97
    oac=faac=yes
    faacopts=br=160:mpeg=4:raw=yes:object=1
    of=lavf=yes
    af=volnorm=1

This script will transcode a video file or DVD to Divx format.

#!/bin/bash
 
#divxrip
 
mencoder $1 -ovc lavc -lavcopts vcodec=mpeg4 \
-ffourcc DIVX -vf scale -zoom -xy 720 -vf-add crop=720:576 \
-oac mp3lame -lameopts cbr:br=128 -o $2.avi

Use it like this, this will rip a DVD to a file called myvid.avi.

divxrip dvd://1 myvid

My ~/.bashrc.

My .bashrc file. This is the file I use for my day-to-day Linux tasks. The
prompt shows the time as well as the user@host in the prompt. The prompt will
also work flawlessly in the text console if your machine is a server and is not
running XFree86.

#!/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 -r`;
DOOMWADDIR=/usr/local/share/games/doom
PATH=$PATH:~/bin:/tools/bin
 
# Author: John Cartwright.
# Website: http://www.securitronlinux.com
# 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.
 
# Setting a blinking block cursor for the console.
#  echo -e '\033[?6c'
 
# 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
 
export EDITOR=mcedit
export DOOMWADDIR="/usr/local/games/doom" # For doom!
export TIME_STYLE=+" %d-%m-%y %I:%M %P"
# These two examples from bash-doc.
export PAGER="/usr/bin/less"
export VIEWER="mcedit"
export LESS="-i -e -M -P%t?f%f :stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-..."
shopt -s checkwinsize
eval `dircolors -b`
alias dir='ls --format="vertical"'
alias lu='ls -hula'
alias vdir='ls --format="long"'
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. http://www.atomicmpc.com.au
{
	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"
			echo
		done
		rm -fr $FILELIST
	else
		printf "Bad symlinks not found.\n\n"
	fi
} # End Atomic function.
 
function grephist()
{
	grep $1 ~/.history/history
}
 
source cd_func.sh
 
#echo "On this day in the GNU/Linux epoch."
#echo
 
#/bin/grep "$(date +'%m/%d')" ~/bin/calendar.computer
 
# Setting the value of the Xterm title.
# Only if we are in X...
if [ $DISPLAY ] ; then
	PROMPT_COMMAND='echo -ne "\033]0;${OSRELEASE}: ${PWD}\007"'
fi
 
if [ -x /usr/bin/finger ] ; then
   INFO=$(finger -lmps $LOGNAME | sed -e "s/On/Logged in/g" | grep "since" )
else
   INFO=$(uname -msov)
fi
 
echo -ne "${INFO}\n"
 
if [ $DISPLAY ] ; then  # Testing for either xterm or rxvt or uxvt or uxterm...
	# etc. Works in a xterm on Open Solaris just fine...
	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[ \t ]\n[ \$ ]-> '
	PS2='--> '
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. \# \

gt; ' 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. \# \

gt; ' 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.

This file will be more than sufficient for the user who wants to have a
customized BASH shell prompt that is more useful than the standard offerings
that comes with Debian and Mandrake alike.

1 thought on “Linux Configurations. My general Linux tips and commands page.”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.