Saturday, 28 November 2020

What is Linux System Administration?

LPI Exam Prep, LPI Learning, LPI Tutorial and Material, LPI Study Material, LPI Certification

A Linux System Administrator takes care of computers running on the Linux operating systems. The professional will handle the support infrastructure, operating systems, virtual platforms, and applications. The administrator is responsible for the integrity and security of the servers and computer systems by following established security protocols and practices.

These professionals work in collaboration with the computer system engineer to install the system. The Linux administrator ensures the systems are updated with changing technologies. They are in charge of the installation of new software, granting permissions, and training users for the applications.

The Linux administrator has an active role in patching, compiling, securing, and troubleshooting Linux servers in a heterogeneous environment. The professional performs system updates and server configurations. They are responsible for implementing changes in multiple environments from development to production. The professional may also develop scripts with various languages, such as Bash, Python, and PHP.

Linux is an operating system or a kernel created by Linus Torvalds with other contributors. It was first released on September 17, 1991. The main advantage of Linux is that it is distributed under an open-source license means programmers can use the Linux Kernel to design their own custom operating systems.

LPI Exam Prep, LPI Learning, LPI Tutorial and Material, LPI Study Material, LPI Certification

Some of the most popular operating systems that use Linux as kernel are Debian, Knoppix, Ubuntu, and Fedora. Nevertheless, the list does not end here as there are thousands of operating systems based on Linux which offer a variety of functions to the users.

Introduction to Linux System Administration: Linux is a major strength in computing technology. Most of the webserver, mobile phones, personal computers, supercomputers, and cloud-servers are powered by Linux. The job of a Linux systems administrator is to manage the operations of a computer system like maintain, enhance, create user account/report, taking backups using Linux tools and command-line interface tools. Most computing devices are powered by Linux because of its high stability, high security, and open-source environment. There are some of the things that a Linux system administrator should know and understand:

◉ Linux File Systems
◉ File System Hierarchy
◉ Managing Root/super User
◉ Basic Bash Command
◉ Handling File, Directories and Users

Duties of a Linux Administrator: System Administration has become a solid criterion for an organization and institute that requires a solid IT foundation. Hence, the need for efficient Linux administrators is the requirement of the time. The job profile might change from each organization as there may be added responsibilities and duties to the role. Below are some duties of a Linux Administrator:

◉ Maintain all internet requests inclusive to DNS, RADIUS, Apache, MySQL, PHP.

◉ Taking regular back up of data, create new stored procedures and listing back-up is one of the duties.

◉ Analyzing all error logs and fixing along with providing excellent customer support for Webhosting, ISP and LAN Customers on troubleshooting increased support troubles.

◉ Communicating with the staff, vendors, and customers in a cultivated, professional manner at all times has to be one of his characteristics.

◉ Enhance, maintain and creating the tools for the Linux environment and its users.

◉ Detecting and solving the service problems ranging from disaster recovery to login problems.

◉ Installing the necessary systems and security tools. Working with the Data Network Engineer and other personnel/departments to analyze hardware requirements and makes acquiring recommendations.

◉ Troubleshoot, when the problem occurs in the server.

Steps to Start the Career as Linux System Admin:

◉ Install and learn to use Linux environment

◉ Get Certified in Linux administration

◉ Learn to do Documentation

◉ Joining up with a local Linux Users Group or Community for Support and Help

In short, the main role of the Linux Systems Administrator is to manage the operations like install, observe the software and hardware systems and taking backup. And also have a good ability to describe an In-depth understanding of technical knowledge. Even freshman-level Professionals has great possibilities for the position of System Administrator with the yearly median salary is around INR 3 Lacs, salary increase with an increase in job experience. To get the experience you need to check for the latest skills and learning in the Linux community.

Thursday, 26 November 2020

Linux Virtualization : Linux Containers (lxc)

Introduction to virtualization

Operating-system-level virtualization is a server virtualization method in which the kernel of an operating system allows the existence of multiple isolated user-space instances, instead of just one. Such instances, which are sometimes called containers, software containers, virtualization engines (VEs) or jails (FreeBSD jail or chroot jail), may look and feel like a real server from the point of view of its owners and users.

Read More: LPI Linux Essentials

