Skip to content

Instantly share code, notes, and snippets.

@jakobii
Last active March 1, 2019 23:40
Show Gist options
  • Save jakobii/229545a9673e6e84258683f363879937 to your computer and use it in GitHub Desktop.
Save jakobii/229545a9673e6e84258683f363879937 to your computer and use it in GitHub Desktop.
Temp User On Ubuntu 18.04 (still in the works!)

Minimal ubuntu server kiosk install

sudo apt-get install --no-install-recommends ubuntu-desktop

Kiosk-like Ubuntu 18.04 Desktop

create a guest user

in this example our guest user will be named student

sudo adduser student

Home Directory in Memory

open /etc/rc.local in your favoite test editor: gedit, nano, vim

sudo gedit /etc/rc.local

Copy the following into /etc/rc.local.

#!/bin/sh
rm -rf /home/student/*
mount -t ramfs -o size=512M ramfs /home/student

Then run the following cmd in bash.

sudo chmod +x /etc/rc.local 

/etc/rc.local will now run at startup.

test your rc.local file.

To test this run the following commands. any errors will be reported to you by systemctl.

sudo systemctl restart rc-local
sudo systemctl status rc-local

Cleanup after every login

the above script only runs at statup. which is nice since it setup the home directory to run in memory and not on disk. however we also probably want a cleanup script to run when users login.

edit /etc/profile

sudo gedit /etc/profile

append this to the bottom of the file. all we are doing in the rebuild section is copying some default information into the guest accounts home folder. exactly what gets copied is pretty easy to customize to fit your needs. (e.g. cp -r /opt/student/. /home/student/)

#remove everything
rm -rf /home/student/*

#rebuild
cp -r /etc/skel/. /home/student/
mkdir /home/student/Desktop
mkdir /home/student/Documents
mkdir /home/student/Downloads
mkdir /home/student/Music
mkdir /home/student/Pictures
mkdir /home/student/Public
mkdir /home/student/Templates
mkdir /home/student/Videos

#change folder owner
chown -R student:student /home/student

now login to your guest account and test it out. try creating some test files and then log out. when you log back in the files should be gone!

customize the guest users home directory

login as the guest user and make it pretty. then run

su -
cp /home/student /opt
chmod -R 755 /opt/student

IMPORTANT! make sure you remove hidden files from the /opt/student. only keep .bash_logout, .bashrc, .profile. you do not need to delete hidden folders. some hidden files contain session specific information.

edit /etc/profile

sudo gedit /etc/profile

and replace

#rebuild
cp -r /etc/skel/. /home/student/
mkdir /home/student/Desktop
mkdir /home/student/Documents
mkdir /home/student/Downloads
mkdir /home/student/Music
mkdir /home/student/Pictures
mkdir /home/student/Public
mkdir /home/student/Templates
mkdir /home/student/Videos

with this

#rebuild
cp -r /opt/student/. /home/student/

enable root login

sudo passwd root   
sudo apt-get update
sudo apt-get install lightdm
sudo nano  /etc/lightdm/lightdm.conf

add the following to /etc/lightdm/lightdm.conf.

[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu
greeter-show-manual-login=true

enable auto guest login

you can do this in the settings gui- Settings->Details->Users. select the user and toggle automatic login.

Here is how you do it from the command line.

sudo gedit /etc/gdm3/custom.conf

uncomment the following. set AutomaticLogin = <username>.

# Enabling automatic login
AutomaticLoginEnable = true
AutomaticLogin = student 

delete any unwanted user accounts

you may have created some user accounts that you do not want to display on the login page. to delete them use the following command. replace <username> with the user you would like to delete. -r will delete there home folder as well so be careful!

userdel -r <username>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment