Skip to main content

More About Linux System Administration

The Terminal and the GUI

As in OS X and Windows, there are typically two main ways to achieve a given goal in Linux: through the GUI and through the command line (known in Linux parlance as the console or the terminal).

The appearance of various Linux distributions can be quite different, depending on the desktop environment in use. In this book, the recommended Raspbian distribution is used, but most of the commands you will be learning are entered at the terminal and are typically the same across all distributions.

Where other distributions differ, you will be given alternative methods of achieving the same goals.

Introducing Raspbian

Raspbian is the name given to a customised variant of the popular Debian Linux distribution. Debian is one of the longest-running Linux distributions and concentrates on stability, high compatibility, and excellent performance even on modest hardware—making it a great partner for the Raspberry Pi. Raspbian takes Debian as its base, or parent distribution, and adds custom tools and software to make using the Raspberry Pi as easy as possible.

To keep the download size to a minimum, the Raspberry Pi image for Raspbian includes only a subset of the software you’d find on a regular desktop version. It includes tools for browsing the web, programming in Python, and using the Pi with a GUI. You can quickly install additional software using the distribution’s package manager, apt. Raspbian includes a desktop environment known as the Lightweight X11 Desktop Environment (LXDE). Designed to offer an attractive user interface using the X Window System software, LXDE provides a familiar point-and-click interface that is immediately convenient if you’ve used Windows, OS X, or other GUI-based operating systems in the past.

To use Raspbian, you must enter a username and password. The default username is pi, and the default password is raspberry.

The Raspbian operating system is under constant development, with software being added to and removed from the default list on a regular basis. While the following listing is correct at the time of writing, don’t be surprised to find the software on your installation differing somewhat.

The software provided with the Raspbian distribution is split into themed categories. To view these categories, left-click the Menu button found on the top left of the screen as part of the taskbar (see Figure shown below).
The Raspbian Desktop
We will discuss about software packages comes along with Raspbian later.

About Raspbian’s Parent, Debian

Raspbian is based on one of the original Linux distributions, Debian. Named after its creator and his girlfriend—Ian and Deb Debian (Ha... ha...) is a popular distribution in its own right. Raspbian is a fork of Debian, a version adapted by the community for a particular task. It isn’t alone. Ubuntu Linux, from Canonical, is also based on Debian, while Linux Mint, one of the most popular distributions for desktops and laptops, is based in turn on Ubuntu.

This process of forking and forking again is unique to open source software. With a closed source package, like Microsoft Windows, it’s not possible to customise it to your individual requirements. This is one of the biggest strengths of open source software, and is brilliantly demonstrated by the ease with which Raspbian was tailored to the requirements of the Raspberry Pi.

Alternatives to Raspbian

Raspbian is the recommended Linux distribution for the Raspberry Pi, but there are alternatives. The most popular are available from the Raspberry Pi Foundation’s downloads page, and most can be installed easily using NOOBS, as described in earler, “Getting Started with the Raspberry Pi”.

Next to Raspbian, the most common distributions installed are LibreELEC and OSMC, which both turn the Pi into a dedicated home theatre system “The Pi as a Home Theatre PC”. The next most popular is Pidora, a distribution based on the Fedora Linux project, which, in turn, has Red Hat as its parent distribution. Another alternative, Arch Linux is designed for those already familiar with Linux; unlike the others in the list, it doesn’t include a GUI by default.

One of the available operating systems is not a variant of Linux at all: RISC OS. Originally produced by Acorn Computers in the late 1980s for its Archimedes range of personal computers—which, like the Raspberry Pi, were based on an ARM processor—RISC OS is a fast, easy-to-use operating system with a clean-looking GUI. While the breakup of Acorn in 1998 saw the popularity of RISC OS decline, the platform still has its fans, and they were quick to add support for the Raspberry Pi.

Running RISC OS on the Raspberry Pi results in an environment that is significantly more responsive than any of the other operating systems offered, thanks to its origins as a plat-
form designed specifically for the ARM instruction set architecture. Sadly, that speed comes at a cost: RISC OS runs only applications that are written specifically for RISC OS, which are far fewer in number than those written for Linux.

NOOBS is smart enough to show you only operating systems which are supported by your model of Pi. Operating systems which require the BCM2836 processor or above, such as Windows 10 IoT Core, will not appear when running NOOBS on the BCM2835-based Model A, Model B, Model A+, Model B+, or Raspberry Pi Zero, for example.

File System Layout

The content of the SD card is known as its file system and is split into multiple sections, each with a particular purpose. Although to use the Raspberry Pi it’s not necessary for you to understand what each section does, that background knowledge can be helpful should anything go wrong.

Users and Groups

In Linux, each user has three main attributes: a user ID (UID), a group ID (GID), and a list of supplementary group memberships. A user can be a member of as many groups as he or 
she pleases, although only one of these can be the user’s primary group. This is usually a self-named group matching the username.

Group membership is important. Users can be granted direct access to files and devices on the system, but it’s more common for a user to receive access to these via group membership. The group audio, for example, grants all members the ability to access the Pi’s sound playback hardware. Without that membership, the user won’t be listening to any music.

To see a user’s group memberships, type groups username at the terminal. If you use this on the default user pi, you’ll see the list of groups any new member should join to make use of the Pi. This is where the information used in Step 2 of the preceding procedure was found.

Logical Layout

The way Linux deals with drives, files, folders, and devices differs somewhat from other operating systems. Instead of having multiple drives labelled with a letter, everything appears as a branch beneath what is known as the root file system.

