How to Install MySQL – Ubuntu


apt-get install --print-uris mysql-server > desktop

This will print out a bunch of URLs. You can download these from another computer, and transfer them to your Ubuntu machine, putting the .deb files into /var/cache/apt/archives.

sudo apt-get install mysql-server

And apt will find the package files you’ve downloaded, and install mysql.

Ubuntu reset root password

Boot up the machine, and after the BIOS screen, hold the Right Shift when booting up, to get the Grub menu

Select the GRUB (Recovery Mode)

Hit the down arrow until you select the 2nd entry from the top (the one with the recovery mode in the description) and then hit Enter.

Using the arrow keys scroll down to root and then hit Enter.

You should now see a root prompt, something like this:


At this stage you should have a read-only filesystem. You have to remount it with write permissions:

mount -rw -o remount /

Now we can set the user’s password with the passwd command. (In this example I will use jorge as the example, you need to substitute whatever the user’s username is):

root@ubuntu:~# passwd <user>
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Type in what you want the new password to be at the prompt. After it’s successful reboot the machine and the user will be able to log in with their new password.

Package Management

APT: Advanced Package Tool. Works with ‘deb‘ archive from the location specified in the “/etc/apt/sources.list” file.


  • dpkg -l : List all packages
  • dpkg -i <pkgname>: Install a package
  • dpkg -r <pkgname>: Remove a package
  • dpkg -s <pkgname>: Whether an deb package installed or not.


When you install packages from the command line with sudo apt-get install ... (or sudo aptitude install ...), or when you upgrade them from the command line (with upgrade or dist-upgrade instead of install), the following information is obtained from your local system’s configuration, and not from the Internet:

  1. what packages are available
  2. what versions of them are available
  3. where the available packages should be retrieved from

Running sudo apt-get update (or sudo aptitude update) updates this on your local system. This is the step that actually retrieves information about what packages can be installed, including what updates to currently installed packages packages are available, from Internet sources.

Because information about what updated versions of packages are available is obtained by running sudo apt-get update (or sudo aptitude update), it is advisable to run this before installing any package, and necessary to run it to install the latest updates, even if you have not added or removed any Software Sources (such as a PPA).

The apt-get utility is a command line program, used to work with Ubuntu’s APT (Advanced Packaging Tool) library

  • installation of new software packages,
  • removing existing software packages,
  • upgrading of existing software packages and even used to upgrading the entire operating system.

The apt-cache command line tool is used for searching apt software package cache.

  • apt-cache pkgnames : To list all the available packages
  • apt-cache show scala : To check information of package
  • apt-cache showpkg scala : Which packages are dependent on the package

The ‘update‘ command is used to resynchronize the package index files from the their sources specified in /etc/apt/sources.list file. The update command fetched the packages from their locations and update the packages to newer version.

  • sudo apt-get update
  • sudo apt-get install scala : To update specific package
  • sudo apt-get install scala=2.3 : To update to a specific version of the package
  • sudo apt-get remove scala: Remove a package (Configuration Files Maintained)
  • sudo apt-get purge scala: Remove package with configurations
  • sudo apt-get clean: Free up disk space by cleaning .deb files

Remove Java from Ubuntu

sudo update-alternatives --remove-all java
sudo update-alternatives --remove-all javac
sudo update-alternatives --remove-all javaws
sudo rm -rf /usr/lib/jvm/jdk1.8.0


mv: Short for move, this command can be used to move your files from one folder to another.

rm: Short for remove, this command is used to remove any files or folders.

cd: Short for change, you can use this command to change your current directory.

cp: Short for copy, this command can be used to copy files or folders in a directory.

chown: This command is used to change ownership of a file.

chmod: This command is used to change permissions on a file.

ls: Short for list, this command can be used to view all of the files and folders in your current working directory.

pwd: Short for print working directory, this command can be used to display the directory in which you are currently working.

sudo: Also referred to as superuser do, a sudo command allows you to run other commands with administrative privileges. This command is especially useful for modifying files in a directory that a user wouldn’t necessarily have access to.

cd: Short for change directory, this command can be used to change the directory in which you are currently working. There are a variety of cd commands that can be used to take you to specific files or folders.

cd / : An alternate to a basic cd command, the cd / command can be used to take you to the root directory.

cd .. : This command can be used to take you up one directory level.

cd – : This command can be used to navigate to a previous directory.


locate filename :

whatis ls: gives a brief description of the shell command.

whereis :

type source: source is a shell bulletin

./ dot slash

A dot slash is a dot followed immediately by a forward slash ( ./ ). It is used in Linux and Unix to execute a compiled program in the current directory. For example, if you had an executable file in the current directory called “hope” and typed “hope” at the command line, you would get an error such as “-bash: hope: command not found”. This is because this command is not a built-in command, and the executable file is not found in your PATH


source ~/.bashrc

source is a bash shell built-in command that executes the content of the file passed as argument, in the current shell. It has a synonym in ‘.’ (period).