You may want to change the way things look and act when you log into the system. You can make all sorts of changes to make things easier for you to use the cluster
What can I change?
Pretty much anything! Many people will change their prompts, the colors things display in, their paths to make launching things easier, aliases to make commands easier to run, default editors, etc.Making It look the way i want
- \d The date, in "Weekday Month Date" format (e.g., "Tue May 26").
- \h The hostname, up to the first ‘.’.
- \H The hostname.
- \t The time, in 24-hour HH:MM:SS format.
- \T The time, in 12-hour HH:MM:SS format.
- \A The time, in 24-hour HH:MM format.
- \u The username of the current user.
- \w The current working directory, with
$HOME
abbreviated with a tilde - \W The basename of
$PWD
, with$HOME
abbreviated with a tilde. - \! The history number of this command.
- \$ If the effective uid is 0,
#
, otherwise$
.
Making is behave the way i want it to
Setting my PATH
How do i make them permanent?
Everything mentioned so far takes place in the shell you are running in. This is a good way to test things. For example, if you change you path in shell and can no longer run commands, just close the shell and open a new one. You probably, however, want these changes to take place in all shells you open. To do this, you will add the commands to one of 2 files. Either the ".bash_profile" or ".bashrc". These files are in you home directory. Notice that they both have a "." in front of them. This hides the files in a normal listing.
Which one?
Depends on what kind of shell you want it for. There are login shells which are typically used interactively, and non login shells which get called from scripts and the like. A good sign it is a login shell is if you had to provide a password to get it.
Typically, when you login into the cluster, you will be in a login shell. These shell use the .bash_profile. This is a great place to put prompt changes and colorization options.
When not logging in and authenticating, you would usually get a non login shell. These read the .bashrc file. This can be confusing when running scripts, using screen, or in your jobs.
In addition, non-login shells occur any time you run a script that uses bash. Non-login shells read from the .bashrc file.
For most users You will want to have the .bash_profile read in the .bashrc. When doing this, paths set in .bashrc should also be set in a login shell. The default files you get when first logging in are set to do just that. If for some reason you delete it, you can add the following to the top of your .bash_profile to get the behaviour back
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
Putting is all together
.bash_profile:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
PS1="[\u@\h \W]\$"
EDITOR=nano
export PATH PS1
.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
# colorize ls"
alias ls="ls --color=auto"
# long listing in ls
alias ll="ls -l --color=auto"