Enable Text Console Support in Ubuntu

There are three ways to access the command line interface in Ubuntu, as on any Linux and UNIX distribution. One is launching the terminal emulator program within the graphical user interface. The other two are about accessing the console directly, independent of the graphical user interface and the windowing system powering it (typically X server), and that's what we're concerned with here.

The quickest way to get to the console in Ubuntu is to just press Ctrl-Alt-F1. You will immediately be thrown out of the GUI and into the clean Linux console where you can log in and use the command line. Multiple console terminals are available this way if you press Ctrl-Alt-F2, Ctrl-Alt-F3, and so on.

However, what you might want is to get into the text console when you boot into Ubuntu instead of booting directly into the graphics mode. For that you'll need to make some configuration changes to your GRUB bootloader. The configuration file you will need to modify is /etc/default/grub, and it is a good idea to make a backup of it first in case you ever want to come back to the original configuration:

sudo cp /etc/default/grub /etc/default/grub.backup

With that out of the way you can start modifying the configuration file by opening it, with superuser privileges, in a text editor such as nano:

sudo nano /etc/default/grub

Enter your password and the file will open. Then look for this line: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash". Using nano you can search for this line by pressing the Ctrl-W shortcut and typing that line in. You just need to comment it out by putting a hash character in front of it so it looks like this:


As you might guess this disables booting with the splash screen, and the "quiet" mode, meaning it wouldn't hide the console output during boot.

Next enable the text mode finding GRUB_CMDLINE_LINUX and adding the "text" option to it. The line will then look like this:


This will ensure that you see the text output, but still doesn't enable the console login. For that find the #GRUB_TERMINAL line, which is likely commented out, uncomment it by removing the # character, and add the "console" option to it so it reads like this:


Finally save the file, which in nano you can do by pressing Ctrl-X and then enter, and make sure to update GRUB with the new configuration using the update-grub command:

sudo update-grub

Now you can reboot and Ubuntu should boot in the text mode, and allow you to log in to the console and run the desired commands.

7zip ubuntu

7zip is a versatile open source file archiver that uses the high compression 7z archive format, but also supports many others including ZIP, GZIP, BZIP2, TAR, WIM, XZ for both packing and unpacking, and even more for just unpacking such as RAR, ARJ, CAB, DEB, DMG, MSI, RPM and others. Check out the 7zip web site for more information.

Install 7Zip

7Zip is available for Ubuntu, and Linux in general in form of p7zip, which is a cross-platform version of the program. It is readily available for install from Ubuntu repositories using the Ubuntu Software Center or the APT tool. You can also install 7zip-rar to include RAR support in 7Zip.

Therefore, to install 7zip in Ubuntu simply search for it in the Ubuntu Software Center and install from there. If you want 7zip-rar tick the "Non-free rar module for p7zip (p7zip-rar)" checkbox from Optional add-ons.

To install both packages quickly from the command line just open the Terminal and run the following APT command:

sudo apt-get install p7zip-full p7zip-rar

That's all there is to it! Now you can use 7zip to package and unpackage files and folders using both command line tools 7z and 7za, and graphical tools like Ark, File Roller, and even the Nautilus File Manager.

Using 7Zip

To compress an archive of files and folders with 7Zip into a .7z compressed archive run the following command:

7z a pictures.7z Pictures/

In this example we compressed the Pictures folder into a pictures.7z archive. The "a" function stands for "add" or "archive" for adding specified files to the archive. We can also specify an absolute path to files and folders we want to compress by replacing Pictures/ above with, for example, /mnt/data/Pictures/.

We can also use 7z to compress folders into an archive of a different type, such as ZIP, by passing a -t switch followed immediately by the archive type. To create a pictures.zip we would then run the following:

7z a -tzip pictures.zip Pictures/

To unpack the archive to a specified location we would use the "e" function, which stands for "extract", like this:

7z e pictures.7z

This would extract files and folders to the current directory we are in.

Of course, you don't need to use the command line to compress and extract files with 7zip. Having it installed in Ubuntu automatically integrates it with Nautilus, the Ubuntu's File Manager, which allows you to seamlessly extract 7z and other archives by just right clicking on it and choosing "Extract here".

To compress files and folders just select them, right click, and choose "Compress…". A dialog will open that allows you to select 7z as the format, among many others.

Besides Nautilus having 7Zip installed also adds 7Zip support to other archiving tools such as File Roller and ARK so they can be used as normal to handle 7z archives, and others supported by it.

Ubuntu: How To Enable SSH

Secure Shell (SSH) allows secure communication between networked computers for such purposes as logging in to a remote computer, running some commands remotely, and transferring files (with the scp command).

