Linux GNU/Linux:Tips and Tricks

Status
Not open for further replies.

cool_cat

Explorer
I hope all GNU/Linux Users can share their experience here about various Tips and Tricks you found/use on GNU/Linux.

--

1)Linux Terminals are now far more user-friendly with Programmable Bash Completion.

In your Default Ubuntu ,Debian Distros ,you can use below file for ~/.bashrc( /home/username/.bashrc)

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

# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)

# for examples

# If not running interactively, don't do anything

[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options

# don't overwrite GNU Midnight Commander's setting of `ignorespace'.

export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups

# ... or force ignoredups and ignorespace

export HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it

shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)

# check the window size after each command and, if necessary,

# update the values of LINES and COLUMNS.

shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)

[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)

if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then

    debian_chroot=$(cat /etc/debian_chroot)

fi

# set a fancy prompt (non-color, unless we know we "want" color)

case "$TERM" in

    xterm-color) color_prompt=yes;;

esac

# uncomment for a colored prompt, if the terminal has the capability; turned

# off by default to not distract the user: the focus in a terminal window

# should be on the output of commands, not on the prompt

#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then

    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then

    # We have color support; assume it's compliant with Ecma-48

    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such

    # a case would tend to support setf rather than setaf.)

    color_prompt=yes

    else

    color_prompt=

    fi

fi

if [ "$color_prompt" = yes ]; then

    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

else

    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

fi

unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir

case "$TERM" in

xterm*|rxvt*)

    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

    ;;

*)

    ;;

esac

# Alias definitions.

# You may want to put all your additions into a separate file like

# ~/.bash_aliases, instead of adding them here directly.

# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then

    . ~/.bash_aliases

fi

# enable color support of ls and also add handy aliases

if [ -x /usr/bin/dircolors ]; then

    eval "`dircolors -b`"

    alias ls='ls --color=auto'

    #alias dir='dir --color=auto'

    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'

    alias fgrep='fgrep --color=auto'

    alias egrep='egrep --color=auto'

fi

# some more ls aliases

alias ll='ls -l'

alias la='ls -A'

alias l='ls -CF'

[B]alias rm='rm -i'

alias mv='mv -i'

alias cp='cp -i'[/B]

[B]# enable programmable completion features (you don't need to enable

# this, if it's already enabled in /etc/bash.bashrc and /etc/profile

# sources /etc/bash.bashrc).

if [ -f /etc/bash_completion ]; then

    . /etc/bash_completion

fi[/B]

2)For VOIP application(gtalk) ,I use Empathy VOIP Client.It works with pulse audio as well.

3)For Reporting Your System's overall Information ,you can use Below Script and Upload the "RESULTS.txt" File for others to read.

SourceForge.net: Boot Info Script

Download the script ,open a terminal and do a "chmod +x boot_info_script27.sh" and then try as root(su) or as sudo :

Code:
sudo ./ boot_info_script27.sh

4)Press "F5" on a Blank Desktop Screen(Gnome,kde ,xfce etc) to have the X(Display) Refresh.also ,the command "xrefresh -white" can redraw the Display again.

5) Use UFW and GUFW(GUI) for firewall management in Ubuntu.
 
MAC OS X style Gnome menu - Gnome2_Global_Menu Instructions:

Installation - gnome2-globalmenu - installation on various linux platforms - Google Code

--

Global, Mac-like Menubar on GNOME with gnome2-globalmenu | kallasoft

there is ubuntu apt repositories also available.

Screen shot:

http://gnome2-globalmenu.googlecode.com/svn/wiki/GlobalMenuWindows.png

http://www.kallasoft.com/wp-content...u-mac-gimp-scrolling-popout-menus-475x128.png

PS: you have to enable global menu in preferences after installation.(right click on gnome panel>preferences>global menu >enable).

A Nice Gnome Customized to look OS X ish with Gnome2 Global menu and awn applet :

http://abz89.files.wordpress.com/2008/12/a.png

--

Changing Gnome Panel Font Color

Gnome Panel Font Color Part Deux Helpful Linux Tidbits

In Ubuntu ,

Code:
sudo apt-get update && sudo apt-get install gnome-color-chooser

[mod] Please use free image host instead of hotlinking images [/mod]
 
HDA-Intel Sound issues - Solution is to Upgrade to Latest ALSA package:

There is a script which allows to get the latest ALSA drivers installed,it can even restore the original Ubuntu drivers(reinstall alsa packages) too(if needed).

ALSA Upgrade Script

[all variants] ALSA Upgrade Script - Ubuntu Forums

Ithink this scripts can be edited to use on all distros irrespective of Origin.

What you need to do is ,download the scripts attached in the thread above and extract the archive - do a "chmod +x whateverscript.sh" and execute( as ./whateverscript.sh).Please READ Carefully that thread.

NOTE:

