Run Google Chrome and Chromium complete from RAM so that it doesn't leave any trace of cache or any browing related data on the Hard Disk. For this you need at least 4GB of free RAM.
#!/bin/bash
set -euo pipefail
USER="unhappyghost"
HOME="/home/$USER"
RAM="/media/ramdisk"
CHROME_CFG="$RAM/chromeConfigStable"
CHROME_CACHE="$RAM/chromeCacheStable"
CHROME_VER_FILE="$CHROME_CFG/.chrome-version"
CHROMIUM_CFG="$RAM/chromiumConfig"
CHROMIUM_CACHE="$RAM/chromiumCache"
SNAP_CFG="$RAM/chromiumSnapConfig"
SNAP_CACHE="$RAM/chromiumSnapCache"
echo "[*] Initializing Chrome RAM environment"
# ---------- helper ----------
ensure_crashpad() {
local dir="$1/Crashpad"
mkdir -p "$dir"
chmod 700 "$dir"
}
# ---------- detect Chrome version ----------
if command -v google-chrome >/dev/null 2>&1; then
CUR_VER=$(google-chrome --version | awk '{print $3}')
else
CUR_VER="unknown"
fi
if [[ -f "$CHROME_VER_FILE" ]]; then
OLD_VER=$(cat "$CHROME_VER_FILE")
else
OLD_VER=""
fi
if [[ "$CUR_VER" != "$OLD_VER" ]]; then
echo "[!] Chrome version change detected: $OLD_VER → $CUR_VER"
rm -rf "$CHROME_CFG"
fi
# ---------- Chrome Stable ----------
rm -rf "$HOME/.cache/google-chrome"
mkdir -p "$CHROME_CACHE"
ln -sf "$CHROME_CACHE" "$HOME/.cache/google-chrome"
rm -rf "$HOME/.config/google-chrome"
mkdir -p "$CHROME_CFG"
ensure_crashpad "$CHROME_CFG"
echo "$CUR_VER" > "$CHROME_VER_FILE"
ln -sf "$CHROME_CFG" "$HOME/.config/google-chrome"
# ---------- Chromium (deb) ----------
rm -rf "$HOME/.cache/chromium"
mkdir -p "$CHROMIUM_CACHE"
ln -sf "$CHROMIUM_CACHE" "$HOME/.cache/chromium"
rm -rf "$HOME/.config/chromium"
mkdir -p "$CHROMIUM_CFG"
ensure_crashpad "$CHROMIUM_CFG"
ln -sf "$CHROMIUM_CFG" "$HOME/.config/chromium"
# ---------- Chromium (snap-safe) ----------
if [[ -d "$HOME/snap/chromium/common" ]]; then
rm -rf "$HOME/snap/chromium/common/.cache"
mkdir -p "$SNAP_CACHE"
ln -sf "$SNAP_CACHE" "$HOME/snap/chromium/common/.cache"
rm -rf "$HOME/snap/chromium/common/chromium"
mkdir -p "$SNAP_CFG"
ensure_crashpad "$SNAP_CFG"
ln -sf "$SNAP_CFG" "$HOME/snap/chromium/common/chromium"
fi
# ---------- OOM protection ----------
if command -v systemd-run >/dev/null 2>&1; then
echo "[*] OOM protection enabled (user.slice)"
systemctl --user set-property user.slice MemoryHigh=90% MemoryMax=95% >/dev/null 2>&1 || true
fi
echo "[✓] Chrome RAM environment ready"
echo "[✓] Launch Chrome manually"
sudo nano /etc/fstab
tmpfs /media/ramdisk tmpfs defaults,nodev,nosuid,noatime,mode=1777 0 0
save and exit.
sudo mkdir /media/ramdisk
sudo nano ~/.chromecache
#!/bin/sh
USER=xer0conf
#for caching google chrome stable
/bin/rm -r -f /home/$USER/.cache/google-chrome
/bin/mkdir /media/ramdisk
/usr/bin/chown -R $USER:$USER /media/ramdisk
#for Cache
/bin/mkdir /media/ramdisk/chromeCacheStable
/usr/bin/chown -R $USER:$USER /media/ramdisk/chromeCacheStable
/bin/ln -s /media/ramdisk/chromeCacheStable /home/$USER/.cache/google-chrome
/usr/bin/chown -R $USER:$USER /home/$USER/.cache/google-chrome
#for Config, bookmarks, downloads etc
/bin/rm -r -f /home/$USER/.config/google-chrome
/bin/mkdir /media/ramdisk/chromeConfigStable
/usr/bin/chown -R $USER:$USER /media/ramdisk/chromeConfigStable
/bin/ln -s /media/ramdisk/chromeConfigStable /home/$USER/.config/google-chrome
/usr/bin/chown -R $USER:$USER /home/$USER/.config/google-chrome
#for caching google chrome unstable
/bin/rm -r -f /home/$USER/.cache/google-chrome-unstable
#for cache
/bin/mkdir /media/ramdisk/chromeCacheUnstable
/usr/bin/chown -R $USER:$USER /media/ramdisk/chromeCacheUnstable
/bin/ln -s /media/ramdisk/chromeCacheUnstable /home/$USER/.cache/google-chrome-unstable
/usr/bin/chown -R $USER:$USER /home/$USER/.cache/google-chrome-unstable
#for config, bookmarks, download etc
/bin/rm -r -f /home/$USER/.config/google-chrome-unstable
/bin/mkdir /media/ramdisk/chromeConfigUnstable
/usr/bin/chown -R $USER:$USER /media/ramdisk/chromeConfigUnstable
/bin/ln -s /media/ramdisk/chromeConfigUnstable /home/$USER/.config/google-chrome-unstable
/usr/bin/chown -R $USER:$USER /home/$USER/.config/google-chrome-unstable
#for the chromium cache
/bin/rm -r -f /home/$USER/.cache/chromium
#for cache
/bin/mkdir /media/ramdisk/chromiumCache
/usr/bin/chown -R $USER:$USER /media/ramdisk/chromiumCache
/bin/ln -s /media/ramdisk/chromiumCache /home/$USER/.cache/chromium
/usr/bin/chown -R $USER:$USER /home/$USER/.cache/chromium
#for config, bookmarks, download etc
/bin/rm -r -f /home/$USER/.config/chromium
/bin/mkdir /media/ramdisk/chromiumConfig
/usr/bin/chown -R $USER:$USER /media/ramdisk/chromiumConfig
/bin/ln -s /media/ramdisk/chromiumConfig /home/$USER/.config/chromium
/usr/bin/chown -R $USER:$USER /home/$USER/.config/chromium
#for the snap chromium cache
/bin/rm -r -f /home/$USER/snap/chromium/common/.cache
#for cache
/bin/mkdir /media/ramdisk/chromiumSnapCache
/usr/bin/chown -R $USER:$USER /media/ramdisk/chromiumSnapCache
/bin/ln -s /media/ramdisk/chromiumSnapCache /home/$USER/snap/chromium/common/.cache
/usr/bin/chown -R $USER:$USER /home/$USER/snap/chromium/common/.cache
#for config, bookmarks, download etc
/bin/rm -r -f /home/$USER/snap/chromium/common/chromium
/bin/mkdir /media/ramdisk/chromiumSnapConfig
/usr/bin/chown -R $USER:$USER /media/ramdisk/chromiumSnapConfig
/bin/ln -s /media/ramdisk/chromiumSnapConfig /home/$USER/snap/chromium/common/chromium
/usr/bin/chown -R $USER:$USER /home/$USER/snap/chromium/common/chromium
save and exit.
sudo chmod +x ~/.chromecache
Add the script to system startup app
sudo nano /etc/rc.local
/home/xer0conf/.chromecache
exit 0
save and exit
sudo chmod +x /etc/rc.local
Source: https://www.squash.io/executing-bash-script-at-startup-in-ubuntu-linux/