Customizing Bash ME 4953/5013 - Introduction to High-Performance Computing

Customizing Bash ME 4953/5013 - Introduction to High-Performance Computing

Customizing bash ME 4953/5013 - Introduction to High-Performance Computing ME 4953/5013 Customizing bash Common Environment Variables Variable Significance HOME Home directory PATH List of directories searched by shell to locate command LOGNAME Login name of user USER Login name of user TERM Type of terminal PWD Absolute pathname of current directory PS1 Primary prompt string PS2 Secondary prompt string SHELL User's login shell To add new entries to the existing PATH use the notation: PATH=/my/new/path:$PATH Adds /my/new/path to front of existing PATH. Or: PATH=$PATH:/my/new/path adds to back of PATH. Adds /my/new/path behind existing PATH. ME 4953/5013 Customizing bash Aliases Assigns shorthand names for common commands Useful aliases Definition Significance alias ls='ls -F' Marks directories, executables, and symlinks alias l.='ls -d .*' Lists all files beginning with a dot alias ..='cd ..' Moves up one directory alias ...='cd ../..' Moves up two directories alias cx='chmod a+x' Assigns execute permissions to all alias h='history 20' Lists las 20 commands alias cls='tput clear' Clears the screen alias path='echo $PATH' Displays the current path alias lm=``ls -t | head -n 1'' Displays last modified filename ME 4953/5013 Customizing bash Using set options Bash provides vi-like (and emacs) capabilities for editing the command line set -o vi set -o emacs Other set options Operator Meaning noclobber Prevents overwriting with redirects ignoreeof Prevents termination of login shell with [Ctrl-d] notify Notifies completion of background jobs immediately rather than at the next prompt noglob Disables wild-card expansion ME 4953/5013 Customizing bash The initialization scripts We can set or change the default behavior of the environment variables, aliases, and set options to persist from login-to-login or when a new sub-shell is launched. We do this with two files, A login script (also called a profile) which is executed only once. One of these three files: ~/.bash profile ~/.profile ~/.bash login A run command script, which is executed every time an interactive sub-shell is launched. ~/.bashrc ME 4953/5013 Customizing bash The login script In your login script: Environment variable changes or additions Custom shell variables Startup messages source the run command script source ~/.bashrc . ~/.bashrc If you make changes to this file, you will have to source it from the current shell or logout and login e.g. source ~/.bash profile ME 4953/5013 Customizing bash The run command script In your run command script: Aliases set commands Startup messages Shell variables you want reset every sub-shell ME 4953/5013 Customizing bash.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us