Yeah, I struggled with this kind of thing a lot while I first started Uni. But I definitely got the hang of it later on.
For me, location was a big factor. I almost always worked in the campus library. Studying in my bedroom never worked, partly because of all the distractions within, and partly because I mentally labelled "bedroom" as "place of rest". Working in a public place like a library helped me immensely because I was surrounded by other students. Even if I didn't know them, they were still studying just like me, and it was comforting and motivating to know that I wasn't alone in my suffering.
Also, if I was in a public library, I found myself to be way more productive on the public machines. This is because they were all terribly slow compared to my laptop, and I couldn't browse Facebook etc nearly as swiftly. If you had an internet/gaming addiction like I did, then I suggest leaving your laptop behind and embracing the horrors of the public PC. It's probably good to leave your Smartphone behind too.
Keeping a regular sleep pattern also helped me, and getting up early was a critical part of my study routine. If I slept in too late, I couldn't focus that well for the rest of the day. I'm sure we all know the old trick of putting the alarm clock at the other end of the room so you have to physically get out of bed to turn it off. I experimented by also putting obstacles all over my floor so I'd have to step around those whenever I had to shut the alarm off (or trip, but hey that'd certainly wake me up anyway). My phone's alarm also has a neat feature where you have to solve a math problem to shut it off, I definitely recommend that.
What are you eating? Junk food turned out to be pretty bad for my concentration. I'd usually snack out of boredom/procrastination, but having a bloated stomach made me more tired and reluctant to work. As far as caffeine is concerned, one coffee/soft drink did me fine, but anything over that was usually for the worse. A strong coffee was great for me because I didn't want to eat directly after having one, and I work better hungry than I do full.
I dunno, just some ramblings haha. Hope someone finds 'em useful. Good luck!