By default SSH is not enabled in Ubuntu. There is an ssh command installed, but it is only a client, and only allows you to login into another computer, not to allow others to login into yours.

To enable that you first need to install the OpenSSH Server. To do that just use apt-get:

sudo apt-get install openssh-server

If you prefer you can also search for openssh server in the Ubuntu Software Center and install it that way.

Once it is installed you need to enable it in the OpenSSH Server configuration. To do this open and edit the /etc/ssh/ssh_config file with superuser privileges:

sudo nano /etc/ssh/ssh_config

The nano program is a terminal based text editor, but if you prefer a graphical editor you can open it in gedit:

$ sudo gedit /etc/ssh/ssh_config

In that configuration file look for the Port 22 line and uncomment it by removing the preceding hash sign #. That's all you need to edit to get the SSH server working, but if you wish you can review, enable, and edit other configuration options.

Once you're done save the file and restart SSH (which was started automatically when openssh-server was installed) for changes to take effect:

sudo service ssh restart

… or using the old method:

$ sudo /etc/init.d/ssh restart

Your Ubuntu machine will now be able to accept SSH logins and communications through its IP address or host domain.

Using Dropbox with Unix

Although last week saw some pretty exciting developments in the cloud storage (Google Drive announcement and SkyDrive free 25Gb space), the truth is that Dropbox is still the king of the cloud storage hill – it's hands down the easiest to use and integrate.

I've been a Dropbox user for a few years now, but have started using it actively only in the last 12 months or so. It's been an invaluable tool for me thanks to its integration with 1Password, the password tool of my choice. Dropbox also helps with lots of day-to-day tasks and thats why I decided it's time to share some of the tips.

Having used Dropbox extensively on Windows systems (XP on laptop and Win7 on desktops), I've recently moved on to using Dropbox with my Mac OSX desktop and Linux hosting.

So here are the top tips for using Dropbox with Unix – each one does wonders for me and so I hope you like them as well.

Important: If you're not a Dropbox user yet, please use this link to sign up – it means I'll get a small bonus (extra 500MB to my free account) for referring you.

[Read more…]

Passwordless SSH with encrypted homedir in Ubuntu

