Slackware 15.0 setup scripts

12 June 2024
The previous guide to Slackware 15 is a little out of date and since these days installing Slackware is something that I do quite often, I decided to rewrite the previous article as a selection of shell script snippets rather than update it. Given how often I provision then tear down VirtualBox virtual machines maybe I ought to setup some sort of PXE-boot unattended install system with something like Ansible or Vagrant, but for my purposes having a script that does all the stuff like UK localisation and locking down OpenSSH in one go “works for me”.

Bare-bones setup

Allow root login via SSH

sed -i 's/^#PermitRootLogin prohibit-password$/PermitRootLogin yes/' /etc/ssh/sshd_config

UK localisation

sed -i 's/^export LANG=en_US.UTF-8$/export LANG=en_GB.UTF-8/' /etc/profile.d/lang.sh sed -i 's/^setenv LANG en_US.UTF-8$/setenv LANG en_GB.UTF-8/' /etc/profile.d/lang.csh

Bash profile

The PS1 directive makes the Bash prompt look like [remy@SlackBox ~/Projects]$ which is the RedHat default, and the one I stuck with long after I stopped using RedHat.

cat > ~/.bashrc <<EOF . ~/.bash_profile EOF cat > ~/.bash_profile <<EOF export PS1='[\u@\h \w]\\$ ' export SVN_EDITOR=scite export GIT_EDITOR=scite export PATH=$PATH:~/bin/ EOF

Adding a non-root user

export NEW_USER=remy export NEW_NAME="Remy" export PASSWORD="sekret" useradd -g users -N -m -c "${NEW_NAME}" ${NEW_USER} echo -e "${PASSWORD}\n${PASSWORD}" | passawd ${NEW_USER}

Setting user groups

Not sure if all these groups are needed but in the past they have solved various problems.

export NEW_USER=remy for group in video,audio,plugdev,cdrom,wheel; do usermod -a -G ${group} ${NEW_USER}; done

More advanced setup

Multilib (32-bit software) support

lftp -c "open http://bear.alienbase.nl/mirrors/people/alien/multilib/ ; mirror -c -e 15.0" cd 15.0 upgradepkg --reinstall --install-new *.t?z upgradepkg --install-new slackware64-compat32/*-compat32/*.t?z

Enable sudo

The ‘proper’ way to edit the file is via visudo but on a fresh install without any other users this is not an issue.

sed -i 's/# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers

Locking down SSH

This means disallowing all password access so logging in has to be via public keys. These days I never use passwords for remote access.

sed -i 's/^#KbdInteractiveAuthentication yes$/KbdInteractiveAuthentication no/' /etc/ssh/sshd_config sed -i 's/^#PasswordAuthentication yes$/PasswordAuthentication no/' /etc/ssh/sshd_config

Set virtual memory swappiness

This controls how preemptive Linux is with moving things from memory to swap. On systems with a lot of RAM I think it better to keep stuff in physical memory.

echo "echo 30 > /proc/sys/vm/swappiness" >> /etc/rc.d/rc.local

Setting up firewall

This covers just the IPv4 firewall. Setting up IPv6 firewalling has not yet been automated..

#!/bin/sh # # /etc/rc.d/rc.firewall # case "$1" in 'start') iptables -t filter -P INPUT ACCEPT iptables -t filter -A INPUT -i lo -j ACCEPT iptables -t filter -A INPUT -p tcp --syn -j REJECT iptables -t filter -P OUTPUT ACCEPT iptables -t filter -P FORWARD DROP ;; 'stop') iptables -t filter -P INPUT ACCEPT iptables -t filter -P OUTPUT ACCEPT iptables -t filter -P FORWARD ACCEPT iptables -t filter -F INPUT iptables -t filter -F OUTPUT iptables -t filter -F FORWARD ;; *) echo "Usage: $0 {start|stop}" ;; esac

Selecting slackpkg mirror

Easier to append mirror than to uncomment it..

cat >> /etc/slackpkg/mirrors <<EOF http://ftp.mirrorservice.org/sites/ftp.slackware.com/pub/slackware/slackware64-15.0/ EOF

Graphical-login related setup

For systems using NVidia graphics card the Nouveau drivers need to be disabled by installing the xf86-video-nouveau-blacklist package. This can be done via slackpkg and it can also be found on the installation DVD within the extra directory.

Boot into graphical login

sed -i 's/^id:.:initdefault:$/id:4:initdefault:/' /etc/inittab

Sorting out SDDM theming

sed -i 's/^InputMethod=.*$/InputMethod=/' /etc/sddm.conf sed -i 's/^Current=.*$/Current=maldives/' /etc/sddm.conf

US and UK keyboards in SDDM

echo 'setxkbmap "gb,us"' >> /usr/share/sddm/scripts/Xsetup

Set XDM to use IceWM

cd /etc/X11/xinit cat > xinitrc.icewm <<EOF #!/bin/sh userresources=$HOME/.Xresources usermodmap=$HOME/.Xmodmap sysresources=/etc/X11/xinit/.Xresources sysmodmap=/etc/X11/xinit/.Xmodmap # merge in defaults and keymaps if [ -f $sysresources ]; then /usr/bin/xrdb -merge $sysresources fi if [ -f $sysmodmap ]; then /usr/bin/xmodmap $sysmodmap fi if [ -f $userresources ]; then /usr/bin/xrdb -merge $userresources fi if [ -f $usermodmap ]; then /usr/bin/xmodmap $usermodmap fi exec dbus-launch --exit-with-session /usr/local/bin/icewm-session EOF rm xinitrc ln -s xinitrc.blackbox xinitrc

Adding restart & shutdown buttons to XDM

cp /etc/X11/xdm/Xsetup_0 /etc/X11/xdm/Xsetup_remy cat >> /etc/X11/xdm/Xsetup_remy <<EOF ( xmessage -buttons Shutdown:20,Reboot:21 "" ; case \$? in 20) exec /sbin/poweroff;; 21) exec /sbin/reboot;; esac )& EOF cp /etc/X11/xdm/Xresources /etc/X11/xdm/Xresources_remy cat >> /etc/X11/xdm/Xresources_remy <<EOF Xmessage*geometry: 180x30+0-0 Xmessage*background: white Xmessage*foreground: black Xmessage*borderWidth: 0 Xmessage*message.scrollVertical: Never Xmessage*message.scrollHorizontal: Never Xmessage*Text*background: white Xmessage*Text*foreground: darkgrey Xmessage*Text.borderColor: white Xmessage*Text.borderWidth: 0 EOF cat >> /etc/X11/xdm/GiveConsole_remy <<EOF #!/bin/sh killall xmessage chown $USER /dev/console EOF sed -i 's/Xsetup/Xsetup_remy/' /etc/X11/xdm/xdm-config sed -i 's/Xresources/Xresources_remy/' /etc/X11/xdm/xdm-config sed -i 's/GiveConsole/GiveConsole_remy/' /etc/X11/xdm/xdm-config