Tag Archives: configure sudo

CentOS 6.8 – Configure “demo” user for autologin, sudo and VirtualBox Shared Folder access


Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” (http://blogs.czapski.id.au/2016/10/build-a-linux-based-infrastructure-solution-demonstration-series) for rationale, introduction and links to articles in this series.

In this article I am configuring the OS so that the demo user:

  1. Is automatically logged in at boot and whenever they log out
  2. Can sudo without a password
  3. Can freely access the VirtualBox shared folder


This article assumes that the work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at http://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.

The instructions should work in other RedHat 6-like OSes and OS versions.

Enable autologin for demo user

Enable autologin for the demo user so that on boot demo user is automatically logged in

su - # welcome1

cp /etc/gdm/custom.conf /etc/gdm/custom.conf_orig

sed -i 's/\[daemon\]/\[daemon\]\
/' /etc/gdm/custom.conf


Reboot to verify that demo user is logged in automatically

Add demo user to sudoers

Add demo to sudo’ers with all rights and no need to enter password

su - # welcome1

rm -f /dev/shm/sudoers
cp -f /etc/sudoers /dev/shm/sudoers

insertAfter=$(( $(grep -n "## Allow root to run any commands anywhere" /dev/shm/sudoers \
| cut -d ":" -f1-1) + 2)); echo ${insertAfter}

ed /dev/shm/sudoers <<-END
demo    ALL=(ALL)       NOPASSWD:ALL

grep -B2 -A2 demo /dev/shm/sudoers
cp -f /dev/shm/sudoers /etc/sudoers # needs manual acknowledgement with "yes"


sudo ls -al /root

Allow user to freely use Virtual Box shared folder

Include demo account in vboxsf group so that the user can freely use vbox shared folder. This assumes that the sahred folder was created with the name “distros”. If it was created with a different name change the commands accordingly.

ls -al /media/sf_distros # verify that you don’t have access to the shared folder
sudo usermod -G vboxsf demo

Log out and log back in for this to take effect

ls -al /media/sf_distros # verify that you now have access to the shared folder