The above definition sums up the broad idea about containers, but to be more accurate, the traditional Virtual Machines used something called hypervisor that runs on top of kernel. This hypervisor provides virtualization to the applications that run on it by monitoring their resource usage and access patterns. This causes a lot of overhead resulting in unnecessary loss of performance. On the other hand, Operating-system-level virtualization works differently. It uses namespaces and cgroups to restrict application’s capabilities including the use of resources. This is a feature provided by the linux kernel. This has almost no overhead.

Linux Virtualization, Linux Containers (lxc), LPI Study Material, LPI Tutorial and Material, LPI Exam Prep, LPI Certification, LPI Guides

This method is so effective that Docker is using these containers internally to provide that isolated environment which is very useful for deploying multiple integrated systems. They are even bound towards creating their own containers library. Google have their own services running on containers on shared hardware.

Installation:


To install lxc in Ubuntu,

$ sudo apt-get install lxc lxctl lxc-templates

This package installs of LXC’s requirements, some templates and also sets up the network structure for the containers.

Run lxc-checkconfig to check if the kernel configuration is ready.

$ sudo lxc-checkconfig
    Kernel configuration not found at /proc/config.gz; searching...
    Kernel configuration found at /boot/config-4.4.0-24-generic
    --- Namespaces ---
    Namespaces: enabled
    Utsname namespace: enabled
    Ipc namespace: enabled
    Pid namespace: enabled
    User namespace: enabled
    Network namespace: enabled
    Multiple /dev/pts instances: enabled

    --- Control groups ---
    Cgroup: enabled
    Cgroup clone_children flag: enabled
    Cgroup device: enabled
    Cgroup sched: enabled
    Cgroup cpu account: enabled
    Cgroup memory controller: enabled
    Cgroup cpuset: enabled

    --- Misc ---
    Veth pair device: enabled
    Macvlan: enabled
    Vlan: enabled
    Bridges: enabled
    Advanced netfilter: enabled
    CONFIG_NF_NAT_IPV4: enabled
    CONFIG_NF_NAT_IPV6: enabled
    CONFIG_IP_NF_TARGET_MASQUERADE: enabled
    CONFIG_IP6_NF_TARGET_MASQUERADE: enabled
    CONFIG_NETFILTER_XT_TARGET_CHECKSUM: enabled
    FUSE (for use with lxcfs): enabled

    --- Checkpoint/Restore ---
    checkpoint restore: enabled
    CONFIG_FHANDLE: enabled
    CONFIG_EVENTFD: enabled
    CONFIG_EPOLL: enabled
    CONFIG_UNIX_DIAG: enabled
    CONFIG_INET_DIAG: enabled
    CONFIG_PACKET_DIAG: enabled
    CONFIG_NETLINK_DIAG: enabled
    File capabilities: enabled

Note : Before booting a new kernel, you can check its configuration usage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig

You should also see the output something similar to the above.

lxc provides a lot of ready templates, which are really helpful for fast deployment.

$ ls -l /usr/share/lxc/templates/
    total 404
    -rwxr-xr-x 1 root root 12973 May 18 14:48 lxc-alpine
    -rwxr-xr-x 1 root root 13713 May 18 14:48 lxc-altlinux
    -rwxr-xr-x 1 root root 11090 May 18 14:48 lxc-archlinux
    -rwxr-xr-x 1 root root 12159 May 18 14:48 lxc-busybox
    -rwxr-xr-x 1 root root 29503 May 18 14:48 lxc-centos
    -rwxr-xr-x 1 root root 10374 May 18 14:48 lxc-cirros
    -rwxr-xr-x 1 root root 19732 May 18 14:48 lxc-debian
    -rwxr-xr-x 1 root root 17890 May 18 14:48 lxc-download
    -rwxr-xr-x 1 root root 49600 May 18 14:48 lxc-fedora
    -rwxr-xr-x 1 root root 28384 May 18 14:48 lxc-gentoo
    -rwxr-xr-x 1 root root 13868 May 18 14:48 lxc-openmandriva
    -rwxr-xr-x 1 root root 15932 May 18 14:48 lxc-opensuse
    -rwxr-xr-x 1 root root 41720 May 18 14:48 lxc-oracle
    -rwxr-xr-x 1 root root 11205 May 18 14:48 lxc-plamo
    -rwxr-xr-x 1 root root 19250 May 18 14:48 lxc-slackware
    -rwxr-xr-x 1 root root 26862 May 18 14:48 lxc-sparclinux
    -rwxr-xr-x 1 root root  6862 May 18 14:48 lxc-sshd
    -rwxr-xr-x 1 root root 25602 May 18 14:48 lxc-ubuntu
    -rwxr-xr-x 1 root root 11439 May 18 14:48 lxc-ubuntu-cloud

