Linux Operating System

What Is Linux?

From smartphones to cars, supercomputers and home appliances, home desktops to enterprise servers, the Linux operating system is everywhere. Linux has been around since the mid–1990s and has since reached a user–base that spans the globe. Linux is actually everywhere : It’s in your phones, your thermostats, in your cars, refrigerators, Roku devices, and televisions.

It also runs most of the Internet, all of the world’s top 500 supercomputers, and the world’s stock exchanges. But besides being the platform of choice to run desktops, servers, and embedded systems across the globe, Linux is one of the most reliable, secure and worry–free operating systems available. Just like Windows, iOS, and Mac OS, Linux is an operating system.

In fact, one of the most popular platforms on the planet, Android, is powered by the Linux operating system. An operating system is software that manages all of the hardware resources associated with your desktop or laptop. To put it simply, the operating system manages the communication between your software and your hardware. Without the operating system (OS), the software would– t function.

The Linux operating system comprises several different pieces :

BootloaderThe software that manages the boot process of your
computer. For most users, this will simply be a splash
screen that pops up and eventually goes away to boot
into the operating system.
KernelThis is the one piece of the whole that is actually
called ? Linux ? The kernel is the core of the system and
manages the CPU, memory, and peripheral devices. The
kernel is the lowest level of the OS.
Init systemThis is a sub–system that bootstraps the user space and
is charged with controlling daemons.
DaemonsThese are background services (printing, sound,
scheduling, etc.) that either start up during boot or after
you log into the desktop.
Graphical serverThis is the sub–system that displays the graphics on your
monitor. It is commonly referred to as the X server or
just X.
Desktop
environment
This is the piece that the users actually interact with.
There are many desktop environments to choose from
(GNOME, Cinnamon, Mate, Pantheon, Enlightenment,
KDE, Xfce, etc.). Each desktop environment includes
built–in applications (such as file managers, configuration
tools, web browsers, and games).
ApplicationsDesktop environments do not offer the full array of apps.
Just like Windows and macOS, Linux offers thousands
upon thousands of high–quality software titles that can
be easily found and installed. Most modern Linux
distributions include App Store–like tools that centralize
and simplify application installation. For example, Ubuntu
Linux has the Ubuntu Software Center which allows you
to quickly search among the thousands of apps and
install them from one centralized location.

Linux Distribution and Installation

Because of the Open–Source nature of the Linux Kernel, which allows anyone to modify or enhance the base kernel (Operating System) with other software, Linux is available in a wide variety of distributions. A linux distribution is a collection of software packages, utilities, and tools and is based on the version of a Linux kernel.

Some distributions can be created with a specific purpose in mind e.g to set–up a firewall or for educational purposes etc. but there are also general–purpose distributions, meaning that they come with a variety of software packages, tools and applications that can be installed by the end user resulting in flexibility. Each distribution comes with its own characteristics and special tools, created by the distribution company to increase the value of their version of Linux.

Most of these distributions are obtained for free but many companies also sell commercial distributions. Often mention will be made for distinct changes with other key Linux distributions. It is also important to note that this manual does not seek to promote any particular distribution but will seek to expound on implementations that cut across any Linux distribution.

This implies that the concepts described in this manual cut across majority of the Linux distributions out there. For a comprehensive listing of Linux distributions see http://www.distrowatch.com/

Popular Linux distributions include

  • Linux mint
  • Manjaro
  • Debian
  • Ubuntu
  • Antergos
  • Solus
  • Fedora
  • Elementary os
  • Opens use

There are many Linux distributions out there, most of them with very elaborate installation instructions. The following are some of the key Linux distributions and where you can find their download and installation instructions.

Distribution NameDownload and Installation Instructions Site
SuSE Linux Enterprise
Server
https://www.suse.com/download/
Ubuntuhttps://ubuntu.com/download/desktop
Fedorahttps://getfedora.org/en/workstation/download/
CentOShttps://www.centos.org/download/

Linux offers one of the easiest installations of all operating systems. In fact, most versions of Linux offer what is called a Live distribution ? which means you run the operating system from either a CD/DVD or USB flash drive without making any changes to your hard drive. You get the full functionality without having to commit to the installation. Once you’ve tried it out, and decided you wanted to use it, you simply double–click the “Install” icon and walk through the simple installation wizard.

Typically, the installation wizards walk you through the process with the following steps (We’ll illustrate the installation of Ubuntu Linux):

Preparation

Make sure your machine meets the requirements for installation. This also may ask you if you want to install third-party software (such as plugins for MP3 playback, video codecs, and more).

Wireless setup (if necessary)

If you are using a laptop (or machine with wireless), you’ll need to connect to the network, in order to download third-party software and updates.

Hard drive allocation

This step allows you to select how you want the operating system to be installed. Are you going to install Linux alongside another operating system (called “dual booting”), use the entire hard drive, upgrade an existing Linux installation, or install over an existing version of Linux.

Location

Select your location from the map.

Keyboard layout

Select the keyboard for your system.

User setup

Set up your username and password.

That’s it. Once the system has completed the installation, reboot and you’re ready to go. For a more in–depth guide to installing Linux, take a look at “How to Install and Try Linux the Absolutely Easiest and Safest Way” or download the Linux Foundation’s PDF guide for Linux installation.


The Linux Command line Structure

A Unix shell is a command–line interpreter and script host that provides a traditional user interface for the Unix operating system and for Unix like systems. Users direct the operation of the computer by entering command input as text for a command line interpreter to execute or by creating text scripts of one or more such commands.