1) Go through the Alsa-Configuration.txt ,Hd-audio-modules.txt ,verify your soundcard codecs -for eg: if I got ALC662 HDAudio Codec can be tweaked(if you care) by adding below lines to /etc/modprobe.d/alsa-base (or options)

Code:
# ALSA portion

       alias char-major-116 snd

       alias snd-card-0 snd-hda-intel

       # module options should go here

[B]      options snd-hda-intel model=3stack-6ch index=0[/B]

      #options snd-hda-intel probe_mask=1

       # OSS/Free portion

       alias char-major-14 soundcore

       alias sound-slot-0 snd-card-0

       

       # card #1

       alias sound-service-0-0 snd-mixer-oss

       alias sound-service-0-1 snd-seq-oss

       alias sound-service-0-3 snd-pcm-oss

       alias sound-service-0-8 snd-seq-oss

       alias sound-service-0-12 snd-pcm-oss

To Find your HDA Intel Sound card's ALC codec version:

Code:
aplay -l

OR

Code:
 cat /proc/asound/card0/codec#0 |grep Codec

To see the ALSA version:

Code:
cat /proc/asound/version

--

So ,Normally to use the script ,run as

Code:
[COLOR=Blue][B] ./AlsaUpgrade-1.0.x-rev-1.16.sh -di[/B][/COLOR]

you can see that it uses apt-get to source some dependencies to compile latest alsa libraries.

Code:
ps ax |grep apt

Options available on Scripts:

root@sher:/home/prakash/Desktop/ALSA# ./AlsaUpgrade-1.0.x-rev-1.16.sh --help

Usage: ./AlsaUpgrade-1.0.x-rev-1.16.sh [OPTION]...

Available options:

-di Download (to /usr/src), compile and install the packages

This option will compeletely upgrade your ALSA in one step

-d Download the packages only

In case you want to tweak/patch the official packages or

you'd like to install the snapshot on top of the official

packages prior to compiling and installating them

-c Compilation only

Kind of dry-run option to see if the configuration and compilation

works

-i Compilation and installation of packages

Sources must exist under /usr/src. Run script with -d or -di options first.

The option is useful to speed up your installation in case Ubuntu upgrades

have overwritten your ALSA installation. It is also useful if you want to

keep your patched version or snapshot version, when reinstalling the packages

-r Restore ALSA

Kernel and all ALSA relevant Ubuntu packages will be restored

(done by re-installation of relevant packages)

-snap Download, compile and install of latest ALSA driver-sources-snapshot

Please run script using -d option first. Recommended for troubleshooting.

(The snapshot is not an offical ALSA release or even pre-release,

it is the latest snapshot taken from the design-tree!)

-h Help - this page

Please visit [all variants] Alsa 1.0.18 Installation Script - Ubuntu Forums

to report any issues you might encounter by using this script.



--

root@sher:/home/prakash/Desktop/ALSA# ./uxchecker-1.05.sh --help

Script usage: ./uxchecker-1.05.sh {-f ull check|-a lsa|-s ystem |-r ealtime}
 
  • Like
Reactions: 1 person
If For ,Some reason ,Alsa can't compile as above and script fails(look at /var/log/Alsa-* .txt for log) ,Try to do this:

add this line to repository (/etc/apt/sources.list):

Code:
deb [url]http://www.avenard.org/files/ubuntu-repos[/url] bleeding/

then ,

Code:
sudo apt-get update && apt-get upgrade -y

This will ,hopefully fix.you can compile alsa driver for your kernel from alsa-source using module-assistant ,if it doesnot works.
 
How to blacklist a module in Debian based(deb-dpkg-apt-aptitude-ubuntu-mepis-etc etc) distros?

add the module name in /etc/modprobe.d/blacklist in the format :

Code:
blacklist [B]module_name[/B]

With Intel Onboard graphics and with a Nvidia/Amd-ati pci-e/agp graphics card ,one might like to blacklist intel_agp module.

normally ,we will add to /etc/modprobe.d/blacklist once disabled onboard gfx in BIOS.if this blacklisting won't work ,

create a file /etc/modprobe.d/00local and add as follows(ugly hack):

Code:
install intel_agp /bin/true

you can replace intel_agp by any other module which you want to prevent loading.

--

I hope this works in Fedora and other rpm distros too.:hap2:
 
Using a Wide Screen Monitor ,Gnome Terminal shows a small size by default when invoked.

To Fix it to your preferred Geometry :

I wanted to achieve 120x35 as the gnome terminal window size.

so ,edited /usr/share/vte/termcap/xterm and changed the resolution I wanted:

Code:
:co#[B]120[/B]:it#8:li#[B]35[/B]:\

the bold portion is where you need to change the value.In xterm file ,this is 10th line probably for most distros.

You can edit as root/sudo. run "gksudo gedit /usr/share/vte/termcap/xterm" to edit.

--

OR a simple step is ,invoke as "gnome-terminal --geometry=120x35(whatever size you want to put)".

more info : gnome-terminal --help
 
Status
Not open for further replies.