We’ll start by creating a new container with name “my_container” with “ubuntu” template.
This will take some time and finish creating a container for you. Yes! its that simple.
Once its completed, the last few lines shows the password for the root user of the container. It would look something similar to this,

$ sudo lxc-create -n my_container -t ubuntu
    .....
    .....
    ##
    # The default user is 'ubuntu' with password 'ubuntu'!
    # Use the 'sudo' command to run tasks as root in the container.
    ##

We can check the status of container using lxc-ls. This will show the container to be in stopped state.

$ sudo lxc-ls --fancy
    NAME            STATE    IPV4  IPV6  AUTOSTART
    ----------------------------------------------
    my_container    STOPPED  -     -     NO

Now to start the container run lxc-start. The -d argument creates it a daemon.

$ sudo lxc-start -n my_container -d

Check the status of container using lxc-ls to verify its running. We can access the console using lxc-console. Use the credentials we received above to get the console access.

 $ sudo lxc-console -n my_container

After logging in, run the following command on the container,

$ top

And on the host-pc run the following command to see the list of running processes.

$ ps auxf

and somewhere you’ll find a process tree that looks similar to this,

Linux Virtualization, Linux Containers (lxc), LPI Study Material, LPI Tutorial and Material, LPI Exam Prep, LPI Certification, LPI Guides

It would be surprising, but, all the process on the container are just simple process on the host pc. The important part is that all are isolated and monitored by kernel. Hence you can think of these as simple processes on the host PC and you can even kill them(only if you have sufficient privileges)

You can exit the console and return to the host by typing Ctrl-A followed by Q.

To get more info about the running container use,

 $ sudo lxc-info -n my_container

You can access the root file-system of this container directly from the host machine by accessing. You will need root permission to do so.

    $ sudo su
    $ cd /var/lib/lxc/my_container/rootfs

That’s it. Now this is like a brand new operating system. You can run any service on this container.

Think of containers as separate operating systems, where you can run anything you want. The only thing that makes is special is that all container runs on the same hardware. So, practically, companies/institutions buy a heavy shared machine then deploy containers with resource limits according to the multiple services they want. This makes is scalable and easier to manage.

To stop the container run,

    $ sudo lxc-stop -n my_container

To delete the container use,

    $ sudo lxc-destroy -n my_container

NOTE: lxc provides a wrapper and easy to use API to use the kernel features. It is not equivalent to containers in any sense.

Tuesday, 24 November 2020

Introduction to Kali Linux

LPI Tutorial and Materials, LPI Certification, LPI Learning, LPI Study Materials, LPI Guides

Operating System is the main system software which is responsible for the flawless working of the machine. Some Operating Systems are designed for some specific purposes. Though we could use them for anything we want to, but they have some special tools or services available feasibly to its users which makes it a good OS for the specific purpose. Like we generally prefer Windows in case of gaming as most of the games are available for windows itself. Likewise, we prefer mac OS for designing related purposes as most of the designing software is easily available for mac and can be used flawlessly. In the same way when we have an OS for Network Security, Digital Forensics, Penetration testing, or Ethical Hacking named Kali Linux.

Read More: LPI Linux Essentials

Kali Linux is a Debian-derived Linux distribution that is maintained by Offensive Security. It was developed by Mati Aharoni and Devon Kearns. Kali Linux is a specially designed OS for network analysts, Penetration testers, or in simple words, it is for those who work under the umbrella of cybersecurity and analysis. The official website of Kali Linux is Kali.org. It gained its popularity when it was practically used in Mr. Robot Series. It was not designed for general purposes, it is supposed to be used by professionals or by those who know how to operate Linux/Kali. To know how to install Kali Linux check its official documentation.

Advantages:

◉ It has 600+ Penetration testing and network security tools pre-installed.

◉ It is completely free and open source. So you can use it for free and even contribute for its development.

◉ It supports many laguages.

◉ Great for those who are intermediate in linux and have their hands on Linux commands.

◉ Could be easily used with Rasberry Pi.

