2

I have these files in my home directory:

drwxr-xr-x    3 meuser staff           256 Oct 12 13:11 .
drwxr-xr-x  102 bin      bin            4096 Sep 30 12:28 ..
-rw-------    1 meuser staff          5349 Oct 11 20:44 .bash_history
-rwx------    1 meuser staff           466 Jun 26 22:12 .profile
-rw-------    1 meuser staff          7074 Oct 12 13:11 .sh_history
drwx------    2 meuser staff           256 Aug 16 15:28 .ssh

My default shell is the Korn shell. When I tried to put an alias into .profile like this:

alias l='ls -lrt'

and tried to run it after relogin:

$ l
ksh: l:  not found.

How to make this alias work?

2
  • 1
    What happens when you run . ./.profile?
    – Mikel
    Commented Mar 23, 2014 at 3:37
  • Are you typing l in response to your $ shell prompt, or are you typing $l? Commented Jun 1, 2015 at 10:09

4 Answers 4

2

.profile is only read at login. Later modifications do not affect the current environment. You have to reload .profile by means of:

  • sourcing the file: . .profile (affects the current shell, not all shells)
  • su -l <user> (new login)
  • logout + login
2
  • That does not seem to work. I changed my default shell to bash and relogin, and then it worked. So it is somehow related to korn shell.
    – jrara
    Commented Oct 12, 2013 at 13:16
  • @jrara Try adding -l to provide an login environemnt.
    – Marco
    Commented Oct 12, 2013 at 14:28
2

It does work.

The only difference I can see with my own .profile are the double quotes:

alias l="ls -l"

That line works for me in AIX with ksh as the shell.

Regarding the disconection and reconection... are you sure the default shell is ksh? Check your user in /etc/passwd.

2
  • 1
    Note that the question shows an error message coming from ksh. Commented Jun 1, 2015 at 10:10
  • @G-Man My "It does work" in the answer means alias works in AIX (Read the title of the question). The rest of the answer explains why it didn't work in his case.
    – YoMismo
    Commented Jun 1, 2015 at 11:25
1

The .profile is not your shell configuration file, it's your login session settings file. It is only read by the shell started upon login, not other interactive shells started within your login session.

ksh has no dedicated customization file per-se, but it treats the $ENV variable as a path to a customization file for interactive shell sessions.

So you'd add something like:

ENV="$HOME/.kshrc" export ENV

to your ~/.profile and:

alias 'l=ls -lrt'

to your ~/.kshrc.

The change would only take effect at the next login.

0

The aliases work in AIX with Korn Shell.

Put some commands at the end of your /etc/profile like:

export PS1="`hostname`# "
alias ll="/usr/bin/ls -lF $*"
alias h="history 50"

If you want these variables set inside your environment, launch:

. /etc/profile

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .