Alias does not work with bash profile

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Alias does not work with bash profile
# 8  
Old 11-08-2013
So I would suggest so we understand:
you type:
su - user1
echo $0

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...

Last edited by vbe; 11-08-2013 at 12:33 PM.. Reason: typos
# 9  
Old 11-08-2013
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.
# 10  
Old 11-08-2013
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 '
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...

Last edited by vbe; 11-08-2013 at 12:50 PM..
# 11  
Old 11-08-2013
I was hoping our thread owner post what I asked so we could understand...
# 12  
Old 11-08-2013
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.
set -o vi
# Set up the prompt
        export P=`uname -n`"@"`echo $LOGNAME`
$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
echo $0
wldm=10log='cd /opt/app/wls'
autoload='typeset -fu'
command='command '
functions='typeset -f'
history='fc -l'
integer='typeset -i'
ll='ls -rlt'
nohup='nohup '
r='fc -e -'
stop='kill -STOP'
suspend='kill -STOP $$'

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

Last edited by vbe; 11-08-2013 at 01:58 PM..
# 13  
Old 11-08-2013
You have it working in bash. Did you read my above post?
# 14  
Old 11-11-2013
Originally Posted by RudiC
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.
Where do i find ~/.bashrc for bash and similarly for ksh ?

Location Path of the directory please !!

It's not in my home directory.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Creating a .profile, displaying system variables, and creating an alias

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Here is what I am supposed to do, word for word from my assignment page: 1. Create/modify and print a... (2 Replies)
Discussion started by: Jagst3r21
2 Replies

2. UNIX for Dummies Questions & Answers

Using alias to create subshell and work in it

using kerberos to access remote server. first I execute kshell to create subshell and then kinit username@domain in that subshell. After that it prompts to enter password. Since I need to do this over and over, I am trying creating alias. I tried kshell; kinit username@domain. Did not work,... (7 Replies)
Discussion started by: analyst
7 Replies

3. UNIX for Dummies Questions & Answers

A very simple script, but alias won't work

I am new to unix and therefore I did a lot of reading before posting. So please, if this has been answered before, forgive me for re-posting and point me to the right place for the answer. I have spent many hours searching the net and read over 50 posts in this forum and even tried a few thing but... (20 Replies)
Discussion started by: sssccc
20 Replies

4. Shell Programming and Scripting

Bash alias for complicated ls command does not work.

I'm trying to set up an alias in .bash_aliases to show just the filenames of the files in a directory, which the following command will do: ls -l | grep ^- | awk '{print $NF}' However when I set up the following alias in .bash_aliases: alias lf="ls -l | grep ^- |... (16 Replies)
Discussion started by: gencon
16 Replies

5. UNIX for Dummies Questions & Answers

alias command within .profile

Please could someone advise me the command - to set up aliases commands within a .profile using shell sh regards venhart (13 Replies)
Discussion started by: venhart
13 Replies

6. Shell Programming and Scripting

Global alias does not work in shell script

Hi Linux Set up - alias ls='ls -l' Then run script #! /bin/ksh sub() { ls } sub Is there any way to get it working. I don't want to define alias inside of the program Thank you (2 Replies)
Discussion started by: zam
2 Replies

7. OS X (Apple)

Problem using a top command alias in my profile

Hi- I am newish to the mac osx unix interface. I want to set up top so that it always displays the username. I can use this command to do this: top -ocpu -P ' PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE USER' -p '$aaaa ^bbbbbbbbb $cccc $wwwwwww $ee... (1 Reply)
Discussion started by: mikey11415
1 Replies

8. Shell Programming and Scripting

alias doesn't work

Hi I have put alias ll='ls -la' in .profile file but it doesn't work. On hand it works it looks like the .profile file is not beeing read. How to check whitch file is loaded? ,profile? .bash_profile? My system: SunOS mion 5.10 Generic Shell: /bin/pfksh Thanks (2 Replies)
Discussion started by: miojamo
2 Replies

9. UNIX for Advanced & Expert Users

All alias in .profile lost when "script" command is called

Hi, I was trying to call "script <an ip add>" command from .profile file to log everything whenever anyone logs in to this user. I did the following at the end of .profile. 1) Extracted the IP address who logged in 2) Called script < ip add> . The problem I am facing is all, aliases etc. written... (3 Replies)
Discussion started by: amicon007
3 Replies

10. UNIX for Dummies Questions & Answers

alias in .profile

hello guys... im just new in using unix and im trying to create a command by using an "alias" and incoporating it in my .profile. how can i make a command that will do a chmod 775 on all files only under my username. i tried alias gochmod="chmod 775 $PUROOT/path/*" but this gives me... (3 Replies)
Discussion started by: davinxi
3 Replies
Login or Register to Ask a Question