Linux – aliases in .bashrc

bashlinuxunix

I am completely new to UNIX, so pardon me if this question is incredibly stupid.

I just started an internship, where I'm given access to a build server. I want to include certain aliases by default in my environment when I log in. From what I understand, the way to do it would be to include them in a .bashrc file in my $HOME directory. But it doesn't seem to work. I read somewhere that only interactive shells and user scripts would be able to read it, is that the reason it doesn't work? I'm running Bash. So how would I go about doing this?

Thanks in advance!

Best Answer

iman453, the files need to be named .bashrc and .bash_profile. The period before the file means it is hidden. Any idea what version of Unix or Linux the build server is running?

In my home directory I have

.
|-- .bash_history
|-- .bash_logout
|-- .bash_profile
|-- .bashrc
|-- .mozilla
|   |-- extensions
|   `-- plugins
|-- .ssh
|   |-- .config
|   |-- authorized_keys
|   |-- authorized_keys2
|   `-- known_hosts
|-- .viminfo
|-- .vimrc

The contents of my .bashrc file are:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
alias chknag='sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg'
alias ducks='sudo du -cksh * | sort -n | head -50'

The contents of .bash_profile:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/sbin:/usr/bin:/sbin

export PATH

When I SSH into this machine after I authenticate I have access to the alias ducks.