Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
The "~" means your home directory right. Well is that a part of the bash shell or part of the linux kernel? What i mean is, if i type "cd ~", does bash change the "~" into a string containg my home directory and pass that string on to the "cd" program. Or does it pass the actual "~" character to "cd", and "cd" passes it to the kernel, and the kernel changes it to my home directory?
I don't have an exact answer for this, but this is what I found out. The tilde (~) holds the value of $HOME, so ~=$HOME.
I'd say that ~ is at the kernel level since trying to give it a value other than $HOME is not possible, at least on my testing trying to make changes to it and give it another value. So, I'd say that
when we type ~ at the command prompt the kernel immediately "knows" that this is actually $HOME comming from the shell.
I did not find anything more specific on this.
Actually, tilde expansion and the HOME environment variable are both functions of the shell. The value of $HOME is set to the home dir of the user who spawns the shell, and the tilde will be expanded by the shell to that value.If the value of $HOME is changed, the tilde will expand to the new value:
[root@Boris /etc]# echo $HOME
[root@Boris /etc]# cd ~
[root@Boris /root]# export HOME=bogus
[root@Boris /root]# echo $HOME
[root@Boris /root]# cd ~
bash: cd: bogus: No such file or directory
[root@Boris /root]# export HOME=/root
[root@Boris /root]# echo $HOME
The tilde can be expanded to other values however, including:
The Home directory of another user