Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With Finder, Cmd-L is a short-cut to make an alias of a file/directory. How can I use the command line to do that?

I tried 'ln -s', but it generates the 'Symbolic Link', not 'Alias'.

share|improve this question
could you explain what the difference is in terms of functionality? – dstarh Feb 9 '11 at 21:21
@dstarh :… – prosseek Feb 9 '11 at 21:53
Thanks – dstarh Feb 10 '11 at 16:24
up vote 7 down vote accepted

mkalias is a binary available in a set of tools here. It can also be installed via Homebrew with brew install osxutils.

This is a SH shell script that calls AppleScript to create an alias.

I'm including the shell script here for future reference incase it goes missing from the nets.


# make_alias
# This script takes two command-line arguments:
# 1) The name (relative or full path) of a source file or folder (directory)
# 2) The name (relative or full path) of a destination folder (directory)
# The script makes a Finder-style alias to the source file or folder
# and puts it in the specified destination folder.
# Cameron Hayne (, December 2003
# Modified as suggested by Paul Russell (, May 2006
#          to allow either file or folder as source
# Mofified to work with ".app" files, January 2007

scriptname=`basename $0`
if [ $# -lt 2 ]; then
    echo "Usage: $scriptname srcPath destPath"


if [ ! -e "$srcPath" ]; then
    echo "$scriptname: $srcPath: No such file or directory"

# remove possible trailing slash from $srcPath

# set $srcType to "file" or "folder" as appropriate
if [ -d "$srcPath" ]; then
    if [ "${srcPath##*.}" == "app" ]; then

# check if the $destPath directory exists
if [ ! -d "$destPath" ]; then
    echo "$scriptname: $destPath: No such directory"

# check if we have permission to create a new file in the $destPath directory
if [ ! -w "$destPath" ]; then
    echo "$scriptname: No write permission in the directory $destPath"

case $srcPath in
/*) fullSrcPath=$srcPath ;;
~*) fullSrcPath=$srcPath ;;
*)  fullSrcPath=`pwd`/$srcPath ;;

case $destPath in
/*) fullDestPath=$destPath ;;
~*) fullDestPath=$destPath ;;
*)  fullDestPath=`pwd`/$destPath ;;

/usr/bin/osascript > /dev/null <<EOT
tell application "Finder"
    set macSrcPath to POSIX file "$fullSrcPath" as text
    set macDestPath to POSIX file "$fullDestPath" as text
    make new alias file to $srcType macSrcPath at folder macDestPath
end tell
share|improve this answer
The shell script works fine, whereas the osxtools are outdated (not compile with Xcode 3.0). – prosseek Feb 10 '11 at 1:09
@proseek, the source for the osxtools is available if you want to recompile. mkalias doesn't really need any updates, it's a very simple file. – zevlag Feb 10 '11 at 16:17
I got "mkalias.c:303: error: ‘FSSpec’ has no member named ‘name’" error when I compile it with gcc 4.2.1. I guess the code is outdated with Carbon library. – prosseek Feb 11 '11 at 5:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.