Quite recently I came across a very interesting issue: while configuring passwordless SSH (it's public key based, so depending on you have it configured it may not be completely passwordless) access to some of my VPS servers, I found that the same keypair just wouldn't work on one of the servers.

Not only that, but the behaviour was quite bizzare: upon my first attempt to connect the public key would get rejected and a regular password would be requested by the ssh session. But once I successfully logged in with my password, any subsequent ssh connections would happily authenticate by my public key and would let me in without a problem.

Those of you using home dir encrypiton in Ubuntu are probably smiling right now! ūüôā But becase I have never consciously configured or used this feature, it took me a good few hours to troubleshoot the issue and come up with the fix.

[Read more…]

Upgrading Ubuntu with do-release-upgrade

There comes a time (a couple of times a year, actually) when you may want to upgrade your Ubuntu distro (read here for instructions on confirming your version of Linux: Find Out Linux Version)

Once that's done, you can use do-release-upgrade for a hassle free upgrade.

IMPORTANT: are you can see, I've used a really old Ubuntu server with 8.10, hence your procedure for upgrading more recent Ubuntu versions may be slightly different. For example, later upgrades will warn you if you're doing a release upgrade over ssh.

What do-release-upgrade is and when you should use it

do-release-script is a Python script which automates the process of updating multiple packages. It relies upon Ubuntu's core package management functionality.

Apart from downloading and installing updated versions of packages found on your system, this command attempts to take care of all the necessary Ubuntu-release related file changes.

Step 1: Run do-release-upgrade

Once you type the do-release-upgrade command name and press Enter, you should see how vital information about packages currently installed is being collected:

# do-release-upgrade
Checking for a new ubuntu release Done
Upgrade tool signature Done
Upgrade tool Done
extracting 'jaunty.tar.gz'
authenticate 'jaunty.tar.gz' against 'jaunty.tar.gz.gpg'
Reading cache
Checking package manager
Reading package lists: Done
Reading state information: Done
Updating repository information
Done http://archive.ubuntu.com jaunty Release.gpg
Done http://archive.ubuntu.com jaunty-updates Release.gpg
Done http://security.ubuntu.com jaunty-security Release.gpg
Done http://us.archive.ubuntu.com jaunty-backports Release.gpg
Done http://security.ubuntu.com jaunty-security Release

Checking package manager
Reading package lists: Done
Packages: 98  2
Reading state information: Done
Reading state information: Done
Reading state information: Done
Calculating the changes


2. Confirming what upgrading will do

This is your last change to change your mind. All the necessary information about your current Ubuntu release is collected, and now you're presented with the exact upgrade details: how many packages will be removed, how many new ones will be installed, how many will be upgraded. You also are given details about the required amount of data to be downloaded should you decide to proceed with the upgrade;

Do you want to start the upgrade?

1 package is going to be removed. 23 new packages are going to be installed. 420 packages are going to be upgraded.

You have to download a total of 248M. This download will take about 7 minutes with your connection.

Fetching and installing the upgrade can take several hours. Once the download has finished, the process cannot be cancelled.

Continue [yN]  Details [d]

Ready? Press y for yes!

3. Downloading all the packages

Just like with apt-get, you will now see the progress of downloading all the updated packages for your Ubuntu OS. At the bottom of the screen you will see the overall completeness of the download (22% in my example), the current download speed (598kB/s in my case) and the ETA:

Done http://archive.ubuntu.com jaunty-updates/main libbz2-1.0 1.0.5-1ubuntu1.1
Done http://archive.ubuntu.com jaunty/main libdb4.7 4.7.25-6ubuntu1
Done http://archive.ubuntu.com jaunty/main libncursesw5 5.7+20090207-1ubuntu1
Done http://archive.ubuntu.com jaunty-updates/main libssl-dev 0.9.8g-15ubuntu3.6
Done http://archive.ubuntu.com jaunty-updates/main libssl0.9.8 0.9.8g-15ubuntu3.6
Done http://archive.ubuntu.com jaunty/main python2.6 2.6.2-0ubuntu1
[23%] 598kB/s 5min17s

4. Upgrade

Once package are downloaded, they will get installed once by one, with package-specific questions asked for software like postfix or apache.

5. Reboot

To finalize the distro upgrade, you will need to do a reboot. Once completed, you should have a shine next release available.

Recommended books:

Ubuntu SSH: How To Enable Secure Shell in Ubuntu

SSH (Secure SHell) is possibly the best way to remotely access a Unix system – it's very secure thanks to automatic encryption of all the traffic, and it's also quite universal because you can do all sorts of things: access remote command line shell, forward graphics session output, establish network tunnels, set up port redirections and even transfer files over the encrypted session.

Today I'm going to show you how to get started with SSH in Ubuntu.

Installing SSH server in Ubuntu

By default, your (desktop) system will have no SSH service enabled, which means you won't be able to connect to it remotely using SSH protocol (TCP port 22). This makes installing SSH server one of the first post-install steps on your brand new Ubuntu.

The most common SSH implementation is OpenSSH. Although there are alternative implementations (closed source solutions and binary distributions maintained by various Unix and Unix-like OS vendors), OpenSSH is a de-facto standard in the secure transfers and connections industry. That's exactly what you want to install.

[Read more…]

How To Confirm if Your CPU is 32bit or 64bit

I had to download a piece of software today for one of the servers which I haven't used in a while. A question of confirming the 64bit CPU capability came up, and I realized that I never mentioned it here on Unix Tutorial.

Some of you probably remember the uname command which also shows you similar information, but uname confirms the running kernel of your OS and not the CPU capability: if you're booted into 32bit mode, it will not help you to recognize the 64bit potential of your system.

Obtaining CPU information from /proc/cpuinfo

Most Linux distros will have the special /proc/cpuinfo file which contains a textual description of all the features your processors have. This is a very useful file – depending on your task it may help you identify any features of your processors, as well as confirm the overall number of CPUs your system has installed.

Most commonly, the following information is obtained from /proc/cpuinfo:

  • processor model name and type
  • processor speed in Mhz
  • processor cache size
  • instruction flags supported by CPU

[Read more…]

How To Change Ownership of Files and Directories in Unix

I've just been asked a question about changing the ownership of files from one Unix user to another, and thought it probably makes sense to have a quick post on it.

File ownership in Unix

Just to give you a quick reminder, I'd like to confirm that every single file in Unix belongs to some user and some group. There simply isn't a way to create a file without assigning ownership. I've briefly touched the topic of confirming file ownership in Unix before, so today I will simply build on that and show you how to change ownership of files.

[Read more…]

Ubuntu Upgrade: From Hardy Heron to Intrepid Ibex

I've been upgrading Ubuntu installations quite a few times recently, and thought it makes sense to post a really short how-to if you ever want to upgrade your Ubuntu distro from the command line.

Use apt-get to upgrade Ubuntu

The procedure for upgrading one Ubuntu release to another one is pretty straightforward. There are some rules though:

  1. Never attempt to skip a release or two when upgrading
  2. Never do a few Ubuntu release upgrades in a row without reboots in between
  3. Always backup the files you change
  4. Always have an install CD for your current Ubuntu release around

[Read more…]