Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a Study account which I use when doing anything school related work. It's purpose is to remove the distractions of my normal account, such as social media and news websites.

I know /etc/hosts can be edited to block certain domains from being accessed, but this is for all Users, and I don't want to have to switch in and out of Admin to change it every time I want to focus.

Is there any way to block these domains for specific Users or Groups?

share|improve this question

You could use iptables to restrict the network access. The module ipt_owner enables you to match network packets by user id. A command like

iptables -A OUTPUT -m owner --uid-owner mike --dst -j DROP

would prohibit user mike to access

As iptables really works with IP's instead of hostnames, this would create several rules, one for each IP of Downside is that you can't use iptables to limit whole domains, you would have to repeat that command for every single hostname you would like to restrict.

Be warned: If you're new to iptables you might have a hard time... ;)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.