A basic way to interact with a computer system is to use the command line. The shell interprets the instructions typed in at the keyboard.

That is the shell is the interface between a human user and the Linux Operating System. The shell prompt (ending with $ or # for user root) indicates that it is ready for user input. You can access the Linux Shell by Pressing Ctrl+Alt+F1 or F2 or F3 or F4 or F5 or F6.

These commands open up a shell terminal where you can be able to enter any Linux command. You may also access the terminal on the windows interface. This terminal runs a shell which is a programming environment which can be used to perform automated tasks. Shell programs are called scripts. The most common shells are summarized in the table below:

Most Common shells

The Bourne shell/bin/sh
The Bourne again shell/bin/bash
The Korn shell/bin/ksh
The C shell/bin/csh
Tom’s C shel/bin/tcsh

Since the bash shell is one of the most widely used shells we shall concentrate on the use of this shell. This Module shall focus on the use of various Linux commands to perform basic file management commands in the Linux System. In this Module you will be :

Introduced to the Linux Command Structure (Variables and command options), the Interactive Shell, metacharacters and quotes plus perform the following :

  • Carry out Basic File Management Operations including creating, Deleting, Editing, Renaming, Copying etc file contents and folders.
  • Moving around the file system;
  • Find files and directories; and.
  • Work with hard and soft links.

Shell commands are often of the form command [options] {arguments}.

To print text to the screen the bash shell will use the echo $echo “this is a short line”

The shell interprets the first “word” of any string given on the command line as a command. If the string is a full or relative path to an executable then the executable is started. If the first word has no “/” characters, then the shell will scan directories defined in the PATH variable and attempt to run the first command matching the string.

For example if the PATH variable only contains the directories /bin and /usr/bin then a command stored in /etc will not be found therefore, the full path needs to be specifies. An alternative to typing the full path to an executable is to use a relative path. For example, if the user is in the directory where a particular program is stored then one can type:

$ ./program name>


Linux File Management

Moving around the File System

A directory or a file can be accessed by giving its full path name, starting at the root (/) or its relative path, starting from the current directory.

Absolute path

independent of the user’s current directory starts with /.

Relative path

depends on where the user is doesn’t start with / As in any structured file system there are a number of utilities that can help you navigate through the system. The next two commands are built–in commands.

PWD

Gives your actual position as an absolute path.

CD

The ‘change directory’ command.

Finding Files and Directories

We will describe the find, which, where is and locate utilities.

Find Syntax:

Syntax: find < Directories><Criteria>exe [-e<camondo> {} \;]

The DIRECTORY argument tells find where to start searching and CRITERIA can be the name of a file or directory we are looking for. Examples : find /usr/X11R6/bin–name ¨x*¨.
find /–user 502

Matching lines are listed to standard out. This output can be acted upon. For example, delete the file, or change the permission. The find tool has the build–in option –exec which allows you to do that. For example, remove all files belonging to user 502 :

locate

Syntax locate Example

locate X11R

When using locate all files and directories that match the expression are listed.

which
Syntax : which string

This tool will return the full path to the file called string by scanning the directories defined in the user’s PATH variable only. As a result which is only used to find commands.

Where is

Syntax : where is string

This tool will return the full path to source or binaries as well as documentation files matching string by scanning the PATH variable as well as a number of well known locations.

ls Syntax : ls <option>

Most common options for ls

-I show inode

-h print human readable sizes

-n list UIDs and GIDs

-p append descriptor (/=@) to list

-R recursively display content of directories

-S sort by file size

-t sort by modification time (similar to–c)

Handling Directories Making a directory with mkdir

When making a directory you can set the permission mode with the –m option. Another useful option is–p which creates all sub directories automatically as needed.

Example :

mkdir –p docs/programs/versions

Removing directories

To remove a directory, use either rmdir or rm–r. If you are root you may have to specify–f to force the deletion of all files.

Notice : rm –rf /dir1/* removes all files and sub directories leaving dir1 empty

rm –rf /dir1/ removes all files and sub directories including dir1

Using cp and mv

cp

Syntax : cp [options] file1 file
2 cp [options] files directory

It is important to notice that cp file1 file2 makes a new copy of file1 and leaves file1 unchanged.

You can also copy several files to a directory, using a list or wildcards. The following table lists the most used options.

Most common options for cp

-d do not follow symbolic link (when used with ?R)

-f Force

-I interactive, prompt before overwrite

-p preserve file attributes

-R recursively copy directories

Note : cp –r /dir/* /dir2/ will copy all files and sub directories omitting my dir

cp –r /mydir/ /dir2/ will copy all files and sub directories including my dir

mv

Syntax : mv [options] oldname newname

mv [options] source destination

mv [options] source directory

The mv command can both move and rename files and directories. If old name is a file and new name is a directory then the file old name is moved to that directory. If the source and destination are on the same filesystem, then the file isn’t copied but the in-ode information is updated to specify the new location. Most common options are–f forces overwrite and–i query interactively.

Touch

Another way of creating or modifying a file is to use touch. Syntax : touch {options} file(s) If file doesn’t exist it is created. You can also change the access time of a file using the–a option,–m changes the modification time and–r is used to apply the time attributes of another file.

Example :

touch file1.txt file2.txt creates new files

touch myfile–r /etc/lilo.conf myfile gets the time attributes of lilo.conf

To create a file called –errors use the – option:
touch — -errors
dd

his command copies a file with a changeable I/O block size. It can also be used to perform conversions (similar to tr). Main options are if= (input file) of= (output file) conv= (conversion) The conversion switch can be : lcase ucase ascii.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.