Skip to content

Setting up my linux PC

ferng edited this page Jul 23, 2023 · 65 revisions

A few bits of build config and general commands to set up the system and access things like external disks.

System

Partitioning

Size Mount Point Notes Backup Mount Point
2 Gb /boot Primary N /dev/sda1
142 Gb / Logical Y /dev/sda2
4 Gb /swap Logical N /dev/sda3
8 Gb Backup Logical - Not Mounted /dev/sda5
32 Gb Minimal Linux partition Primary - Not Mounted -

Dual boot order

sudo vi /etc/default/grub
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=3

#then
sudo update-grub
sudo grub-set-default <NUMBER>

Boot to console

sudo vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="text"
GRUB_TERMINAL=console

# then
sudo update-grub

# restart in gui
reboot-gui.sh
# restart in text 
reboot-text.sh

Console

Silence perf

sudo vi /etc/sysctl.conf

#uncomment
kernel.printk = 3 4 1 3

Security

Disk encryption

#install utils
sudo apt-get install ecryptfs-utils cryptsetup

#as another admin user encrypt the account's home directory
sudo ecryptfs-migrate-home -u <user>

#as the encrypted user run
ecryptfs-unwrap-passphrase
#enter a passphrase and record the output

#view passphrase
ecryptfs-unwrap-passphrase

Firewall

sudo ufw allow 22
sudo ufw status
sudo ufw enable
sudo ufw status
sudo ufw deny 22
sudo ufw status
sudo ufw app info Samba
less ufw.log

User access

#as root
apt-get install sudo
usermod -a -G sudo fern

LXQT

Remove shit

#libre office
sudo apt purge libreoffice-common
sudo apt remove libreoffice-core libreoffice-common libreoffice-style-breeze

#clean up and remove fonts
sudo apt autoremove

HIDPI

# dpi
vi ~/.Xresources
Xft.dpi: 150

Theme

bash sudo apt install qt5-style-kvantum

Applications

chrome

front end (does nothing)

  • Preferences | LXQT | Session settings | Default applications | google-chrome
  • Preferences | LXQT | File Associations | chrome for:
html, xml

backend

# remove BROWSER lines from 
sudo vi /etc/xdg/xdg-Lubuntu/lxqt/session.conf 
vi ~/.config/lxqt/session.conf

