#!/bin/bash exec sg newgrp `id -gn` # or: exec su -l $USER # or if you don't want to replace the shell with a new one so you can exit and go back to the original: su - $USER # or for all Screen sessions: screen -S -X at \# stuff "exec sg newgrp \`id -gn\`^M"