Disadvanatges:

◉ It is not recommended for those who are new to linux and want to learn linux.(As it is Penetration Oriented)

◉ It is a bit slower.

◉ Some software may malfunction.

Kali Linux is to be used by those who are professional penetration testers, cybersecurity experts, ethical hackers, or those who know how to operate it. In simple words, if you know how to use Linux and its terminal commands, architecture, system, and file management then you are good to go with Kali Linux. And if you are not, then we will recommend you first start with ubuntu distribution and get your hands on Linux and after sufficient practice, you could give Kali Linux a try. This will not only save your time of searching on the internet but also will make you use it with ease. However, if you’re a professional penetration tester or studying penetration testing, there’s no better toolkit than Kali Linux.

Why Kali Linux?

LPI Tutorial and Materials, LPI Certification, LPI Learning, LPI Study Materials, LPI Guides
If you are interested in penetration testing or cybersecurity stuff you need some specific tools to perform some tasks which come pre-installed and settled up in Kali Linux so you may directly use them without doing any configuration. Or in case if one wants to check the vulnerabilities on a website or want to know security-related bugs in any application then it is great to go with Kali Linux.

Many people think that Kali is a tool for hacking or cracking social accounts or web servers. This is one of the biggest myths about Kali Linux. Kali Linux is just another Debian distribution with a bunch of networking and security tools. It is a weapon to train or defend yourself not to attack anyone. Kali Linux was designed mainly for professionals. It is for those who want to get their hands in Penetration Testing, Cyber Security, or Ethical Hacking. It is a powerful tool and in case, not used properly, it may lead to losses even.

Thursday, 19 November 2020

Difference Between Arch Linux and Kali Linux

Arch Linux is an open-source Linux based Operating System that is freely available for use. It belongs to the Pacman based Linux family. It is a light weighted OS for daily use and could even be used by professionals. It was first released in March 2002. It is a beginner-friendly Linux Operating System.

Arch Linux, Kali Linux, Linux Exam Prep, LPI Tutorial and Material, LPI Exam Prep

Kali Linux is a Linux based open source Operating System which is freely available for use. It belongs to the Debian family of Linux. It was developed by “Offensive Security”. It was first released in March 2013 with the aim to be the replacement of the BackTrackOS. Kali comes packed with 100+ of penetration testing, security research, digital forensics, reverse engineering, and ethical hacking tools.

Difference between Arch Linux and Kali Linux


ARCH LINUX KALI LINUX 
Developed by Levente Polyak. Developed by Offensive Security.
Arch was initially released in March 2002.   kali was initially released in March 2013. 
Arch is light weight OS and used for daily purposes.   Kali is used by security researchers or ethical hackers for security purposes
The discussion forum for Arch is bbs.archlinux.org.   The discussion forum for Kali Linux is forums.kali.org. 
Latest Arch consists of the Pantheon environment by default, though it allows you to change the same.   Latest Kali consists of the xfce environment by default, though it allows you to change the same.
Arch doesn’t comes packed with hacking and penetration testing tools.   Kali comes packed with hacking and penetration testing tools. 
Arch comes with a user friendly Interface   Kali comes with a less user friendly Interface as compared to Arch. 
Arch is a good option for beginners to Linux.   Kali Linux is a good option for those who are intermediate in Linux. 

Tuesday, 17 November 2020

tr command in Unix/Linux with examples

LPI Tutorial and Material, LPI Guides, LPI Certifications, LPI Learning

The tr command in UNIX is a command line utility for translating or deleting characters. It supports a range of transformations including uppercase to lowercase, squeezing repeating characters, deleting specific characters and basic find and replace. It can be used with UNIX pipes to support more complex translation. tr stands for translate.

Syntax :


$ tr [OPTION] SET1 [SET2]

Options


-c : complements the set of characters in string.i.e., operations apply to characters not in the given set
-d : delete characters in the first set from the output.
-s : replaces repeated characters listed in the set1 with single occurrence
-t : truncates set1

Sample Commands


1. How to convert lower case to upper case


To convert from lower case to upper case the predefined sets in tr can be used.

$cat lpifile

Output:

WELCOME TO
LPICentral

$cat lpifile | tr “[a-z]” “[A-Z]”

Output:

WELCOME TO
LPICentral

or

$cat lpifile | tr “[:lower:]” “[:upper:]”