# find chrome desktop shortcut
ls /usr/share/applications/*chr*
sudo xdg-settings set default-web-browser google-chrome.desktop

# auto install
sudo apt-get update
sudo apt-get --only-upgrade install google-chrome-stable

Fonts

cd ~/.local/share/
mkdir fonts
cp ~/Downloads/*.ttf fonts
fc-cache -f -v

LXDE

Application shortcuts

cd /usr/share/applications
sudo cp google-chrome.desktop idea.desktop
sudo vi idea.desktop

[Desktop Entry]
Encoding=UTF-8
Exec=/opt/idea-IC-183.4886.37/bin/idea.sh
Icon=/opt/idea-IC-183.4886.37/bin/idea.png
Type=Application
Terminal=false
Name=intellij
GenericName=intellij
StartupNotify=true
Categories=Programming;

Fonts

cd /usr/share/fonts/truetype
sudo mkdir google
sudo cp ~/Downloads/Inconsolata-Regular.ttf google

XCFE

Configuration

  • Settings > Appearance: Xfce-winter
  • Settings > Appearance > Font: Sans 9
  • Settings > Desktop > Default Icons: off
  • Settings > Keyboard > Layout > Keyboard model > a4tech kb21
  • Settings > Appearance > Settings > Toolbar Style > Text
  • Settings > Notifications > Bottom Right | 6 Seconds
  • Settings > Power Mgmt > On Ac > Sleep : 8 | Off 10
  • Settings > Preferred Applications > Web : Chromium
  • Settings > Screen Saver : Disable
  • Settings > Session and Startup > Power Management : On
  • Settings > Window Manager > Style : Redmond
  • Settings > WorkSpaces
  • Download xcfe configuration files

Ubuntu Unity

Resize Display

gsettings set org.gnome.desktop.interface scaling-factor 1

Cleaner applicaton switcher

  • Install compizconfig
sudo apt-get install compizconfig-settings-manager compiz-plugins-extra
  • Search for ubuntu unity plugin
  • In switcher tab and disable everything
  • Search for Application Switcher (under window management or try Static Application switcher)
  • In general tab disable Icon (ugly icons off)
  • Enable application switcher (left panel)

Ubuntu Gnome

Resize Display

#reset xhost for sudo (Invalid MIT-MAGIC-COOKIE-1 key)
xhost local:root

#switch from wayland to xorg
sudo vi /etc/gdm3/custom.conf
#uncomment
WaylandEnable=false

#set vanila gnome choose the 
sudo apt install gnome-session
sudo update-alternatives --config gdm3.css
#select gnome-sell.css

#tidy up top bar
 sudo apt install gnome-shell-extension-pixelsaver

Hardware

Touchpad

Configure

# display devices
cat /proc/bus/input/devices

cd /etc/X11/xorg.conf.d
sudo vi 51-synaptics.conf

# add this section
Section "InputClass"
  Identifier "touchpad ignore SynPS/2 Synaptics duplicate"
  MatchProduct "SynPS/2 Synaptics TouchPad" 
  Option "Ignore" "on" 
EndSection

cd /usr/share/X11/xorg.conf.d
sudovi 51-synaptics-quirks.conf

# add this section
Section "InputClass"
  Identifier "SynPS/2 Synaptics TouchPad"
  MatchProduct "SynPS/2 Synaptics TouchPad"
  MatchIsTouchpad "on"
  MatchOS "Linux"
  MatchDevicePath "/dev/input/event*"
  Option "Ignore" "on"
EndSection

#restart xorg
sudo systemctl restart lightdm

Control

#disable if using mouse
gsettings set org.gnome.desktop.peripherals.touchpad send-events disabled-on-external-mouse

#enable touchpad back on
gsettings set org.gnome.desktop.peripherals.touchpad send-events enabled

#switch it off altogether
gsettings set org.gnome.desktop.peripherals.touchpad send-events disabled

Trackball sensitivity

  • install xinput sudo apt install xinput
  • run ./trackballAccel.sh

Bluetooth pairing issues

  • distrust and unpair keyboard on both windows and linux
  • pair with ubuntu
  • pair with windows

windows

  • in windows open Control Panel\Hardware and Sound\Devices and Printers in explorer
  • right click on the keyboard
  • click properties
  • click Bluetooth tab
  • make a note of the unique identifier 00:18:00:3a:c3:5a

ubuntu

  • open the windows partition in explorer (just to mount it)
sudo apt-get install chntpw
# this is the windows partition
cd /media/fern/625E099E5E096BDB/Windows/System32/config 
chntpw -e SYSTEM
cd ControlSet001\Services\BTHPORT\Parameters\Keys
ls
# shows the PCs bluetooth mac address
cd 0c84dc44dee8
ls
# shows the paired bluetooth mac addresses for the keyboard (check against the bluetooth Identifier you got in windows) so we need to get the paired key
hex 0018003ac35a
:00000  15 6C C5 97 9F 01 29 37 E3 6B 7F 94 6D 04 98 94 .l....)7.k..m...

# copy everything after the :00000 then on a separate terminal
cd /var/lib/bluetooth/
sudo su
# cd to this PCs bluetooth config
cd 0C\:84\:DC\:44\:DE\:E8/
# cd to the keyboard's paired config
cd 00\:18\:00\:3A\:C3\:5A/
vi info
# replace the key with the value copied above (removing spaces)
156CC5979F012937E36B7F946D049894
sudo /etc/init.d/bluetooth restart

restart bluetooth

sudo systemctl restart bluetooth.service

check bluetooth issues

hcitool dev
journalctl -xb | grep blue

Intermitent connection

vi /etc/modprobe.d/disable_autosuspend.conf 
# Disable autosuspend for btusb to make the bluetooth keyboard work again
options btusb enable_autosuspend=n

# view config
systool -v -m btusb

Bluetooth headset

sudo apt install pulseaudio-module-bluetooth 
pulseaudio -k
pulseaudio --start

Samba

Install Samba and set up drives

#as root
apt-get install smbclient smbfs
apt-get install ntfs-3g
smbclient -L 192.168.2.1

mkdir /media/belkin
mkdir /media/pendrive

Access drives

sudo mount -t cifs -o uid=1000 //192.168.2.1/hd-lbu2 /media/belkin
sudo mount -t cifs -o uid=1000 //192.168.2.1/pendrive /media/pendrive

House Keeping

Create rescue USB disk

#find out what device it's mount as
mount
 
#copy iso image
cat debian-live-x.x.x-amd64-rescue.iso > /dev/sdb

Boot up from USB disk and backups

sudo su -
mkdir /mnt/sda7
mount /dev/sda7 /mnt/sda7
cp /mnt/sda7/bin/backup*.sh .

#backups
./backupHome.sh
./backupFull.sh

Environment

File system

  • Disable fschk on /tmp
sudo tune2fs -c -1 /dev/sda11

Enable NTP

sudo apt-get install ntp

Set up timezone

sudo  dpkg-reconfigure tzdata

Google Chrome

Installation

#download keys
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

#add repo
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'

#install
sudo apt update

sudo apt install google-chrome-stable

Configuration

  • System Settings > Default Applications > Browser > Select > Internet > google-chrome
  • start chrome > don't ask again
  • System Settings > Advanced > File Associations > Text > html > Google Chrome

Thunderbird

cd /usr/local
sudo cp ~/Downloads/thunderbird-78.2.2.tar.bz2 .
sudo tar -xvf thunderbird-78.2.2.tar.bz2 
sudo rm -rf thunderbird-78.2.2.tar.bz2 

Moin Moin

Installation

  • user: fern / 2looks
cd~
mkdir bin
cd bin
cp /media/belkin/fern/forDev/apps/moin-1.9.4.tar.gz .
tar -zxvf moin-1.9.4.tar.gz
rm moin-1.9.4.tar.gz

vi ~/bin/wiki.sh
  #! /bin/sh
  ~/bin/moin-1.9.4/wikiserver.py
chmod 744 ~/bin/wiki.sh

vi ~/bin/moin-1.9.4/wikiserverconfig.py
:%s/8080/8010/g

#start wiki
wiki.sh

Transfer/Backup Moin Moin

#disk to PC
cp -r /media/4GB/wiki/data /home/fern/bin/moin-1.9.4/wiki
cp -r /media/pendrive/wiki/data /home/fern/bin/moin-1.9.4/wiki
cp -r /media/belkin/fern//wiki/data /home/fern/bin/moin-1.9.4/wiki

#PC to disk
cp -r /home/fern/bin/moin-1.9.4/wiki/data /media/4GB/wiki
cp -r /home/fern/bin/moin-1.9.4/wiki/data /media/pendrive/wiki
cp -r /home/fern/bin/moin-1.9.4/wiki/data /media/belkin/fern/wiki

#PC to Google Drive
cd /home/fern/bin/moin-1.9.4
rm moin.tar.gz
tar -zcvf moin.tar.gz wiki/data
mv moin.tar.gz ~

#Google Drive to PC
cd ~/bin/moin-1.9.4
rm -r wiki/data/*
mv ~/Downloads/moin.tar.gz .
tar -zxvf moin.tar.gz

Delete a Moin Moin user

cd /home/fern/bin/moin-1.9.4
rm *pyc
cd /home/fern/bin/moin-1.9.4/wiki/data/cache/wikiconfig/user
rm name2id
cd /home/fern/bin/moin-1.9.4/wiki/data/user
grep fern *

#delete the file that shows up

Screen

Installation

(Windows Only)

  # start C:\cygwin\Cygwin.bat as adminitrator
  groups  #to display available groups
  chgrp Users /tmp/uscreens/S-Fernando
  chmod 700 /tmp/uscreens/S-Fernando
  #exit cygwin, et voila all done

Configuration

  • Scrollback buffer:
vi ~/.screenrc
defscrollback 10000
vbell "off"

vi ~/.inputrc
set bell-style none

vi ~/.minttyrc
BoldAsFont=no
RightClickAction=paste

Usage

Start Screen

Command Action
<CTRL+A> + ?

Start a job

Command Action
<CTRL+A> + c start a new screen leaving the job running in the existing one
<CTRL+A> + n change to next window
<CTRL+A> + p change to previous window
<CTRL+A> + K quit

Reconnect after conn drops

Command Action
screen -ls lists screen sessions
screen -r 2824.pty0.LON01-01829 reattaches screen

Move through scrollback buffer

Command Action
<CTRL+A> + [ start scrollback browsing
h move the cursor left by one character
j move the cursor down by one line
k move the cursor up by one line
l move the cursor right by one character
0 move to the beginning of the current line
$ move to the end of the current line
G move to the specified line (defaults to the end of the buffer)
<CTRL+u> scroll a half page up
<CTRL+b> scroll a full page up
<CTRL+d> scroll a half page down
<CTRL+f> scroll the full page down
/ search forwards
? search backwards

Copy and paste

Command Action
start block, move, then to end block
<CTRL+A> + ] paste block

Raspberry Pi

Install Raspbian

  • Download Raspbian
  • Format SD with SD Formatter
  • write image win32 disk manager

Headless complex

enable ssh
sudo raspi-config
Interfacing Options
ssh # to enable ssh server

Updates

# update OS and patches - run this periodically
sudo apt update
sudo apt full-upgrade -y

Headless simple

  • Add a file with the name ssh to the root directory on the sd card

Mongodb

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mongodb-server
sudo service mongodb start

Node

# check cpu
cat /proc/cpuinfo

# get the model name (in brackets v6l) then download it
wget https://nodejs.org/dist/v10.0.0/node-v10.0.0-linux-armv6l.tar.gz

# install it
sudo mv node-v10.0.0-linux-armv6l.tar.gz /opt
cd /opt
sudo tar -xzf node-v10.0.0-linux-armv6l.tar.gz
sudo mv node-v10.0.0-linux-armv6l nodejs
sudo rm node-v10.0.0-linux-armv6l.tar.gz

# set up the environment
sudo ln -s /opt/nodejs/bin/node /usr/bin/node
sudo ln -s /opt/nodejs/bin/npm /usr/bin/npm

Printer server

Install cups

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install cups 

Configure cups

# add your user to the group created by CUPS called lpadmin that has access to the printer queue. 
sudo usermod -a -G lpadmin pi 

#configure cups for remote admin
sudo vi  /etc/cups/cupsd.conf 
#comment out 
Listen localhost:631 
#add
Port 631 

# configure locations - Restrict access to the server...
<Location />
  Order allow,deny
  Allow @local
</Location>

# Restrict access to the admin pages...
<Location /admin>
  Order allow,deny
  Allow @local
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow @local
</Location>

# Restrict access to log files...
<Location /admin/log>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow @local
</Location>

Activate changes

# restart cups
sudo /etc/init.d/cups restart 

# open firewall for cups
sudo iptables -A INPUT -i eth0 -p tcp -m tcp --dport 631 -j ACCEPT
sudo iptables -A INPUT -i eth0 -p udp -m udp --dport 631 -j ACCEPT 

Install Samba

sudo apt-get install samba  

Expose services for windows and Apple

sudo  vi /etc/samba/smb.conf

[printers]
   comment = All Printers
   browseable = no
   path = /var/spool/samba
   printable = yes
   guest ok = yes
   read only = yes
   create mask = 0700

# Windows clients look for this share name as a source of downloadable
# printer drivers
[print$]
   comment = Printer Drivers
   path = /usr/share/cups/drivers
   browseable = yes
   read only = yes
   guest ok = no

[global]
## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP
# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable its WINS Server
   wins support = yes

Restart Samba

sudo /etc/init.d/samba restart  

Set up clients

# Windows
#select a shared printer by name
http://192.168.1.252:631/printers/EPSON_EPL-6200

# Apple - it's magic
# Unix - it's magic

Acer aspire

Config

Grub

sudo vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="nomodeset"
#GRUB_TERMINAL=console
#GRUB_GFXMODE=640x480
#GRUB_GFXPAYLOAD_LINUX=640x480

sudo update-grub
# then reboot

Clone this wiki locally