If you log in to the Pi and type ls /, you’ll see various directories displayed (see Figure shown below). Some of these are areas of the SD card for storing files, while others are virtual directories for accessing different portions of the operating system or hardware.
Directory listing for Pi's root file system

The directories visible on the default Raspbian distribution are as follows:

■ boot—This contains the Linux kernel and other packages needed to start the Pi.
■ bin—Operating system-related binary files, such as those required to run the GUI, are stored here.
■ dev—This is a virtual directory, which doesn’t actually exist on the SD card. All the devices connected to the system—including storage devices and the sound card—can be accessed from here.
■ etc—This stores miscellaneous configuration files, including the list of users and their encrypted passwords.
■ home—All users get a subdirectory beneath this directory to store all their personal files.
■ lib—This is a storage space for libraries, which are shared bits of code required by numerous different applications.
■ lost+found—This is a special directory where file fragments are stored if the system crashes.
■ media—This is a special directory for removable storage devices, such as USB memory sticks or external CD drives.
■ mnt—This folder is used to manually mount storage devices, such as external hard drives.
■ opt—This stores optional software that is not part of the operating system. If you install new software to your Pi, it will usually go here or in usr.
■ proc—This is another virtual directory, containing information about running programs, which are known in Linux as processes.
■ run—A special directory used by various daemons, processes which run in the background.
■ root—Although most user’s files are kept in a subdirectory of home, the root (superuser) account’s files are kept here.
■ sbin—This stores special binary files, primarily used by the root (superuser) account for system maintenance.
■ srv—A directory used to store data served by the operating system. This is empty in Raspbian.
■ sys—This is a virtual directory storing system information used by the Linux kernel.
■ tmp—Temporary files are stored here automatically.
■ usr—This directory provides storage for user-accessible programs.
■ var—This is a directory which programs use to store changing values or variables.

Physical Layout

Although the preceding list is how the file system appears to the Linux operating system, it’s not how it’s laid out on the SD card. For the default Raspbian distribution, as installed from the official image, the SD card is organised into two main sections, known as partitions because they split the device into different areas in much the same way as the chapters of a book help to organise its contents.

The first partition on the disk is a small (approximately 75MB) partition formatted as FAT32, the same partition format used by Microsoft Windows for removable drives. This is mounted, or made accessible, by Linux in the /boot directory and contains all the files required to configure the Raspberry Pi and to load Linux.

The second partition is far larger and formatted as EXT4, a native Linux file system designed for high-speed access and data safety. This partition contains the main chunk of the distribution. All the programs, the desktop, the users’ files, and any software that you install yourself are stored here. This takes up the bulk of the SD card.

Comments

Popular posts from this blog

8051 Simple Programs

Sum of 8-bit Numbers Stored in Memory Here  we will discuss about 8051 programs but we can't discuss about all of the 8051 instructions. For programming 8051 we should know about assembler directives as well as instruction set. Click  here to download Atmel c51 user guide that will discuss about 8051(c51 family microcontroller) instruction set, assembler directives, c51 cross assembler from Atmel.  Program ORG 00H MOV R0,#50H   ; get memory location in memory pointer R0 MOV R1,#51H   ; get memory location on memory pointer register R1 MOV A,@R0       ; get content of memory location 50H to accumulator ADD A,@R1        ; add content of A with content of memory location 51H and store result in A MOV R0,#52H    ; get 52H to memory pointer R0 MOV@R0,A         ; copy content of A to memory location 52H END Add 16-bit Numbers ...

Introduction to 8051 embedded C

For 8051 we need to include the file reg51.h. This file contains the all the definitions of 8051 registers. With this information C compiler produces hex file that can be downloaded into the ROM of the microcontroller. It is important to note that the size of the hex file produced by the assembly language is much larger than the hex file produced by C compiler. Apart from this fact, there is many reasons for writing programs in C instead of assembly: ●It is much easier and less time consuming to write programs in C assembly. ●C is more flexible; it is easier to modify and update. ●Programming in C allows to use code available in function libraries. ●Program written inC for one microcontroller is portable to other microcontrollers with little or no modifications. Data Types in 8051 Embedded C The table shown below lists the data types that are available in typical C51 compiler. The gives information about the size of the data variable and it's value range. Data type ...

Frequency of Oscillation of RC Phase Shift Oscillator

Derivation of Frequency of Oscillation We have to find out the transfer function of RC feedback network. Feedback Circuit of RC Phase Shift Oscillator Applying KVL to various loops on the figure, we get, $$I_1 \left(R+\frac{1}{j \omega C }\right) -I_2R=V_i \text{ ....(1)}$$ $$-I_1R+I_2\left (2R+\frac {1}{j\omega C}\right)-I_3R=0\text{ ... (2)}$$ $$0-I_2R+I_3\left(2R+ \frac{1}{j\omega C}\right)=0\text{ ...(3)}$$ Replacing \(j\omega\) with \(s\) and writing equations in the matrix form, $$\begin{bmatrix}R+\frac{1}{sC} & -R & 0 \\-R & 2R+\frac{1}{sC} & -R \\0 & -R & 2R+\frac{1}{2sC} \end{bmatrix}\begin{bmatrix}I_1\\I_2\\I_3\end{bmatrix}=\begin{bmatrix}V_i\\0\\0\end{bmatrix}$$ Using Cramer's rule to find out \(I_3\), $$\text{Let, }D=\begin{bmatrix}R+\frac{1}{sC} & -R & 0 \\-R & 2R+\frac{1}{sC} & -R \\0 & -R & 2R+\frac{1}{2sC} \end{bmatrix}$$ \(|D|=\begin{vmatrix}R+\frac{1}{sC} & -R & 0 \\-R & 2R+\frac{1}{...