ubuntu 18.04 on AWS

I followed an answer on stackoverflow to create a path alias:

nano ~/.bashrc

alias myfolder='/home/xxx/pms'

When I try to cd

cd myfolder

I get:

No such file or Directory

But if I use the path it works.

I am not sure what the issue here is.


  • If you use alias "myfolder"="cd /home/xxx/pms" and source ~/.bashrc you'll be able to access your folder typing only myfolder on the terminal... – Rafael Muynarsk Mar 25 at 14:00

What you're trying

You may be thinking of the term alias as defined and used in Mac OS.

For ubuntu the command alias does something totally different. The command you have used is for creating new commands so you don't have to remember a longer command, or a longer command you type so much it is quicker to type the alias. For example, if I don't want to keep typing this command to launch a program:

java -jar /usr/local/bin/bfg-1.13.0.jar

You could create an alias called bfg in my Unix profile (or ~/.bashrc as you have) like this:

alias bfg='java -jar /usr/local/bin/bfg-1.13.0.jar'

From now on I can use bfg every time I want to run the java program.

What you really need

In Ubuntu what you're looking for is a symbolic link. A symbolic link is created with the ln command on Ubuntu (and all other Unix varieties). See the following example.

In the below example you can see a folder that already exists called pms in my home folder.

Thus its absolute path is /home/ubuntu/pms.

ubuntu@server:~$ ls -l
total 4
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 25 11:05 pms

Now I change to a mother directory where I want the link, what you are thinking of as an alias, and create the symbolic link with ln -s

ubuntu@server:~$ cd /tmp/
ubuntu@server:/tmp$ ln -s /home/ubuntu/pms myfolder

Now I'm able to change directory to this alias as you understand it.

ubuntu@server:/tmp$ cd myfolder/
ubuntu@server:/tmp/myfolder$ pwd

To be clear, an alias is a completely different thing in Unix & Linux land. The symbolic link I have made can be seen by listing the /tmp directory where I created it.

ubuntu@server:/tmp/myfolder$ cd /tmp
ubuntu@server:/tmp$ ls -l
total 16
lrwxrwxrwx 1 ubuntu ubuntu   16 Mar 25 11:06 myfolder -> /home/ubuntu/pms

The contents of the /tmp/myfolder are one and the same as /home/ubuntu/pms.

  • Thanks for the detailed explanation. Now when I make changes to certain files using the above link, the changes will carry through? – Sid Mar 25 at 11:44
  • Yes. Files and folders seen and created in the symlinked folder (from the example) /tmp/myfolder and in the original /home/ubuntu/pms are actually the same files on the disk. – lantrix Mar 26 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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