Output:

WELCOME TO
LPICENTRAL

2. How to translate white-space to tabs


The following command will translate all the white-space to tabs

$ echo "Welcome To LPICentral" | tr [:space:] '\t'

Output:

Welcome    To    LPICentral  

3. How to translate braces into parenthesis


You can also translate from and to a file. In this example we will translate braces in a file with parenthesis.

$cat lpifile

Output:

 {WELCOME TO}
LPICentral

$ tr '{}' '()'   newfile.txt

Output:

(WELCOME TO)
LPICentral

The above command will read each character from “lpifile.txt”, translate if it is a brace, and write the output in “newfile.txt”.

4. How to use squeeze repetition of characters using -s


To squeeze repeat occurrences of characters specified in a set use the -s option. This removes repeated instances of a character.

OR we can say that,you can convert multiple continuous spaces with a single space

$ echo "Welcome    To    LPICentral" | tr -s [:space:] ' '

Output:

Welcome To LPICentral

5. How to delete specified characters using -d option


LPI Tutorial and Material, LPI Guides, LPI Certifications, LPI Learning
To delete specific characters use the -d option.This option deletes characters in the first set specified.

$ echo "Welcome To LPICentral" | tr -d 'w'

Output:

elcome To LPICentral

6. To remove all the digits from the string, use


$ echo "my ID is 73535" | tr -d [:digit:]

Output:

my ID is

7. How to complement the sets using -c option


You can complement the SET1 using -c option. For example, to remove all characters except digits, you can use the following.

$ echo "my ID is 73535" | tr -cd [:digit:]

Output:

73535

Saturday, 14 November 2020

anvil - Unix, Linux Command

LPI Study Material, LPI Exam Prep, LPI Tutorial and Material, LPI Certification, LPI Guides

NAME

anvil - Postfix session count and request rate control

SYNOPSIS

anvil [generic Postfix daemon options]

DESCRIPTION

The Postfix anvil(8) server maintains statistics about client connection counts or client request rates. This information can be used to defend against clients that hammer a server with either too many simultaneous sessions, or with too many successive requests within a configurable time interval. This server is designed to run under control by the Postfix master(8) server.

In the following text, ident specifies a (service, client) combination. The exact syntax of that information is application-dependent; the anvil(8) server does not care.

CONNECTION COUNT/RATE CONTROL

To register a new connection send the following request to the anvil(8) server:

request=connect

ident=string

The anvil(8) server answers with the number of simultaneous connections and the number of connections per unit time for the (service, client) combination specified with ident:

status=0

count=number

rate=number

To register a disconnect event send the following request to the anvil(8) server:

request=disconnect

ident=string

The anvil(8) server replies with:

   status=0

MESSAGE RATE CONTROL

To register a message delivery request send the following request to the anvil(8) server:

request=message

ident=string

The anvil(8) server answers with the number of message delivery requests per unit time for the (service, client) combination specified with ident:

status=0

rate=number

RECIPIENT RATE CONTROL

To register a recipient request send the following request to the anvil(8) server:

request=recipient

ident=string

The anvil(8) server answers with the number of recipient addresses per unit time for the (service, client) combination specified with ident:

status=0

rate=number

TLS SESSION NEGOTIATION RATE CONTROL

LPI Study Material, LPI Exam Prep, LPI Tutorial and Material, LPI Certification, LPI Guides
The features described in this section are available with Postfix 2.3 and later.

To register a request for a new (i.e. not cached) TLS session send the following request to the anvil(8) server:

request=newtls

ident=string

The anvil(8) server answers with the number of new TLS session requests per unit time for the (service, client) combination specified with ident:

status=0

rate=number

To retrieve new TLS session request rate information without updating the counter information, send:

request=newtls_report

ident=string

The anvil(8) server answers with the number of new TLS session requests per unit time for the (service, client) combination specified with ident:

status=0

rate=number

SECURITY

The anvil(8) server does not talk to the network or to local users, and can run chrooted at fixed low privilege.

The anvil(8) server maintains an in-memory table with information about recent clients requests. No persistent state is kept because standard system library routines are not sufficiently robust for update-intensive applications.

Although the in-memory state is kept only temporarily, this may require a lot of memory on systems that handle connections from many remote clients. To reduce memory usage, reduce the time unit over which state is kept.