What Ubuntu offers - Linux Nitty Gritty: Working at the Ubuntu Command-Line Prompt (2011)

Linux Nitty Gritty: Working at the Ubuntu Command-Line Prompt (2011)

What Ubuntu offers

Ubuntu is a thoroughly modern operating system that provides everything you might find in Windows or Macintosh OS X, but without the drawbacks. It keeps things simple, yet offers sophisticated features.

Hardware support is excellent, with virtually every item of day-to-day hardware supported, including graphics/sound cards, printers, wireless, USB memory sticks, cameras, iPods, and so-on. There’s no need to fumble around with driver CDs—practically everything will be up and running straight after installation, although as with any operating system you may have to configure the system to your own tastes and needs.

Users and the filesystem

The purpose of this chapter is to get you to speed with the Ubuntu filesystem. You’ll learn about:

* How Ubuntu compares to Windows when it comes to files;

* Where things can be found in the Ubuntu filesystem;

* The basics of the users and permissions system that lies at the heart of Ubuntu.

How Ubuntu handles files

Some comparison between Windows and Ubuntu is inevitable when discussing the filesystem. Although fundamentally similar, as a variant of Linux, Ubuntu differs from Windows in the following ways.

Paths

There are no drive letters under Ubuntu. Instead, the root of the filesystem, known as C:\ under Windows, is identified simply by a forward slash (/).

Additionally, whereas Windows uses a backslash (\) to indicate the root of the filesystem, and to separate folders in a path listing, Ubuntu uses a forward slash.

So, whereas a path like C:\Documents and Settings\Owner\My Documents is common under Windows, you will see something like /home/frank/Documents in Ubuntu. This difference can be jarring at first, but you’ll be surprised at how quickly you get used to it.

Mounting

If there are no drive letters then how are other storage devices accessed, such as CD/DVD drives, or USB memory sticks?

The answer is that they’re mounted—effectively, the filesystem of the storage device is magically plumbed through to a particular folder within the Ubuntu filesystem. Insert a CD/DVD, for example, and its contents will be visible when you browse to the /media/cdrom folder.

It’s important to note that the files aren’t literally copied to the folder. They’re made available in a virtual way. You can manipulate the files and folders like any other files and folders, and although it might appear as if they’re contained in that particular folder, they aren’t.

Anything that might have already been in the folder used as the mount point will temporarily disappear. However, the contents are still there, and if the storage device is unmounted, the contents will reappear.

Mounting might sound complicated, but don’t worry—it’s nearly always done automatically, either at boot-up for devices permanently attached to your PC, or when you attach a removable storage device to the computer, such as a USB stick. You probably won’t be aware of it taking place, in fact; all the user sees after inserting a USB memory stick is a new icon on the desktop that, when double-clicked, lets her browse the USB stick’s files. Of course, if the user looks closely, she will see that she’s actually browsing the folder that the USB memory stick has been mounted at.

File & folder names

File and folder names can contain spaces, as with Windows, but upper/lowercase letters are important in Linux. A folder can feasibly contain separate files called Report.doc, REPORT.doc, report.doc, RePORT.doc, and so on.

NOTE This ability of an operating system to differentiate between upper and lower case letters is called case sensitivity.

Additionally, file and folder names under Ubuntu can contain practically any letter, number, or symbol, with the exception of the forward slash (/).

NOTE Whereas Windows refers to folders, many Linux users refer to directories. Exactly the same thing is being discussed. The term directory is nearly always used at the command-line, although the term folder is preferred when using the Ubuntu desktop.

Important filesystem locations

Each user on the system is given their own folder within the /home folder in which to save personal data. For example, the user jane is given the folder /home/jane. The /home folder is akin to C:\Documents and Settings under Windows.

TIP Linux users often refer to their folder within /home as their “home folder”, saying things like, “I couldn’t find the file but I remembered I’d saved it in my home folder.”

Users aren’t permitted to save their personal files outside of their /home folder. This is rigidly enforced using ownerships and file permissions, as I explain in the Understanding Users section below.

Outside of the /home folder, the Ubuntu filesystem is a little more complicated than Windows, and it isn’t quite a case of program files being in one location, and system files in another.

A cursory rundown of the Ubuntu filesystem can be found in Table 4-1, although this is not essential knowledge and is provided largely for reference purposes.

Perhaps the most important locations for the majority of users are /home, as described above; /usr/bin, where practically all software is located; and /etc, where system configuration files are found.

NOTE Like many versions of Linux, Ubuntu broadly follows the Filesystem Hierarchy Standard (FHS) to decide where things should go in the filesystem. For more details, including in-depth descriptions of each location, see www.pathname.com/fhs/.

Hidden files and folders

Windows lets users hide files and folders by setting a file attribute.

Linux takes a simpler approach. Any file or folder that has a period (.) at the beginning doesn’t appear in file listings, unless the user specifically requests all files/folders be listed.

In other words, if you rename report.doc to .report.doc, it will instantly become invisible and will seem to disappear from the file browsing window (you might have to hit the Refresh button in the file browser window to update the listing before the file actually vanishes).

A user’s personal configuration files are stored in his or her /home folder and are hidden in this way. To view them, and other hidden files, click View > Show Hidden Files in a file browsing window.

NOTE Any file or folder that has a tilde (~) at the end of its filename (i.e. report.doc~) will be hidden in file listings provided by the Nautilus file manager, and on the desktop. They will be visible everywhere else, including at the command-line.

Table 4-1. Key locations in the Ubuntu filesystem.

Location

Details

/bin

Essential software, typically needed to get the system running

/boot

Files related to the boot menu/loader

/dev

Virtual files representing hardware devices

/etc

System (global) configuration files

/home

Users’ personal folders

/lib

Support (library) files required by software

/media

Contains subfolders where storage devices can be mounted

/proc

Virtual folder containing files representing stats and settings

/root

Personal folder of the root user

/sbin

Essential software for system maintenance, usually used only by the root user

/tmp

Temporary files/folders

/usr

Essentially, subdirectories containing most software used on the system, including system libraries and documentation

/var

Data that is vital to the running of the system and that is constantly being updated

File extensions

Generally speaking, the trend with Linux is not to use file extensions for system files. Executable programs under Ubuntu don’t have a file extension, such as .exe, as with Windows. Instead, the fact they are programs and not ordinary data files is indicated by the use of the executable file attribute.

Configuration files sometimes have a .conf file extension, but often have no file extension at all. Many files that are plain text have no file extension, in fact; the use of the .txt file extension is rare in the world of Linux. Program documentation files in the /usr/share/doc folder, for example, are plain text and have no file extensions.

NOTE It isn’t quite true that files in the /usr/share/doc folder have no file extensions because some program documentation files are compressed, so have a .gz file extension, but this is a minor point.

However, when it comes to the personal files of users, such as documents or images, file extensions are as important as they are under Windows. Files with a .doc extension are recognized as Microsoft Word files, for example, and .jpg files are recognized as images.