Alias does not work with bash profile

Hi,

Below is what i have in my profile:

alias wldm='cd /opt/app/wls'

If i use bash or ksh shell this alias does not work.
What should be done for this alias to work with all these simultaneously -> No Shell, bash shell, and ksh shell

In bash, that alias does work, as long as there is a directory /opt/app/wls .

What do you mean by "No shell"? Aliases are innately bound to shells.

where in your profile? How do you connect?

How do you expect an alias to work if there isnt a shell:

After i login using

sudo su - user1

it works as below:

wldm

/opt/app/wls>

This is what i meant by no shell.

with bash and ksh shells it does not work as below

bash
bash-3.2$ wldm
bash: wldm: command not found
bash-3.2$ ksh
$ wldm
ksh: wldm:  not found

How did you login in second example ?

The first and the second are not two different logins but they are single login.

This is what i am doing

Step 1: sudo su - user1
Step 2: wldm
Step 3: bash
Step 4: wldm
Step 5: ksh
Step 6: wldm 

Step 2 works, Step 4 and 6 do not work as shown in the previous post.

If you do sudo su - user1
You read user1's environment ( his profile, but cat say which file since you did not tell us what user1 default shell is...)

there is a shell! A new shell with user1 UID and profile...
So what I understand is user1 is set as you wish but not you... Is that the issue?

Sorry did not see your last post ( was writing this one hehe...) I will read it now...

So I would suggest so we understand:
you type:

su - user1
echo $0
alias

And produce here the output!

If you were in ksh, you will see the aliases, typing bash after, you will loose them I suppose because not transmitted as not the same shell...
Let me try and test...

I'd bet that alias wldm is defined in ~/.profile but not in ~/.bashrc . So, for a login shell it is available, for an interactive non-login shell it is not. And neither for ksh.

Hi Rudi
I just tested and noticed it can vary between OS ... the closest I found was a debian:

nase1:/home/vbe $ su - pd1
pd1@nase1:~$ sh
$ alias
$ alias ll='ls- al'
$ alias
ll='ls- al'
$ ksh
$ alias
2d='set -f;_2d'
autoload='typeset -fu'
command='command '
fc=hist
float='typeset -lE'
functions='typeset -f'
hash='alias -t --'
history='hist -l'
integer='typeset -li'
nameref='typeset -n'
nohup='nohup '
r='hist -s'
redirect='command exec'
source='command .'
stop='kill -s STOP'
suspend='kill -s STOP $$'
times='{ { time;} 2>&1;}'
type='whence -v'
$ bash
pd1@nase1:~$ alias
alias cls='clear'
alias dir='ls -laF'
alias ll='ls -l'
alias lla='ls -al'
alias set2vt='export TERM=vt220'
pd1@nase1:~$ sh
$ alias
$   # Here I have the same shell as beginning: sh ! but as not exited it is not the first...

So going from sh to ksh I loose the alias... and typing sh at last after a bash I dont see it either, but as RudiC suggests, I am not in a clear situation where the alias was put in the correct profiles... so its may not be all that pertinent...

I was hoping our thread owner post what I asked so we could understand...

Here is the entry in my user1 profile.

$ more .profile
#       This is the default standard profile provided to a user.
#       They are expected to edit it to meet their own needs.
MAIL=/usr/mail/${LOGNAME:?}
set -o vi
# Set up the prompt
        export P=`uname -n`"@"`echo $LOGNAME`
PS1='
$PWD
$P $ '

echo "Changing to app home dir."
cd /opt/app/user1/tulip
alias wldm='cd /opt/app/wls'

Here is my OS

$ uname -a
SunOS mymachine 5.10 Generic_148888-04 sun4v sparc SUNW,SPARC-Enterprise-T5220

and here is the output of what you requested.

su - user1
Password:
 
echo $0
-nologin
 
alias
wldm=10log='cd /opt/app/wls'
autoload='typeset -fu'
command='command '
functions='typeset -f'
history='fc -l'
integer='typeset -i'
ll='ls -rlt'
local=typeset
nohup='nohup '
r='fc -e -'
stop='kill -STOP'
suspend='kill -STOP $$'
top=/usr/local/bin/top
wget=/usr/local/bin/wget

Please suggest how can i get my alias to work with sh, ksh and bash

You have it working in bash. Did you read my above post?

Where do i find ~/.bashrc for bash and similarly for ksh ?

Location Path of the directory please !!

It's not in my home directory.

If it is not in your home dir, you'll have to create it. You could also try to create it as a symbolic link to your ~/.profile.
For the ksh equivalent, pls. cf its man page.