Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

Sunday, December 7, 2008

.bashrc file collection

Bash-Making use of your .bashrc file
A Sample .bashrc File from Advanced Bash-Scripting Guide

BASH

Bash-wiki
GNU BASH
BashScripts.org Forum

Tutorials:
BASH Programming - Introduction HOW-TO
Bash Shell Programming in Linux
Bash Guide For Beginners
Advanced Bash-scripting Guide
Getting Started with BASH

Tips:
Customizing your Bash environment

Bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc

The difference between ~/.bashrc, ~/.bash_profile, ~/.profile, /etc/profile, /etc/bash.bashrc, and ~/.bash_logout:
[1] When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior. Basically, ~/.bashrc allows you to create shortcuts (aliases) and interactive programs (functions) that run on the startup of the bash shell or that are used when running an interactive shell.

[2] When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.

[3] When bash exits the file called .bash_logout in the user's home directory is run.

Reference:
[1] http://telin.ugent.be/~slippens/drupal/bashrc_and_others
[2] http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlbash.html

Saturday, December 6, 2008

Master the Linux bash command line with these 10 shortcuts

The bash shell is the primary interface to the Linux operating system -- it accepts, interprets and executes your commands, and provides you with the building blocks for shell scripting and automated task execution.

[1] Easily recall previous commands
"speed search" previously-executed commands by typing the first few letters of the command followed by the key combination Ctrl-R.

[2] Use command aliases
You can obtain a list of available aliases by invoking alias without any argument, and you can delete an alias with unalias.

[3] Use filename auto-completion
To use this feature, type the first few letters of the file name, followed by Tab. Bash will scan the current directory, as well as all other directories in the search path, for matches to that name.

[4] Use key shortcuts to efficiently edit the command line
Ctrl-A/E: moves the cursor to the beginning/end of the command line.
Ctrl-W/K: deletes the word immediately before/after the cursor.

[5] Get automatic notification of new mail
MAILPATH='/var/spool/mail/USERNAME'
export MAILPATH

[6] Run tasks in the background
To run a task in the background, add an ampersand(&) to the end of its command line.

[7] Quickly jump to frequently-used directories
$PATH variables lists bash's "search path" - the directories it will search when it can't find the requested file in the current directory. However, bash also supports the $CDPATH variable, which lists the directories the cd command will look in when attempting to change directories.

[8] Perform calculations
echo $((16/2))
type in the artithmetic expression you wish to evaluate at the prompt within double parentheses.

[9] Customize the shell prompt
PS1='\u@\h:\w \@> '
export PS1
This will display the name of the current logged-in user, the host name, the current working directory and the current time at the shell prompt.

[10] Get context-specific help
help alias

Reference:
Master the Linux shell command line with these 10 shortcuts