#Linux & Ubuntu Tips
[TOC]
##Yinka's favourite packages
##Get list of installed packages
dpkg -l
dpkg --get-selections | sed 's/\t.*//' > packages-list.txt
# clean list of installed packages, perfect for using with apt-get install.
dpkg --get-selections | grep "[[:space:]]install$" > installed_pkgs
# Get the list of installed packages to a txt
dpkg --get-selections | grep python
# filter to show only python packages
dpkg -L python3
# show files location for python 3 or any package stated
# You can later reinstall the packages in the list using this command:
dpkg --set-selections < installed_pkgs
sudo apt-get -u dselect-upgrade
# show only user install packages
grep -w install /var/log/dpkg.log > full-list.log
# Look at lines beyond the "/var/log/installer/initial-status.gz" timestamp
###PPAs ####Shotwell {#shotwell}
sudo add-apt-repository ppa:yorba/ppa
sudo apt-get update && sudo apt-get install shotwell
####VLC {#vlc}
sudo add-apt-repository ppa:videolan/stable-daily
sudo apt-get update && sudo apt-get install vlc
####Numix GTK and icon themes
sudo add-apt-repository ppa:numix/ppa
sudo apt-get update
sudo apt-get install numix-gtk-theme
sudo apt-get install numix-icon-theme numix-icon-theme-utouch
###Install Python
$ sudo apt-get install python-setuptools python-dev build-essential
###Medibuntu The repository provides all the playback and encoding capabilities that most Windows and Mac systems contain, but which Ubuntu’s creators decline to include by default in their systems, due to licensing restrictions and a lack of open-source code for those features. If you just want to get AAC playback, copyright DVDs playing, and newer versions of all the audio, video, and font files, load Medibuntu repository into your system. (Required)
Open your Terminal, copy and paste:
wget -q "http://packages.medibuntu.org/medibuntu-key.gpg" -O- | sudo apt-key add -
sudo add-apt-repository "deb http://packages.medibuntu.org/ $(lsb_release -sc) free non-free"
sudo apt-get update
sudo apt-get install app-install-data-medibuntu apport-hooks-medibuntu
If you are running a 32-bit version of Ubuntu, copy and paste in Terminal:
sudo apt-get install w32codecs libdvdcss2
sudo /usr/share/doc/libdvdread4/./install-css.sh
If you are running a 64-bit version of Ubuntu, copy and paste in Terminal:
sudo apt-get install w64codecs libdvdcss2
sudo /usr/share/doc/libdvdread4/./install-css.sh
###Essential packages for running 32-bit applications in 64-bit Ubuntu
sudo apt-get install ia32-libs
Special Note: If you are running 32-bit Ubuntu already then you won’t need ia32-libs.
###Sun Java 8 JDK (Recommended)
sudo apt-get purge openjdk*
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
###Skype
sudo apt-get install skype
###Remove programs ####Completely remove chrome
sudo apt-get purge google-chrome-stable
Then remove the folder in config folder /home/username/.config
, and do the same thing to the .cache folder /home/username/.cache/google-chrome
like:
rm -rf /home/username/.config/google-chrome
rm -rf /home/username/.cache/google-chrome
###Unattended upgrade https://help.ubuntu.com/community/AutomaticSecurityUpdates
sudo dpkg-reconfigure -plow unattended-upgrades
###Install Drivers#### ####Texture compression library for Mesa
sudo apt-get install libtxc-dxtn-s2tc0
####Bluetooth
sudo apt-get install \
bluetooth blueman \
bluez-hcidump bluewho python-bluez bluez-tools \
brcm-patchram-plus-nexus7
#####Edit bluetooth conf
$ gksudo gedit /etc/bluetooth/audio.conf # to open audio conf
into the [General] section, add:
Disable = Media
Enable = Socket
And uncomment AutoConnect = true
##Ubuntu configs## ###Tweaks
- Log into Ubuntu one
- On multiple munotors uncheck sticky edges and place launcher on just the main monitor
- Adobe Acrobat reader acroread
- Google chrome chrome.exe
###Keyboard shortcut to move windows between monitors###
- Install
CompizConfig Settings Manager
usingapt-get install compizconfig-settings-manager compiz-plugins-extra
. - Run it (just type
Compiz
in the dash and you'll see it). - Click Window Management.
- Enable the
Put
plug-in (select the check-box). - Click on
Put
. - Configure the shortcut for
Put
to next Output (click the pencil icon next to the keyboard shortcut forPut to next Output
.
###Extend wallpaper across monitors
The default Ubuntu Appearance settings doesn't let you span a single large wallpaper across both monitors or use a different wallpaper for each monitor. Select Preferences
> Display Parameters
and under Multi Monitor Display
, select Extend image (one file for all monitors)
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install syncwall
###Enable hibernation {#hibernation} You can follow official documentation here.
Before enabling hibernation, please try to test whether it works correctly by running sudo pm-hibernate
in a terminal. The system will try to hibernate. If you are able to start the system again then you are more or less safe to add an override.
To do so, start editing:
gksudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
Fill it with this:
[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
Save by pressing Ctrl-O
then enter
and then exit nano by pressing Ctrl-X
.
Restart and hibernation is back!
Or run killall unity-panel-service
to just reset the menu.
Some users will then need to run sudo update-grub
to get the hibernate option to be available in the power menu..
###Disable suspend
Choose any file name, but this is one is verbose/convention:
gksudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.disable-suspend.pkla
Fill it with this:
[Disable suspend by default]
Identity=unix-user:*
Action=org.freedesktop.upower.suspend
ResultActive=no
Ctrl+O, Enter, Ctrl+X
No need to restart, it should be gone as soon as you go into the shutdown menu.
###Post install script References:
- http://askubuntu.com/questions/47404/how-do-i-make-post-install-scripts
- UBUNTU 12.04 - POST-INSTALLATION SCRIPT FOR CODECS, MULTIMEDIA http://bernaerts.dyndns.org/linux/74-ubuntu/270-ubuntu-precise-post-installation-script
- https://github.com/nicolargo/ubuntupostinstall
- https://github.com/snwh/ubuntu-post-install/blob/master/ubuntu-post-install-script-13.10.sh
- http://paste.mitechie.com/show/984/
###Modify Compose key To be able to use unicode e.g type em dash
- Go to System Settings > Keyboard.
- Under Typing tab, select Layout Settings link (at the bottom of the dialog box).
- Click Options
- Under Compose key position (drop-down), choose a key to use for composing — I chose the Right Win (right Windows key).
- Now press and release the compose key, then type --- to get the em-dash.
###Reduce pdf size http://www.ghostscript.com/doc/9.07/Ps2pdf.htm
$ ps2pdf -dPDFSETTINGS=/ebook input.pdf output.pdf
$ man ps2pdf # type this for more info
$ sudo apt-get install ghostscript # using ghostscript
$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
# you might get better result by changing '-dPDFSETTINGS=/screen' to '-dPDFSETTINGS=/ebook'
$ gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dPDFSETTINGS=/ebook -sOutputFile=output.pdf input.pdf
$ man gs # type this for more details
###List all PPAs
grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/*
List all configured software sources (repositories), including currently disabled ones:
cat /etc/apt/sources.list; for X in /etc/apt/sources.list.d/*; do echo; echo; echo "** $X:"; echo; cat $X; done
###Boot-Repair A simple tool to repair frequent boot issues you may encounter in Ubuntu like when you can’t boot Ubuntu after installing Windows or another Linux distribution, or when GRUB is not displayed anymore, or when some upgrades breaks GRUB, etc.
Boot-Repair lets you fix these issues with a simple click, which (generally reinstall GRUB and) restores access to the operating systems you had installed before the issue. You need to boot from your live stick of Ubuntu again and then run these commands in Terminal:
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair
###Grub Customizer GUI configuration tool to allow users to change the Grub 2 settings without using the command line. The application allows the user to add, remove, freeze, rename and reorder boot menu items. It will also allow changes to the Grub 2 configuration settings such as background image and menu timeout. For long-time users familiar with StartUp-Manager, this application performs many of the same capabilities with additional options. It also makes convoluted guides such as my “Grub 2 Title Tweaks” unnecessary for all but the most devoted command-line enthusiasts!
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer
###opt-out of pre-installed advertising lens
sudo apt-get purge unity-lens-shopping
##Commands ###Common commands
$ mkdir dir_name # Create a new folder/directory
$ sudo chown $user dir_path/name # Pass dir to a user
$ sudo chown $user file_name # Pass file to a user
$ cal # Get calendar
$ pwd # Print working directory/present working directory.
$ cd .. # Move up one directory
$ cd / # Navigate to the home directory
$ cd - # Navigate back to the previous directory
$ clear # Clear the prompt clear
$ free -m # Check free memory
$ finger # Who's logged on
$ ls ~ # show files in your home directory, note the space
$ ls -sh # list files with sizes, `ls-sh` is same as `ls -s -h`
$ ~ # The tilde (~) symbol stands for your home directory.
# If you are user, then the tilde (~) stands for /home/user
###System information commands
$ iwlist scan # Scan for wifi
$ lsb_release -d # Ubuntu version or `lsb_release -a`
$ uname -mr # Kernel/architecture or `uname -a`
$ dpkg -l # Get a list of installed program
$ ip addr # system's notworking interface
$ free # Amount of free and used memory
$ top # table of runing processes
$ df -h # Check the disk space `h` means human readable
$ du # displays the disk usage for a directory. add `-sh`
# option for total for the directory you run it on
$ sudo dmidecode | less # Computer name and other info
###SSH
$ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub
$ ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub
$ ssh-keygen -l -f /etc/ssh/ssh_host_key.pub
##Dive into Git
###Step 1: Create a README for your repository
While a README isn't a required part of a GitHub repository, it is a very good idea to have one. READMEs are a great place to describe your project or add some documentation such as how to install or use your project. You might want to include contact information - if your project becomes popular people will want to help you out.
In the prompt, type the following code
mkdir ~/Hello-World # Creates a directory called "Hello-World"
cd ~/Hello-World # Changes the cwd to dir created above
git init # Sets up Git files, initializes empty Git repo
touch README # Creates file README in Hello-World directory
###Step 2: Commit your README
Now that you have your README set up, it's time to commit it. A commit is essentially a snapshot of all the files in your project at a particular point in time. In the prompt, type the following code:
Think of a commit as a snapshot of your project — code, files, everything — at a particular point in time. After your first commit git will only save the files that have changed, thus saving space.
Be warned: git will do it's best to compress your files, but large files and binaries can cause a repository to become bloated and unwieldy. Try to avoid committing things like compressed files (zips, rars, jars), compiled code (object files, libraries, executables), database backups, and media files (flv, psd, music, movies)
$ git add README
# Stages README file, adds it to list of files to be committed
$ git add . # note the period at the end
# Looks at the working tree and adds all those paths to the
# staged changes if they are either changed or are new and
# not ignored, it does not stage any 'rm' actions
$ git add -u
# Looks at all the currently tracked files and stages the
# changes to those files if they are different or if they
# have been removed. It does not add any new files, it only
# stages changes to already tracked files.
$ git add -A # is a handy shortcut for doing above 2
$ git commit -m 'first commit'
# Commits your files, adds the message "first commit
###Step 3: Push your commit
So far everything you've done has been in your local repository, meaning you still haven't done anything on GitHub yet. To connect your local repository to your GitHub account, you will need to set a remote for your repository and push your commits to it:
A remote is a repository stored on another computer, in this case on GitHub's server. It is standard practice (and also the default in some cases) to give the name origin to the remote that points to your main offsite repository (for example, your GitHub repository).
Git supports multiple remotes. This is commonly used when forking a repository.
$ git remote add origin https://github.com/username/Hello-World.git
# Creates a remote named "origin" pointing at your GitHub repo
$ git push origin master
# Sends your commits in the "master" branch to GitHub
Now if you look at your repository on GitHub, you will see your README has been added to it.
###Configuration
Set your global parameters
$ git config --global user.name 'yinka' # username
$ git config --global user.email 'ade@ghh' # email
$ git config --global color.ui true # pretiffy
$ git config --global credential.helper cache # cache password for 15 mins
$ git config --global credential.helper 'cache --timeout=3600' # for 1 hour
To show git configuration
$ git config --list
You can also look at your ~/.gitconfig
file. Local config will be in your repository's .git/config
file.
To exclude files, you can specifically exclude files by using the exclude_patterns config value::
exclude_patterns = ['pages/reference-architecture', some/other/file.txt]
You can exclude individual files, directories, or use file globbing patterns to match groups of files this way.
###Commands
Commonly used git commands
git add -A # stages All
git add . # stages new and modified, without deleted
git add -u # stages modified and deleted, without new
git push # push files to github
git push -f # force a push to overite github
git commit -a -m 'changes' # commit/comment only modifies file
###Keep repository in sync
To contribute to one repo from 2 computers and keep both repositories in sync you want to pull the latest changes to your machine before you start working on the code.
To do this you want to execute
$ git pull origin {branch_name}
# execute the longer version of the same request using:
$ git fetch
$ git merge origin/{branch_name}
Note: this is the same process that you would use if two or more people were working on the same repo. Which is essentially what is happening, instead of two different people working on the same repository, you have two different machines working on the same repository.
Just remember if you are starting out fresh on a new machine to run through all the basics for initializing git.
$ git init
$ git remote add origin git@github.com:username/repo.git
$ git pull origin master
# /* do some coding */
$ git commit -am "my changes"
$ git push origin master
# If you want to combine a couple steps you can do the following
$ git init
$ git clone git@github.com:username/repo.git
# /* do some coding */
$ git commit -am "my changes"
$ git push origin master
git clone
does the same as git remote add origin
and git pull origin master
##Working with remotes
###Showing Your Remotes
To see which remote servers you have configured, you can run the git remote
command. It lists the shortnames of each remote handle you’ve specified. If you’ve cloned your repository, you should at least see origin
— that is the default name Git gives to the server you cloned from
$ git clone git://github.com/schacon/ticgit.git
Initialized empty Git repository in /private/tmp/ticgit/.git/
remote: Counting objects: 595, done.
remote: Compressing objects: 100% (269/269), done.
remote: Total 595 (delta 255), reused 589 (delta 253)
Receiving objects: 100% (595/595), 73.31 KiB | 1 KiB/s, done.
Resolving deltas: 100% (255/255), done.
$ cd ticgit
$ git remote
origin
You can also specify -v, which shows you the URL that Git has stored for the shortname to be expanded to:
$ git remote -v
origin git://github.com/schacon/ticgit.git (fetch)
origin git://github.com/schacon/ticgit.git (push)
If you have more than one remote, the command lists them all. For example, my Grit repository looks something like this.
$ cd grit
$ git remote -v
bakkdoor git://github.com/bakkdoor/grit.git
cho45 git://github.com/cho45/grit.git
defunkt git://github.com/defunkt/grit.git
koke git://github.com/koke/grit.git
origin git@github.com:mojombo/grit.git
This means we can pull contributions from any of these users pretty easily. But notice that only the origin remote is an SSH URL, so it’s the only one I can push to (we’ll cover why this is in Chapter 4).
###Adding Remote Repositories
To add a new remote Git repository as a shortname you can reference easily, run git remote add [shortname] [url]:
$ git remote
origin
$ git remote add pb git://github.com/paulboone/ticgit.git
$ git remote -v
origin git://github.com/schacon/ticgit.git
pb git://github.com/paulboone/ticgit.git
Now you can use the string pb on the command line in lieu of the whole URL. For example, if you want to fetch all the information that Paul has but that you don’t yet have in your repository, you can run git fetch pb:
$ git fetch pb
remote: Counting objects: 58, done.
remote: Compressing objects: 100% (41/41), done.
remote: Total 44 (delta 24), reused 1 (delta 0)
Unpacking objects: 100% (44/44), done.
From git://github.com/paulboone/ticgit
* [new branch] master -> pb/master
* [new branch] ticgit -> pb/ticgit
Paul’s master branch is accessible locally as pb/master — you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it.
###Fetching and Pulling from Your Remotes
As you just saw, to get data from your remote projects, you can run:
$ git fetch [remote-name]
The command goes out to that remote project and pulls down all the data from that remote project that you don’t have yet. After you do this, you should have references to all the branches from that remote, which you can merge in or inspect at any time. (We’ll go over what branches are and how to use them in much more detail in Chapter 3.)
If you clone a repository, the command automatically adds that remote repository under the name origin. So, git fetch origin fetches any new work that has been pushed to that server since you cloned (or last fetched from) it. It’s important to note that the fetch command pulls the data to your local repository — it doesn’t automatically merge it with any of your work or modify what you’re currently working on. You have to merge it manually into your work when you’re ready.
If you have a branch set up to track a remote branch (see the next section and Chapter 3 for more information), you can use the git pull command to automatically fetch and then merge a remote branch into your current branch. This may be an easier or more comfortable workflow for you; and by default, the git clone command automatically sets up your local master branch to track the remote master branch on the server you cloned from (assuming the remote has a master branch). Running git pull generally fetches data from the server you originally cloned from and automatically tries to merge it into the code you’re currently working on.
###Pushing to Your Remotes
When you have your project at a point that you want to share, you have to push it upstream. The command for this is simple: git push [remote-name] [branch-name]. If you want to push your master branch to your origin server (again, cloning generally sets up both of those names for you automatically), then you can run this to push your work back up to the server:
$ git push origin master
# push same repo to another remote
$ git push appengine master
This command works only if you cloned from a server to which you have write access and if nobody has pushed in the meantime. If you and someone else clone at the same time and they push upstream and then you push upstream, your push will rightly be rejected. You’ll have to pull down their work first and incorporate it into yours before you’ll be allowed to push. See Chapter 3 for more detailed information on how to push to remote servers.
###Inspecting a Remote
If you want to see more information about a particular remote, you can use the git remote show [remote-name] command. If you run this command with a particular shortname, such as origin, you get something like this:
$ git remote show origin
* remote origin
URL: git://github.com/schacon/ticgit.git
Remote branch merged with 'git pull' while on branch master
master
Tracked remote branches
master
ticgit
It lists the URL for the remote repository as well as the tracking branch information. The command helpfully tells you that if you’re on the master branch and you run git pull, it will automatically merge in the master branch on the remote after it fetches all the remote references. It also lists all the remote references it has pulled down.
That is a simple example you’re likely to encounter. When you’re using Git more heavily, however, you may see much more information from git remote show:
$ git remote show origin
* remote origin
URL: git@github.com:defunkt/github.git
Remote branch merged with 'git pull' while on branch issues
issues
Remote branch merged with 'git pull' while on branch master
master
New remote branches (next fetch will store in remotes/origin)
caching
Stale tracking branches (use 'git remote prune')
libwalker
walker2
Tracked remote branches
acl
apiv2
dashboard2
issues
master
postgres
Local branch pushed with 'git push'
master:master
This command shows which branch is automatically pushed when you run git push on certain branches. It also shows you which remote branches on the server you don’t yet have, which remote branches you have that have been removed from the server, and multiple branches that are automatically merged when you run git pull.
###Removing and Renaming Remotes
If you want to rename a reference, in newer versions of Git you can run git remote rename to change a remote’s shortname. For instance, if you want to rename pb to paul, you can do so with git remote rename:
$ git remote rename pb paul
$ git remote
origin
paul
It’s worth mentioning that this changes your remote branch names, too. What used to be referenced at pb/master is now at paul/master.
If you want to remove a reference for some reason — you’ve moved the server or are no longer using a particular mirror, or perhaps a contributor isn’t contributing anymore — you can use git remote rm:
$ git remote rm paul
$ git remote
origin
##Appendix ###Resources Linux help sites:
###Post Install Script We start out with going command line and do this:
$ touch post_install_script
$ sudo 775 post_install_script
$ gedit post_install_script
Start with enabling all repositories and refreshing the software list because the LiveCD is outdated:
sudo sed 's/# deb/deb/' -i /etc/apt/sources.list
sudo apt-get update
What does this do?
- update sources list
- remove all directories in my home and create them again in /discworld2/ After that I recreate my home directory directories using symlinks. This way I am able to format my home and keep my files (they are not only on another partition but even on another disc);
- install software I want;
- set power management the way I want it.
- add ppa's I want
After installing I just execute my post_install file and it will run for a long time but it will take care of everything I want (well I will be adding more and more things over time so it will get longer)
#!/bin/bash
# https://github.com/deshack/ubuntu-utility-script
# https://github.com/snwh/ubuntu-post-install/blob/master/ubuntu-post-install-script-13.04.sh
#----------------------------#
# UBUNTU POST-INSTALL SCRIPT #
#----------------------------#
echo ''
echo '#-------------------------------------------#'
echo '# Ubuntu 13.04 Post-Install Script #'
echo '#-------------------------------------------#'
# SYSTEM UPGRADE
function sysupgrade {
# Update Repository Information
echo 'Updating repository information...'
echo 'Requires root privileges:'
sudo apt-get update -qq
# Dist-Upgrade
echo 'Performing system upgrade...'
sudo apt-get dist-upgrade -y
echo 'Done.'
main
}
# INSTALL FAVOURITE APPLICATIONS
function appinstall {
# Install Favourite Applications
echo 'Installing selected favourite applications...'
echo 'Requires root privileges:'
# Edit the following line to setup your Favourite Applications
# - filezilla: FTP client
# - gimp: image editor
# - inkscape: vector graphics editor
# - xchat: IRC client
# - chromium-browser: Chromium Web Browser, the open source base of Google Chrome
# - audacity: audio editor and recorder
# - meld: text files differences viewer
# - filezilla gimp inkscape #########
sudo apt-get install -y --no-install-recommends xchat audacity meld cairo
echo 'Done.'
main
}
# INSTALL FAVOURITE SYSTEM TOOLS
function toolinstall {
echo 'Installing system tools...'
echo 'Requires root privileges:'
# Two SSH utilities, feel free to add your favourite System Tools
sudo apt-get install -y --no-install-recommends openssh-server ssh
echo 'Done.'
main
}
# INSTALL MULTIMEDIA CODECS
function codecinstall {
# Install Ubuntu Restricted Extras Applications
echo 'Installing Ubuntu Restricted Extras...'
echo 'Requires root privileges:'
sudo apt-get install -y ubuntu-restricted-extras vlc ccsm aptitude dconf-tools openjdk-7-jdk openssh-server p7zip-full ppa-purge samba ssh synaptic virt-manager zsync
echo 'Done.'
main
}
# INSTALL DEV TOOLS
function devinstall {
# Install Development Tools
echo 'Installing development tools...'
echo 'Requires root privileges:'
# - bzr: Bazaar distributed version control
# - git: version control and content tracking
# - ruby: Ruby programming language
sudo apt-get install -y bzr git
echo 'Done.'
main
}
# EXTRA INSTALLATION
function thirdparty {
INPUT=0
echo ''
echo 'What would you like to do? (Enter the number of your choice)'
echo ''
while [ true ]
do
echo '1. Install Google Chrome (Unstable)?'
echo '2. Install Google Talk Plugin?'
echo '3. Install Steam?'
echo '4. Install Unity Tweak Tool?'
echo '5. Install DVD playback tools?'
echo '6. Return'
echo ''
read INPUT
# Google Chrome (Unstable)
if [ "$INPUT" -eq 1 ]; then
echo 'Downloading Google Chrome (Unstable)...'
# Make tmp directory
if [ -e $HOME/tmp ]; then
mkdir -p $HOME/tmp
else
continue
fi
cd $HOME/tmp
# Download Debian file that matches system architecture
if [ $(uname -i) = 'i386' ]; then
wget https://dl.google.com/linux/direct/google-chrome-unstable_current_i386.deb
elif [ $(uname -i) = 'x86_64' ]; then
wget https://dl.google.com/linux/direct/google-chrome-unstable_current_amd64.deb
fi
# Install the package
echo 'Installing Google Chrome...'
sudo dpkg -i google*.deb
sudo apt-get install -fy
# Cleanup and finish
rm *.deb
cd
echo 'Done.'
thirdparty
# Google Talk Plugin
elif [ "$INPUT" -eq 2 ]; then
echo 'Downloading Google Talk Plugin...'
# Make tmp directory
if [ -e $HOME/tmp ]; then
mkdir -p $HOME/tmp
else
continue
fi
cd $HOME/tmp
# Download Debian file that matches system architecture
if [ $(uname -i) = 'i386' ]; then
wget https://dl.google.com/linux/direct/google-talkplugin_current_i386.deb
elif [ $(uname -i) = 'x86_64' ]; then
wget https://dl.google.com/linux/direct/google-talkplugin_current_amd64.deb
fi
# Install the package
echo 'Installing Google Talk Plugin...'
sudo dpkg -i google*.deb
sudo apt-get install -fy
# Cleanup and finish
rm *.deb
cd
echo 'Done.'
thirdparty
# Steam
elif [ "$INPUT" -eq 3 ]; then
echo 'Downloading Steam...'
# Make tmp directory
if [ -e $HOME/tmp ]; then
mkdir -p $HOME/tmp
else
continue
fi
cd $HOME/tmp
# Download Debian file that matches system architecture
if [ $(uname -i) = 'i386' ]; then
wget http://repo.steampowered.com/steam/archive/precise/steam_latest.deb
elif [ $(uname -i) = 'x86_64' ]; then
wget http://repo.steampowered.com/steam/archive/precise/steam_latest.deb
fi
# Install the package
echo 'Installing Steam...'
sudo dpkg -i steam*.deb
sudo apt-get install -fy
# Cleanup and finish
rm *.deb
cd
echo 'Done.'
thirdparty
# Unity Tweak Tool
elif [ "$INPUT" -eq 4 ]; then
# Install the package
echo 'Installing Unity Tweak Tool...'
sudo apt-get install -y unity-tweak-tool
echo 'Done.'
thirdparty
# Medibuntu
elif [ "$INPUT" -eq 5 ]; then
echo 'Adding Medibuntu repository to sources...'
echo 'Requires root privileges:'
sudo -E wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get update -qq && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get update -qq
echo 'Done.'
echo 'Installing libdvdcss2...'
sudo apt-get install -y libdvdcss2
echo 'Done.'
# Return
elif [ "$INPUT" -eq 6 ]; then
clear && main
else
# Invalid Choice
echo 'Not an option, choose again.'
thirdparty
fi
done
}
# CONFIG
function config {
INPUT=0
echo ''
echo 'What would you like to do? (Enter the number of your choice)'
echo ''
while [ true ]
do
echo '1. Set preferred application-specific settings?'
echo '2. Show all startup applications?'
echo '3. Return'
echo ''
read INPUT
# GSettings
# You can find these options in System Settings or Unity Tweak Tool
# and in the corresponding applications' settings
if [ "$INPUT" -eq 1 ]; then
# Font Sizes
echo 'Setting font preferences...'
gsettings set org.gnome.desktop.interface text-scaling-factor '1.0'
gsettings set org.gnome.desktop.interface document-font-name 'Sans 11'
gsettings set org.gnome.desktop.interface font-name 'Ubuntu 11'
gsettings set org.gnome.desktop.interface monospace-font-name 'Ubuntu Mono 13'
gsettings set org.gnome.nautilus.desktop font 'Ubuntu 11'
gsettings set org.gnome.desktop.wm.preferences titlebar-font 'Ubuntu Bold 11'
gsettings set org.gnome.settings-daemon.plugins.xsettings antialiasing 'rgba'
gsettings set org.gnome.settings-daemon.plugins.xsettings hinting 'slight'
# Unity Settings
echo 'Setting Unity preferences...'
gsettings set com.canonical.Unity.ApplicationsLens display-available-apps false
gsettings set com.canonical.unity-greeter draw-user-backgrounds true
gsettings set com.canonical.unity-greeter draw-grid false
gsettings set com.canonical.indicator.power icon-policy 'present'
gsettings set com.canonical.Unity.Lenses remote-content-search 'all'
# Nautilus Preferences
echo 'Setting Nautilus preferences...'
gsettings set org.gnome.nautilus.preferences sort-directories-first true
# Gedit Preferences
echo 'Setting Gedit preferences...'
gsettings set org.gnome.gedit.preferences.editor display-line-numbers true
gsettings set org.gnome.gedit.preferences.editor create-backup-copy false
gsettings set org.gnome.gedit.preferences.editor auto-save true
gsettings set org.gnome.gedit.preferences.editor insert-spaces false
gsettings set org.gnome.gedit.preferences.editor tabs-size 8
# Rhythmbox Preferences
echo 'Setting Rhythmbox preferences...'
gsettings set org.gnome.rhythmbox.rhythmdb monitor-library true
gsettings set org.gnome.rhythmbox.sources browser-views 'artists-albums'
# Totem Preferences
echo 'Setting Totem preferences...'
gsettings set org.gnome.totem active-plugins "['chapters', 'movie-properties', 'skipto', 'screensaver', 'autoload-subtitles', 'recent', 'screenshot', 'save-file', 'apple-trailers', 'media_player_keys']"
config
# Startup Applications
elif [ "$INPUT" -eq 2 ]; then
echo 'Changing display of startup applications.'
echo 'Requires root privileges:'
cd /etc/xdg/autostart/ && sudo sed --in-place 's/NoDisplay=true/NoDisplay=false/g' *.desktop
cd
echo 'Done.'
config
# Return
elif [ "$INPUT" -eq 3 ]; then
clear && main
else
# Invalid Choice
echo 'Not an option, choose again.'
config
fi
done
}
# CLEANUP SYSTEM
function cleanup {
INPUT=0
echo ''
echo 'What would you like to do? (Enter the number of your choice)'
echo ''
while [ true ]
do
echo ''
echo '1. Remove unused pre-installed packages?'
echo '2. Remove old kernel(s)?'
echo '3. Remove orphaned packages?'
echo '4. Remove residual config files?'
echo '5. Clean package cache?'
echo '6. Return?'
echo ''
read INPUT
# Remove Unused Pre-installed Packages
if [ "$INPUT" -eq 1 ]; then
echo 'Removing selected pre-installed applications...'
echo 'Requires root privileges:'
sudo apt-get purge
echo 'Done.'
cleanup
# Remove Old Kernel
elif [ "$INPUT" -eq 2 ]; then
echo 'Removing old Kernel(s)...'
echo 'Requires root privileges:'
sudo dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
echo 'Done.'
cleanup
# Remove Orphaned Packages
elif [ "$INPUT" -eq 3 ]; then
echo 'Removing orphaned packages...'
echo 'Requires root privileges:'
sudo apt-get autoremove -y
echo 'Done.'
cleanup
# Remove residual config files?
elif [ "$INPUT" -eq 4 ]; then
echo 'Removing residual config files...'
echo 'Requires root privileges:'
sudo dpkg --purge $(COLUMNS=200 dpkg -l | grep '^rc' | tr -s ' ' | cut -d ' ' -f 2)
echo 'Done.'
# Clean Package Cache
elif [ "$INPUT" -eq 5 ]; then
echo 'Cleaning package cache...'
echo 'Requires root privileges:'
sudo apt-get clean
echo 'Done.'
cleanup
# Return
elif [ "$INPUT" -eq 6 ]; then
clear && main
else
# Invalid Choice
echo 'Not an option, choose again.'
cleanup
fi
done
}
# END
function end {
echo ''
read -p 'Are you sure you want to quit? (Y/n) '
if [ "$REPLY" = 'n' ]; then
clear && main
else
exit
fi
}
# MAIN FUNCTION
function main {
INPUT=0
echo ''
echo 'What would you like to do? (Enter the number of your choice)'
echo ''
while [ true ]
do
echo '1. Perform system update & upgrade?'
echo '2. Install favourite applications?'
echo '3. Install favourite system tools?'
echo '4. Install development tools?'
echo '5. Install Ubuntu Restricted Extras?'
echo '6. Install third-party applications?'
echo '7. Configure system?'
echo '8. Cleanup the system?'
echo '9. Quit?'
echo ''
read INPUT
# System Upgrade
if [ "$INPUT" -eq 1 ]; then
clear && sysupgrade
# Install Favourite Applications
elif [ "$INPUT" -eq 2 ]; then
clear && appinstall
# Install Favourite Tools
elif [ "$INPUT" -eq 3 ]; then
clear && toolinstall
# Install Dev Tools
elif [ "$INPUT" -eq 4 ]; then
clear && devinstall
# Install Ubuntu Restricted Extras
elif [ "$INPUT" -eq 5 ]; then
clear && codecinstall
# Install Third-Party Applications
elif [ "$INPUT" -eq 6 ]; then
clear && thirdparty
# Configure System
elif [ "$INPUT" -eq 7 ]; then
clear && config
# Cleanup System
elif [ "$INPUT" -eq 8 ]; then
clear && cleanup
# End
elif [ "$INPUT" -eq 9 ]; then
end
else
# Invalid Choice
echo 'Not an option, choose again.'
main
fi
done
}
# CALL MAIN FUNCTION
main
#-----------------------------------#
# END OF UBUNTU POST-INSTALL SCRIPT #
#-----------------------------------#