Ssh Aliases


#1

I want to be able to log into my ssh without specifically re-setting my aliases each time. I’ve tried putting my aliases into ~/.bash_profile and ~/.bashrc with no luck.

Does anyone know how to do what I’m trying to do?

Thanks!


#2

I have a file called .alias, but I’m using tcsh. Type ‘env’ to see which shell you’re using.

-Scott


#3

Looks like I’m using bash, which is just as well. I’ve never used anything else. So how do I accomplish the alias task with bash?


#4

I added the following to .bashrc and it took effect upon changing my shell:
alias ll=‘ls -l’

Is your syntax the same as the above?

-Scott


#5

Yes, I used the same exact syntax in .bashrc and .bash_profile with no luck. Here is what I have in each:

alias dir=‘ls -malF --color=always’

Perhaps I have it in the wrong directory? When I start out, I’m in the /home/username directory, so that’s where I put these files.


#6

I added your alias to my ~/.bashrc and it works for me.
How are you editing this file? I have been using vi.

-Scott


#7

I’m using vi also. This is very strange. Here is my entire .bashrc:

System-wide .bashrc file for interactive bash(1) shells.

alias dir=‘ls -malF --color=always’


#8

That looks like what I have.

Since my account is tcsh, I’ve been typing /bin/bash to enter the bash shell. Could you try that?

-Scott


#9

When I do that, it works. I wonder why bash isn’t reading the .bashrc when I initially log in.


#10

Well, now I’m somewhat stumped, but the first line of the default file does say that it’s executed for non-login shells, whatever that means.

However, .bash_profile says it’s for login shells. But you said you tried the same thing in the profile. Still stumped. Does it have to be bash for you?

-Scott


#11

You may have another shell set as your default.

When you log in try chsh at the prompt.
Then enter your password when asked and then enter your new shell as
/bin/bash

Log off and reconnect to see if you are now using your bash shell.

Oh and place your aliases in the .bash_profile file.


Norm

Opinions are my own views, not DreamHosts’.
I am NOT a DreamHost employee OK!! :@

You act on my advice at your own risk!


#12

.bashrc isn’t automatically read on login like .bash_profile (and .profile), not sure why. You’re supposed to put aliases in .bashrc, but have this in .bash_profile

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi