Design a site like this with
Get started

Useful Linux scripts for standalone systems, emulators, HTPCs etc.

Booting the system to console with grub2

Edit the file /etc/default/grub:

sudo nano /etc/default/grub

Change the line GRUB_CMDLINE_LINUX_DEFAULT to include “text”:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash text"

Save the file and update grub:

sudo update-grub

Note that on systemd systems this might not be enough. Switch to text mode using this:

sudo systemctl set-default

You can switch back to graphical mode using “”.
Now reboot.

Auto-login user on console tty1 after boot (OLD, pre-systemd)

Edit the file /etc/init/tty1.conf:

sudo nano /etc/init/tty1.conf

Replace the “exec” line with this:

exec /bin/login -f USERNAME  /dev/tty1 2>&1

replacing USERNAME with you user name. Snatched from here.

Auto-login user on console tty1 after boot (NEW, systemd)

sudo systemctl edit getty@tty1

Add these lines:

ExecStart=-/sbin/agetty -a USERNAME --noclear %I $TERM

replacing USERNAME with you user name. Snatched from here.
Now reload settings:

sudo systemctl restart getty@tty1
sudo systemctl daemon-reload

Now reboot. You should be logged in automagically.
If it does not work, make sure your user is in the tty group. You can add it using:

sudo usermod -a -G tty USERNAME

Use .bash_profile to start a program when user logs in

Edit the file ~/.bash_profile (create if it doesn’t exist):

nano ~/.bash_profile

Here’s a script template:

if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
  exec su -c "xinit PATH_TO_EXECUTABLE --standalone -- -nocursor :0" USERNAME

replacing USERNAME with you user name. Snatched from here.

Use upstart to start a program using on login

Create a new script file file in /etc/init/, e.g.

sudo nano /etc/init/SCRIPTNAME.conf

Here’s a script template:

# Starts a program on startup by using xinit.
# Change USERNAME to your user name below and
# PATH_TO_EXECUTABLE to the executable you want to run.


description "EXECUTABLE-upstart-script"
author "You"

start on (filesystem and stopped udevtrigger)
stop on runlevel [016]

# tell upstart to respawn the process if abnormal exit

# Start executable.
# The option "-- -nocursor" kills all X cursor on XBMC startup and does not interfere with mouse use/operation
  exec su -c "xinit PATH_TO_EXECUTABLE --standalone -- -nocursor :0" $USER
end script

Allow all users to start X from the console

Edit /etc/X11/Xwrapper.config and change the last line that says “allowed_users=console” to:


Found here. Note that some programs might also need:


Force a monitor resolution in X

Edit /usr/share/X11/xorg.conf.d/modes.conf or create it if it doesn’t exist. Add the mode you want to use:

Section "Monitor"
  Identifier "HDMI1"
  Option "PreferredMode" "1024x768"

where HDMI1 is the port the monitor is on and 1024×768 the preferred resolution.

Allow a non-root user to shutdown/restart

Edit /etc/group and add a line that says:


Where NUMBER is an unused number (usually > 1000) and USERNAME is the user you want to grant the permission. USERNAME can now do e.g. “shutdown -h now” or “shutdown -r now”.

You can find some more Linux stuff here.


Published by HorstBaerbel

Software developer by trade and interest, but I venture into the electronics- and diy-world from time to time.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: