Aliases

Updated: April 19, 2023

You can define an alias in the shell to create new commands or to specify your favorite options.

For example, the -F option to the ls command displays certain characters at the end of the names to indicate that the file is executable, a link, a directory, and so on. If you always want ls to use this option, create an alias:

alias ls='ls -F'

If you ever want to invoke the generic ls command, specify the path to the executable, or put a backslash (\) in front of the command (e.g., \ls).

Aliases are expanded in place, so you can't put an argument into the middle of the expanded form; if you want to do that, use a shell function instead. For example, if you want a version of the cd command that tells you where you end up in, type something like the following in ksh:

function my_cd
{
  cd $1
  pwd
}

For more information, see Functions in the entry for ksh in the Utilities Reference.

For information on adding an alias or shell function to your profile so that it's always in effect, see ksh's startup file in Configuring Your Environment.