Peculiar Output for cd(change directory) command

I hope you all know about the “cd” command in linux which is used to switch
between Linux directories. Recently I noticed a peculiar behaviour from “cd” command. Please see below:
[sms@test ~]$ whoami
sms                          ====>  Shows the Username I used to login.

[sms@test ~]$ pwd
/home/sms               ====> Shows the directory in which I am currently in.

[sms@test ~]$ cd Desktop/client
====> Now I am moving on to Desktop/client  folder

[sms@test ~]$ pwd
=====> Now I am again checking my present working directory.

[sms@test client]$ cd $qwerty
Here goes the peculiar behaviour. I am typing a $ symbol and anyword (I don’t have such folder or file name in the name “$qwerty” or “qwerty”).

[sms@test ~]$ pwd
Now see what happened. The present working directory switched to home directory of logged in user.

Known method to switch to the logged in user’s home directory is to type
cd ~

However this usage of “cd $anything” to switch to the logged in user’s home directory is pretty strange and new thing for me to see.

This makes the $ symbol in-usable as the first letter of file/directory name. I have checked the linux naming conventions to see if $ symbol is usable or not. I could not find any rules that linux file/directory name cannot start with “$” symbol.

Anyone who knows about the peculiar command usage can comment my post. I am using Redhat distribution – Centos 6.6.
[sms@test ~]$ cat /etc/redhat-release
CentOS release 6.6 (Final)

Thank you for anyone who can help me out. Have a Great Day.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s