Ubuntu Command line Display Driver Change

Recently upgraded to 15.10 and that looked okay at first. However, the displa driver that it installed, NVIDIA, was causing issues. So I defaulted back to the open source driver and reboot. MISTAKE! Ended up causing the system to crash and couldn’t do anything about it.

I rebooted into root terminal. Then ran a command to display the available drivers.

ubuntu-drivers devices

The spit out a list of drivers. Then I reinstalled the latest available nvidia driver.

apt-get install nvidia-352-updates

Failed to spawn command gulp

I ran in to the error with Atom, Failed to spawn command gulp. The solution for me was to install the module globally.

$ sudo npm install -g gulp
/usr/bin/gulp -> /usr/lib/node_modules/gulp/bin/gulp.js
[email protected] /usr/lib/node_modules/gulp
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

Easy and done.

GIT push from one repo to another

Splitting off from a branch to another git repo seems like it would suck. In reality it’s simple. Two lines and you’re set.

Things you’ll need:

  • Source repo pulled down locally
  • Target repo created on your git server (GitHub, BitBucket, GitLab, etc)
  • Url for target git repo
  • Branches

$ cd /path/to/source
$ git remote add [email protected]:my_team/my_awesome_target_repo.git
$ git push targetrepo my_branch_to_create_off_of:master

That’ll create the master branch off of the branch “my_branch_to_create_off_of” from your local repo.

Bash test if file exists

Using bash I needed to check that a file exists, then do something. This one turns out to be super simple. I wanted to conditionally load a db file if it existed in this case.

What I needed was, a check for the file in bash. Then execute the command. In this instance it was to load a postgres restore file.

[ -f $db_dump ] && printf "Loading DB...\n";sudo su postgres -c "pg_restore -d db_name_here $db_dump;" || printf "No db dump to load\n"

Another way to write this is to use a full if/else conditional. Admittedly this is a little cleaner.

if [ -f "$db_dump" ]
	printf "Loading DB...\n";
        sudo su postgres -c "pg_restore -d db_name_here $db_dump;"
	printf "No DB file found.\n";