Just a collection of useful Linux scripts or commands.
Booting the system to console with grub2Edit the file /etc/default/grub:
sudo nano /etc/default/grubChange the line GRUB_CMDLINE_LINUX_DEFAULT to include "text":
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash text"Save the file and update grub:
Auto-login user on console tty1 after bootEdit the file /etc/init/tty1.conf:
sudo nano /etc/init/tty1.confReplace the "exec" line with this:
exec /bin/login -f USERNAME < /dev/tty1 > /dev/tty1 2>&1replacing USERNAME with you user name. Snatched from here.
Use .bash_profile to start a program when user logs inEdit the file ~/.bash_profile (create if it doesn't exist):
nano ~/.bash_profileHere's a script template:
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; thenreplacing USERNAME with you user name. Snatched from here.
exec su -c "xinit PATH_TO_EXECUTABLE --standalone -- -nocursor :0" USERNAME
Use upstart to start a program using on loginCreate a new script file file in /etc/init/, e.g.
sudo nano /etc/init/SCRIPTNAME.confHere's a script template:
# Starts a program on startup by using xinit.Note:
# Change USERNAME to your user name below and
# PATH_TO_EXECUTABLE to the executable you want to run.
start on (filesystem and stopped udevtrigger)
stop on runlevel 
# tell upstart to respawn the process if abnormal exit
exec su -c "xinit PATH_TO_EXECUTABLE --standalone -- -nocursor :0" $USER
-- -nocursoroption kills all X cursor on XBMC startup and does not interfere with mouse use/operation
Allow all users to start X from the consoleEdit
/etc/X11/Xwrapper.configand replace the last line that says:
Force a monitor resolution in XEdit
/usr/share/X11/xorg.conf.d/modes.confor create it if it doesn't exist. Add the mode you want to use:
Section "Monitor"where HDMI1 is the port the monitor is on and 1024x768 the preferred resolution.
Option "PreferredMode" "1024x768"
Allow a non-root user to shutdown/restartEdit
/etc/groupand add a line that says:
shutdown:x:NUMBER:USERNAMEWhere 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 nowor
shutdown -r now.