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
/tmp/myfolder
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
.
alias "myfolder"="cd /home/xxx/pms"
andsource ~/.bashrc
you'll be able to access your folder typing onlymyfolder
on the terminal...