What is the meaning of ~ in ~/somefolder?

Solution 1:

~ = $HOME = your home directory

The next commands will change to your home directory /home/david if your username is david:

cd
cd ~
cd $HOME
cd /home/david
cd ~david

Solution 2:

You can also use ~username (no slash) to have it lookup the home directory of a user; that is, ~khamer resolves to /home/khamer, whereas ~david would resolve to /home/david regardless of who is typing the command.