I am planning to reinstall my operating system because it has many glitches. However, I am totally new to this and I would like to ask you what actually happens when you reinstall Lion? Do all your files remain or not?
Lion does not offer any customizations during the installation process. Thus a reinstallation is about as smooth and as linear as possible.
You restart your Mac holding the OPTION key when you hear the tone. You will then be greeted with various partitions you can use instead of the main Lion partition.
Should you wish to simply reinstall Lion, you would select the Recovery HD partition. Once loaded, you just need to follow the prompts and install it over your current Lion installation.
The new installation will replace all the core system files, but leave your user profile and data complete untouched. Your music, documents, even passwords and bookmarks, and applications will not touched; none of your personal information will be deleted (nor will it backup your old system, as was common in older OS X versions). It is a seamless process that simply rolls Lion back to the default installation build. There will be nothing lost and no disk spaced wasted on old system files.
Note: It was the case that older builds of OS X allowed various types of reinstallations (like Archive and Install or a complete erase), but these have been omitted in Lion, greatly simplifying the process.
Lion doesn't offer the different kinds of installs that previous versions of the OS did. If you use the Lion installer, you will perform an "Upgrade" install that keeps your files and programs intact. It's still always a good idea to back up your data before upgrading.
If you need to perform a clean install, MacWorld offers advice, but it's not an option in the installer as in previous versions of the OS.
It depends on which install option you choose: "Archive and Install" and "Upgrade" will keep your user files. "Erase and Install" will not. Not all options are available depending on the OS currently installed and the one you wish to install.
If you're installing newer over older (10.6 over 10.5, or 10.6.8 over 10.6.0), you'll have all the options. If you're installing older over newer or the same version (10.5 over 10.6 or 10.6 over 10.6), you probably won't have the "Upgrade" option, just "Archive and Install" and "Erase and Install".