.bashrc Do's and Don'ts: Difference between revisions
Jump to navigation
Jump to search
H Winkhardt (talk | contribs) m (Tippfehler) |
K Siegmund (talk | contribs) (→Do's) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
You can add commands that you want to run every time at login and when starting a job by adding lines to these files, but you can also make mistakes that make your life or the life of the cluster teams harder. |
You can add commands that you want to run every time at login and when starting a job by adding lines to these files, but you can also make mistakes that make your life or the life of the cluster teams harder. |
||
== |
== Don'ts == |
||
* don't forget to test your changes before you log out |
* don't forget to test your changes before you log out (log in on a second shell) |
||
* don't put <code> module load </code> commands in .bashrc, modules may make changes that break the default system environment |
* don't put <code> module load </code> commands in .bashrc, modules may make changes that break the default system environment |
||
* don't put LD_PRELOAD or LIBRARY_PATH in your .bashrc, unless you know exactly what you're doing |
* don't put LD_PRELOAD or LIBRARY_PATH in your .bashrc, unless you know exactly what you're doing |
||
* |
* |
||
== Do's == |
== Do's == |
||
* make a copy of your .bashrc before making large changes |
|||
* '''test''' your changes to .bashrc before you log out |
* '''test''' your changes to .bashrc before you log out |
||
* add command aliases or bash functions in .bashrc - example: <code> alias l='ls -la' </code> |
* add command aliases or bash functions in .bashrc - example: <code> alias l='ls -la' </code> |
||
Line 26: | Line 26: | ||
HISTIGNORE="?:??" # dont store one and two letter commands |
HISTIGNORE="?:??" # dont store one and two letter commands |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
* maybe make your rm / cp commands safer by aliasing to -i <code> alias rm 'rm -i'</code> |
|||
== Autoedits / Conda == |
|||
There is some software (e.g. conda) which automatically modifies .bashrc. Make sure to have a copy of your .bashrc and test after installing software like this |
Latest revision as of 12:58, 5 November 2024
.bashrc and .profiles are files that are sourced when you log in, they set some important variables that make your shell function at a specific site setup.
You can add commands that you want to run every time at login and when starting a job by adding lines to these files, but you can also make mistakes that make your life or the life of the cluster teams harder.
Don'ts
- don't forget to test your changes before you log out (log in on a second shell)
- don't put
module load
commands in .bashrc, modules may make changes that break the default system environment - don't put LD_PRELOAD or LIBRARY_PATH in your .bashrc, unless you know exactly what you're doing
Do's
- make a copy of your .bashrc before making large changes
- test your changes to .bashrc before you log out
- add command aliases or bash functions in .bashrc - example:
alias l='ls -la'
- add a local ~/bin or similar to $PATH if needed
- improve your terminal command history experience:
shopt -s histappend # append to the history file, don't overwrite it
shopt -s direxpand # expand dirs before trying to expand filenames
HISTSIZE=1000000 # number of commands stored in one terminal session
HISTFILESIZE=20000000 # number of commmands stored in file
HISTFILE="$HOME"/.bash_history_$USER # prevent file truncation by bash sessions that did not read in .bashrc
PROMPT_COMMAND="history -a" # save history after every command
HISTCONTROL=ignoreboth:erasedups # dont store duplicates and ignore lines starting with white space
HISTIGNORE="?:??" # dont store one and two letter commands
- maybe make your rm / cp commands safer by aliasing to -i
alias rm 'rm -i'
Autoedits / Conda
There is some software (e.g. conda) which automatically modifies .bashrc. Make sure to have a copy of your .bashrc and test after installing software like this