Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download and install Latest NVIDIA driver on Debian based OS
#!/bin/bash
## this script is for Debian\Ubuntu.
## Check if root
if [ ! $UID = 0 ]; then
echo "This script needs super user privileges to run"
echo "run it againg using sudo or login as root"
exit 1
fi
## Stop the DM:
service lightdm stop
service gdm stop
service kdm stop
## remove existing drivers, install dkms
apt-get update
apt-get purge nvidia*
apt-get install dkms
## Get file name
LATEST_FILE="ftp://download.nvidia.com/XFree86/Linux-x86_64/latest.txt"
BASE_URL="http://uk.download.nvidia.com/XFree86/Linux-x86_64"
## Check curl || wget
if [ -f /usr/bin/curl ]; then
function dl_name() {
curl -s "$1"
}
function dl() {
curl -o "$2" "$1"
}
elif [ -f /usr/bin/wget ]; then
function dl_name() {
wget -q -O - "$1"
}
function dl() {
wget -O $2 $1
}
fi
PATH_LATEST="$(dl_name $LATEST_FILE | cut -d" " -f2)"
FILE_NAME="$(basename $PATH_LATEST)"
FILE_URL="$BASE_URL/$PATH_LATEST"
## Download
dl "$FILE_URL" "$FILE_NAME"
## Execute
chmod +x "$FILE_NAME"
sh "$FILE_NAME"
## Reboot
echo "Reboot your system.."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment