Thursday 28 January 2021

Unix Vs. Linux: What’s the Difference Between Unix and Linux?

What is UNIX?

The UNIX OS was born in the late 1960s. AT&T Bell Labs released an operating system called Unix written in C, which allows quicker modification, acceptance, and portability.

It began as a one-man project under the leadership of Ken Thompson of Bell Labs. It went on to become most widely used operating systems. Unix is a proprietary operating system.

The Unix OS works on CLI (Command Line Interface), but recently, there have been developments for GUI on Unix systems. Unix is an OS which is popular in companies, universities big enterprises, etc.

What is LINUX?

Linux is an operating system built by Linus Torvalds at the University of Helsinki in 1991. The name "Linux" comes from the Linux kernel. It is the software on a computer which enables applications and the users to access the devices on the computer to perform some specific function.

The Linux OS relays instructions from an application from the computer's processor and sends the results back to the application via the Linux OS. It can be installed on a different type of computers mobile phones, tablets video game consoles, etc.

The development of Linux is one of the most prominent examples of free and open source software collaboration. Today many companies and similar numbers of individuals have released their own version of OS based on the Linux Kernel.

KEY DIFFERENCE

◉ Comparing Unix vs Linux, Linux source code is available to the general public whereas, in Unix, the source code is proprietary.

◉ UNIX OS was created in the late 1960s at AT&T Bell Labs whereas Linux is an operating system built by Linus Torvalds at the University of Helsinki in 1991.

◉ The main difference between Linux and Unix is Linux is a clone of Unix

◉ When we compare Unix to Linux, Linux default shell is BASH while the Unix shell is Bourne Shell.

◉ One key Unix and Linux difference is that Linux threat detection and solution are very fast while Unix users require longer wait times to get the proper bug fixing patch.

◉ Important versions of Linux are Redhat, Ubuntu, OpenSuse, Solaris, whereas important versions of Unix are HP-UX, AIS, BSD, etc.

Features of Unix OS

◉ When compare Unix to Linux, Unix is a Multi-user, multitasking operating system

◉ It can be used as the master control program in workstations and servers.

◉ Hundreds of commercial applications are available

◉ In its heydays, UNIX was rapidly adopted and became the standard OS in universities.

Features of Linux Operating System

◉ Support multitasking

◉ Programs consist of one or more processes, and each process have one or more threads

◉ It can easily co-exists along with other Operating systems.

◉ Comparing features of Linux and Unix, Linux can run multiple user programs

◉ Individual accounts are protected because of appropriate authorization

◉ When comparing Unix vs Linux, Linux is a replica of UNIX but does not use its code.

Difference between Unix and Linux

Now, we will see what is the difference between unix and linux:

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

Unix Vs Linux

Key Differences Linux  Unix 
Cost Linux is freely distributed, downloaded through magazines, Books, website, etc. There are paid versions also available for Linux. Different flavors of Unix have different pricing depending upon the type of vendor.
Development  Linux is Open Source, and thousands of programmer collaborate online and contribute to its development.  Unix systems have different versions. These versions are primarily developed by AT&T as well as other commercial vendors. 
User  Everyone. From home users to developers and computer enthusiasts alike.  The UNIX can be used in internet servers, workstations, and PCs. 
Text made interface  BASH is the Linux default shell. It offers support for multiple command interpreters.  Originally made to work in Bourne Shell. However, it is now compatible with many others software. 
GUI  Linux provides two GUIs,viz., KDE and Gnome. Though there are many alternatives such as Mate, LXDE, Xfce, etc.  Common Desktop Environment and also has Gnome. 
Viruses  Linux has had about 60-100 viruses listed to date which are currently not spreading.  There are between 80 to 120 viruses reported till date in Unix. 
Threat detection  Threat detection and solution is very fast because Linux is mainly community driven. So, if any Linux user posts any kind of threat, a team of qualified developers starts working to resolve this threat.  Unix users require longer wait time, to get the proper bug fixing patch. 
Architectures  Initially developed for Intel's x86 hardware processors. It is available for over twenty different types of CPU which also includes an ARM.  It is available on PA-RISC and Itanium machines. 
Usage  Linux OS can be installed on various types of devices like mobile, tablet computers.  The UNIX operating system is used for internet servers, workstations & PCs. 
Best feature  Kernel update without reboot  Feta ZFS - next generation filesystem DTrace - dynamic Kernel Tracing 
Versions Different Versions of Linux are Redhat, Ubuntu, OpenSuse, etc.  Different Versions of Unix are HP-UX, AIS, BSD, etc. 
Supported file type  The Filesystems supported by file type like xfs, nfs, cramfsm ext 1 to 4, ufs, devpts, NTFS.  The Filesystems supported by file types are zfs, hfx, GPS, xfs, vxfs. 
Portability  Linux is portable and is booted from a USB Stick  Unix is not portable 
Source Code   The source is available to the general public The source code is not available to anyone. 

Limitation of Linux


◉ For Linux vs Unix, There's no standard edition of Linux

◉ Linux has patchier support for drivers which may result in misfunctioning of the entire system.

◉ Linux is, for new users at least, not as easy to use as Windows.

◉ Many of the programs we are using for Windows will only run on Linux only with the help of a complicated emulator. For example. Microsoft Office.

◉ Linux is best suitable for a corporate user. It's much harder to introduce in a home setting.

Limitations of Unix


◉ The unfriendly, terse, inconsistent, and non-mnemonic user interface

◉ Comparing limitation of Linux vs Unix, Unix OS is designed for a slow computer system, so you can't expect fast performance.

◉ Shell interface can be treacherous because typing mistake can destroy files.

◉ Versions on various machines are slightly different, so it lacks consistency.

◉ One of the Unix and Linux difference is, Unix does not provide any assured hardware interrupt response time, so it does not support real time response time systems.

Linux Market share compared to other OS

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

Tuesday 26 January 2021

Pros of using Linux based Operating Systems for Programming

LPI Exam Prep, LPI Tutorial and Material, Linux Admin, LPI Preparation, LPI Career

The best thing about Linux is that it comes in-built with most of the compilers and interpreters, because of this there is no need for the user to download them. While on the other hand, Many other non-Linux Operating Systems don’t come with compilers or interpreters pre-installed. If the software that you require doesn’t have what you need then with just one line of the command

apt install <package-name>

OR 

pacman -S <package-name>

OR 

yum install <package-name>

Example:

apt install sublime-text

Benefits of Linux for programmers

Just because a developer needs to write code and sublime-text provides what is required for the developer. You will get what you need with just that line of command and isn’t this awesome, also this saves us a lot of time and effort as a lot of functions that we may perform in Linux with single command are not present in many other Operating Systems.

◉ Another reason why Linux is preferred by programmers is due to its versatility, power that comes with it, also speed, and security. Linux OS has arguably the biggest community and also welcomes all newcomers.

◉ Linux also comes with many flavors and programmers can decide which they want to get ahead with.

◉ It is Open Source and you may write your own commands and their functions the way you want them to work.

◉ You may even make changes to Linux Kernel in your local machine as that too is open source while many other Operating Systems don’t have their Kernels’ code Open Source.

There is a meme popular in the programming community

An Error Message prompts! (Like sublime-text is not installed)

Windows: Umm ok :/

OSX: Upgrade to newest version 

Linux: Here's a hint to solve 

do 'apt install sublime-text' before  launching sublime-text

It is much easier to solve any issue related to Linux with just one or two lines of code rather than going through some video tutorials. A problem in Linux can be solved with one or two commands.

◉ Being open-source we can have control over everything like for example all the codes are open to its users and this gives the power to the users to literally changes anything, being as robust as it is Linux is capable of running for some months without crashing, so no need to shut down.

◉ There are very popular programming tools like awk, grep which help in the daily life of programmers for being productive.

◉ Some important features that make Linux special are being able to run interpreted languages like Python, R, Ruby, and many more by just typing one word at any time, quickly connecting to repository Github’s or bitbuckets or even remote networks with SSH and SVN, file management, being able to write scripts to make all types of tasks in a more efficient and optimal fashion all from the terminal

LPI Exam Prep, LPI Tutorial and Material, Linux Admin, LPI Preparation, LPI Career

◉ The ability to changes your entire interface in Linux to look and feel like windows or OSX is ONE OF THE SMALL FEATURES that it provides, it also comes with tons of software packages available, quick and easy to download and install.

◉ Bash scripting is available to the users to use in-built for the users. You may by now get the idea of how much power does Linux holds.

◉ As a matter of assumption but the fact in my case Linux can give like 2x or even more times the performance in terms of programming and usage.

Saturday 23 January 2021

Virtualization In Cloud Computing and Types

Virtualization is a technique of how to separate a service from the underlying physical delivery of that service. It is the process of creating a virtual version of something like computer hardware. It was initially developed during the mainframe era. It involves using specialized software to create a virtual or software-created version of a computing resource rather than the actual version of the same resource. With the help of Virtualization, multiple operating systems and applications can run on same machine and its same hardware at the same time, increasing the utilization and flexibility of hardware.

Read More: LPIC-3 304: Virtualization and High Availability

In other words, one of the main cost effective, hardware reducing, and energy saving techniques used by cloud providers is virtualization. Virtualization allows to share a single physical instance of a resource or an application among multiple customers and organizations at one time. It does this by assigning a logical name to a physical storage and providing a pointer to that physical resource on demand. The term virtualization is often synonymous with hardware virtualization, which plays a fundamental role in efficiently delivering Infrastructure-as-a-Service (IaaS) solutions for cloud computing. Moreover, virtualization technologies provide a virtual environment for not only executing applications but also for storage, memory, and networking.

LPI Exam Preparation, LPI Tutorial and Material, LPI Certification, LPI Career

The machine on which the virtual machine is going to be build is known as Host Machine and that virtual machine is referred as a Guest Machine.

BENEFITS OF VIRTUALIZATION


1.More flexible and efficient allocation of resources.
2.Enhance development productivity.
3.It lowers the cost of IT infrastructure.
4.Remote access and rapid scalibility.
5.High availability and disaster recovery.
6.Pay per use of the IT infrastructure on demand.
7.Enables running multiple operating system.

Types of Virtualization:


1.Application Virtualization.
2.Network Virtualization.
3.Desktop Virtualization.
4.Storage Virtualization.

LPI Exam Preparation, LPI Tutorial and Material, LPI Certification, LPI Career

1. Application Virtualization:

Application virtualization helps a user to have a remote access of an application from a server. The server stores all personal information and other characteristics of the application but can still run on a local workstation through internet. Example of this would be a user who needs to run two different versions of the same software. Technologies that use application virtualization are hosted applications and packaged applications.

2. Network Virtualization:

The ability to run multiple virtual networks with each has a separate control and data plan. It co-exists together on top of one physical network. It can be managed by individual parties that potentially confidential to each other.

Network virtualization provides a facility to create and provision virtual networks—logical switches, routers, firewalls, load balancer, Virtual Private Network (VPN), and workload security within days or even in weeks.

3. Desktop Virtualization:

Desktop virtualization allows the users’ OS to be remotely stored on a server in the data center. It allows the user to access their desktop virtually, from any location by different machine. Users who wants specific operating systems other than Windows Server will need to have a virtual desktop. Main benefits of desktop virtualization are user mobility, portability, easy management of software installation, updates and patches.

4. Storage Virtualization:

Storage virtualization is an array of servers that are managed by a virtual storage system. The servers aren’t aware of exactly where their data is stored, and instead function more like worker bees in a hive. It makes managing storage from multiple sources to be managed and utilized as a single repository. storage virtualization software maintains smooth operations, consistent performance and a continuous suite of advanced functions despite changes, break down and differences in the underlying equipment.

Tuesday 19 January 2021

Celebrating Open Anniversary 2021

LPI Exam Prep, LPI Tutorial and Material, LPI Learning, LPI Guide, LPI Certification, LPI Career

In 2021, the open source movement will be celebrating several important milestones, including the 30th Anniversary of Linux and the World Wide Web.

This is a great opportunity to reflect about the impact the open source movement has had on your business and society as a whole. 

The 2021 Open Anniversary celebrations will revolve around 12 themes, one for each month of the year. A major milestone was selected to represent each theme. 

The themes and corresponding milestones are presented below:

◉ Free Culture (January): 20 years of Wikipedia and Creative Commons;

◉ Open Source (February): Open Source Initiative was founded;

◉ Open Business (March): Red Hat celebrates its Anniversary;

◉ Open Government (April): 15 years of the Sunlight Foundation (legacy);

◉ Open Knowledge (May): 25 years of the Internet Archive and 20 years of the Wayback Machine;

◉ Open Hardware (June): Open Source Hardware Association was established;

◉ Open Education (July): Open Educational Resources was presented;

◉ Open Web (August): 30 years of the first website and public announcement of the WWW;

◉ Linux (September): 30 years of Linux, initial release (version 0.0.1);

◉ Free Software (October): Free Software Foundation was founded;

◉ Open Access (November): 35 years of Aaron Swartz (in memory of);

◉ Open Data (December): Open public data was defined.

LPI Exam Prep, LPI Tutorial and Material, LPI Learning, LPI Guide, LPI Certification, LPI Career
Each month will focus on an anniversary specific theme, the open source community is encouraged to participate in the activities.

Linux Professional Institute is thrilled to be supporting the Linux Anniversary taking place in the month of September and will also be sharing information and activities on a monthly basis based on the monthly themes as well. CLPI specific content will be generated from LPI partners, members and the overall community.

We look forward to the year ahead! You can find the activities that are taking place on Open Anniversary.

Source: lpi.org

Saturday 16 January 2021

Free nerdy culture

LPI Tutorial and Material, LPI Exam Prep, LPI Learning, LPI Preparation, LPI Career

Although we tend to emphasize the technical aspects of our Free and Open Source Software Community, the truth is that hackers and nerds in general value all kinds of Free Knowledge. Actually, Eric S. Raymond points this out in his text, How to Become a Hacker;

“The hacker mind-set is not confined to this software-hacker culture. There are people who apply the hacker attitude to other things, like electronics or music — actually, you can find it at the highest levels of any science or art. Software hackers recognize these kindred spirits elsewhere and may call them ‘hackers’ too — and some claim that the hacker nature is really independent of the particular medium the hacker works in.”

This said, of course, in modern days all the tools allowing the base for free sharing of knowledge are technical ones, and pretty much of them all based on free and open source software. The biggest example here is Wikipedia, who is based on the free software MidiaWiki, widely used within several communities who want to share their knowledge. Another important component is the Creative Commons licenses who allow all sorts of media (written text, music, movies, drawing and arts) to be developed in a free and collaborative manner, still recognizing the creators of whatever it is -- even software, methodologies, processes and hardware blueprints.

LPI’s mission is to promote the use of open source by supporting the people who work with it. And the people working with open source are big supporters of all kinds of knowledge-openness and freedom. Including freedom of expression. So, other than supporting several initiatives aligned with the LPI worldwide mission, LPI also supports FOSSlife, a community (Drupal based) portal where you will read technical articles, of course, seasoned with a lot of free culture elements.

LPI Tutorial and Materials, LPI Certification, LPI Career, LPI Study Material
The idea behind FOSSlife is to provide a voice and open space for all aspects of the culture that surrounds the life of free and open source software professionals. You can read about topics such as mindfulness techniques for dealing with life in tech, what refactoring has to do with roman numerals and who are the drive-thru contributors to open source, among other things. Of course you can expect more technical articles in there too. 

Hackers also love science fiction, so we will end with a quote from StarGate SG1 (episode 11, first season). Daniel is trying to gather information that might give him a whole new perspective on how our civilization started but the world they are in is about to be destroyed and he must join his team and go back to the StarGate. An elder, Ernest, who have been trapped in that world for fifty years tells Daniel, with tears in his eyes;

“No prize is worth attaining if you can never share it! There would be no point! Believe me.”

Source: lpi.org

Tuesday 12 January 2021

Different Ways to Create File in Linux

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

There are mainly four ways of creating files in LINUX. All of them have their own purpose and benefits. They are as follows:

1. cat command

It is the most universal tool for creating files. We cannot edit a file using cat command. Major operations that can be done using it are as follows:

Creating files and then writing the data 

cat >file1

Note: After writing the text, press ctrl+d.

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

To view data of a file

cat file1

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

Concatenate files — adding two files into another a new file

cat >file2
cat file1 file2 > file3
cat file3

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

To add data at end of a file

cat >> file2
cat file2

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

Copy file’s data (the content of one file into another) 

cat file1 > file2
cat file2

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

Reverse the data of the file (tac)

tac file1

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

2. touch command


We can create an empty file (or multiple empty files) using this command. But its main purpose is to change or update the time-stamp of a file. Major operations that can be done using it are as follows:

Creating a file

touch filea
cat filea

Note: Creating a file and then using the cat command to view the data.

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

To change the timestamp of the file

stat filea
touch filea
stat filea

Note: We are using stat file_name to check the timestamp of the file. We can see the access, modify, and change is now updated.

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

Change access time only

Access time is the last time when the file was accessed.

stat filea
touch -a filea
stat filea

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

Change modify time only

Modify time is the time when a file was modified.

stat filea
touch -m filea
stat filea

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

3. vi command


Its main function is to edit files. It is commonly used by programmers to edit texts. Major operations that can be done using it are as follows:

Note: To quit vi text editor, press the Escape key and then type:wq and hit enter.

Create a file

vi file_1

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

Open and edit file

use simple arrow keys to move and character keys to type in the file.

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

4. nano command


It may/may not be found in all distributions of LINUX. We can create as well as edit files.

Note: To exit nano Text Editor press ctrl + x.

nano file_1

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

LPI Exam Prep, LPI Learning, LPI Certification, LPI Learning, LPI Guides, LPI Career, LPI Cert Prep, LPI PDF

Saturday 9 January 2021

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: LPIC-OT 701: DevOps Tools Engineer

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 Tutorial and Material, Linux Guides, Linux Learning, Linux Exam Prep

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 Tutorial and Material, Linux Guides, Linux Learning, Linux Exam Prep

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.

Thursday 7 January 2021

LPI Certification Programs

LPI Exam Prep, LPI Certification, LPI Learning, LPI Tutorial and Material, LPI Guides, LPI Career

Linux certifications are highly recommended by many companies as Linux gaining recognition by global platforms these days. These Linux exams certification programs are gaining popularity among data administrators, system admins, DevOps engineers. It helps IT, professionals, to get knowledge and recognition.

Linux Professional Institute (LPI) found in October 1999. After ten years later and after Linus Torvalds began his pioneering efforts on the Linux kernel. It helps software professionals to enhance their Linux knowledge.


Certification Name LPIC-1: Linux Administrator
LPIC-2: Linux Engineer
LPIC-3: Linux Enterprise Professional
Prerequisites & Required Courses  ◉ LPIC-1: Fundamental Linux knowledge is required
◉ LPIC-2: Candidate must have an active LPIC-1 certification
◉ LPIC-3: Active LPIC-2 certification plus completion is one of the 300 series specialty Linux exams 
Format  Online 
Languages  English, German, Japanese, Portuguese, Chinese 
Passing Criteria  Passing exams 101 and 102 
Career Path  Linux Certified Professional 
Linux certification Cost Per Exam  $200 
Validity  5 years 

Tuesday 5 January 2021

What is Open API in UNIX?

There is a set of generic APIs in UNIX which is used to manipulate files. One of these APIs is the open API. The open API is used to create new files and also to establish a connection between a process and a file. After a file is created, any process can call the open function and it gets a file descriptor to refer to the file, which contains the inode information. The prototype of the open function is given below:

#include <sys/types.h>

#include <fcntl.h>

int open(const char *path_name, int access_mode, mode_t permission);

◉ If successful, the open function returns a non-negative integer representing the open file descriptor.

◉ If unsuccessful, the open function returns -1

Use of the arguments in the function prototype:

First Argument: path_name

This specifies the pathname of the file to be created or opened. This may be a relative pathname or an absolute pathname. If the pathname is a symbolic link, the open function will resolve the link refers to a non-symbolic link file to which the link refers.

Second Argument: access_mode

It is an integer value that specifies how the file is to be accessed by the calling process. This value should be one of the manifested constants described below as defined in the <fcntl.h> header:

Access mode flag Use
O_RDONLY   Opens the file for read-only
O_WRONLY   Opens the file for write-only 
O_RDWR  Opens the file for read and write 

These access node flags can be bitwise-ORed with the access modifier flags given below to change the access mechanism of the file:

Access modifier flag Use
O_APPEND

Appends data to the end of the file
(Applicable only to Regular files)

O_CREAT

Creates file if it does not exist
(Applicable only to Regular files)

O_EXCL It causes open function to fail if the named file exists already.
Also, it can be used with the O_CREAT flag only. (Applicable only to Regular files)
O_NONBLOCK

Specifies that any subsequent read or write on the file should be nonblocking
(Applicable only to FIFO and device files)

O_NOCTTY

Specifies not to use named terminal device file as the calling process control terminal
(Applicable only to terminal device files)

O_TRUNC

Discards the file content and sets the file size to 0 bytes if the file exists
(Applicable only to Regular files)


Note:

◉ If a file is to be opened for read-only, then the file should already exist and also, no other modifier flags can be used with it.

◉ If a file is opened for read-write or write-only, then any modifier flags can be specified.

◉ If the named file does not exist and the O_CREAT file is not specified, then the open function will abort with a failure return status.

Third Argument: permission

This argument is used only when a new file is being created. This is required only if the O_CREAT flag is set in the access_mode argument. It specifies the access permission o the file for its owner, group member, and others. This argument is defined as mode_t and its value should be constructed based on the manifested constants defined in the <sys/stat.h> header. The symbolic names for file permission are given in the table below:

SYMBOL           MEANING
S_IRUSR       read by owner
S_IWUSR       write by owner
S_IXUSR       execute by owner
S_IRWXU       read, write and execute by owner
S_IRGRP       read by group
S_IWGRP       write by group
S_IXGRP       execute by group
S_IRWXG       read, write and execute by group
S_IROTH       read by others
S_IWOTH       write by others
S_IXOTH       execute by others
S_IRWXO       read, write and execute by others

Example 1:

int fdesc= open(“abc/xyz/geeksforgeeks”,O_RDWR | O_APPEND, 0);

This example opens an already existing file called /abc/xyz/geeksforgeeks for read and write in append mode

The access mode flag O_RDWR is bitwise ORed “|” with access modifier flag O_APPEND

Example 2:

Let us see the use of open API in a C program which demonstrates interprocess communication between a reader and writer process. Do not worry about the functionality or procedure of the program as it will have other concepts also. Concentrate only on the use of open API. Firstly, create two C program files using the nano editor.

$nano write.c

After entering this command, the nano editor will pop up.

LPI Tutorial and Material, LPI Exam Prep, LPI Learning, LPI Certification, LPI Career
Enter this program write.c into the nano editor, then save it and exit from the editor

In this program, in line number 13 (fd=open(myfifo, O_WRONLY);), the open API is used to open a file in the WRITE ONLY MODE (O_WRONLY). In the next line the text, “GeeksforGeeks” is being written in the file using another API called write API. After this, the file descriptor fd is closed. As a result, the file which was opened has the text “GeeksforGeeks”. 

Similarly, create a read.c file by entering the command:

$nano read.c

LPI Tutorial and Material, LPI Exam Prep, LPI Learning, LPI Certification, LPI Career
Enter this program read.c into the nano editor, then save it and exit from the editor

In this program, in line number 12 (fd=open(myfifo, O_RDONLY);), the open API is used to open the same file in which text “GeeksforGeeks” was written. The API opens it in the READ ONLY MODE (O_RDONLY). In the next line the read API is used to read the data from the file and the data (“GeeksforGeeks”) is displayed. After this, the file descriptor fd is closed. 

Let us see the terminal screen on Ubuntu:

LPI Tutorial and Material, LPI Exam Prep, LPI Learning, LPI Certification, LPI Career
First Terminal Screen 

We have already discussed the first two nano commands. The third command (cc write.c) compiles the write.c program and ./a.out runs the write.c program. After the execution of the program, the text “GeeksforGeeks” has been written into the file and a line is displayed saying that “Writer process started and now open one more terminal for running reader process”.

Now, open one more terminal screen of Ubuntu and execute the commands as given in the picture below:

LPI Tutorial and Material, LPI Exam Prep, LPI Learning, LPI Certification, LPI Career
Second Terminal Screen

The first command (cc read.c) compiles the read.c program and ./a.out runs the read.c program. After the execution, you can see that the data from the file is being displayed.

This was possible because the file was opened in the read-only mode and the data was read by the read API and got displayed.

Source: geeksforgeeks.org

Saturday 2 January 2021

Linux – Network Information Service

LPI Study Materials, LPI Exam Prep, LPI Certification, LPI Career, Linux Guides

The Network Information Service, or NIS (initially called YP or yellow pages), is a mainframe-client index service convention for circulating server configuration information, for example, client and host names between PCs on a PC network. Sun Microsystems built up the NIS; the innovation is authorized to essentially all other Unix merchants. Since British Telecom PLC claimed the name “Yellow Pages” as an enlisted brand name in the United Kingdom for its paper-based, business phone catalog, Sun changed the name of its framework to NIS, however, all the orders capacities actually start with “yp”. A NIS/YP framework keeps up and disseminates a focal index of the client and gathering information, hostnames, email pseudonyms, and other content-based tables of information in a PC network. For instance, in a typical UNIX climate, the rundown of clients for ID is put in/and so forth/passwd and mystery verification hashes in/and so on/shadow. NIS includes another “worldwide” client list which is utilized for recognizing clients on any customer of the NIS area. Administrators can arrange NIS to serve secret key information to outside cycles to verify clients utilizing different variants of the Unix crypt(3) hash calculations. In any case, in such cases, any NIS(0307) customer can recover the whole secret phrase information base for disconnected investigation. Kerberos was intended to deal with confirmation in a safer way. 

We utilize the Linux NIS mainframe (Network Information Service) for sharing basic information put away in level documents between frameworks on a network. It is frequently ideal to have a mutual archive, (for example, NIS) for putting away clients and gatherings information as opposed to putting away them in level documents like/and so forth/passwd. So what is the advantage of that? By making such documents accessible through the NIS worker, that would permit any distant NIS customer machine to access or question the information in these mutual records and use them as expansions to the nearby forms.

Read More: LPI Certifications

NIS isn’t for sharing records. We can share any even document which in any event has one section with an extraordinary worth by means of NIS like/and so on/services record. The primary advantage of utilizing the NIS worker is that you keep your information and records, and spread any updates to all clients. A few clients, particularly Windows clients, may think this is a kind of Active Directory like service. The Linux NIS worker is more established than Active Directory and not a reproduce for it.

NIS Introduction:

By running NIS, the framework administrator can disperse administrative information bases, called maps, among an assortment of mainframes (ace and slaves). The administrator can refresh those information bases from a brought together area in a programmed and solid design to guarantee that all customers share a similar naming service information predictably all through the network. NIS was grown freely of DNS and has a marginally extraordinary core interest. While DNS centers around making correspondence less difficult by utilizing machine names rather than mathematical IP addresses, NIS centers around making network administration more sensible by giving unified command over an assortment of network information. NIS stores information about machine names and addresses, yet additionally about clients, the network itself, and network services. This assortment of network information is alluded to as the NIS namespace.

Note — In certain settings machine names are alluded to have had names or machine names. This conversation utilizes a machine, yet some screen messages or NIS map names may utilize host or machine.

NIS Architecture:

NIS utilizes a customer worker plan. NIS mainframes offer types of assistance to NIS customers. The primary workers are called ace workers, and for unwavering quality, they have reinforcement or slave workers. Both ace and slave workers utilize the NIS information recovery programming and both store NIS maps. NIS utilizes domains to mastermind the machines, clients, and networks in its namespace. Nonetheless, it doesn’t utilize an area chain of command; a NIS namespace is level.

LPI Study Materials, LPI Exam Prep, LPI Certification, LPI Career, Linux Guides

A NIS domain can’t be associated straightforwardly to the Internet utilizing just NIS. Notwithstanding, associations that need to utilize NIS and furthermore be associated with the Internet can consolidate NIS with DNS. You can utilize NIS to deal with all neighborhood information and use DNS for the Internet to have queries. NIS gives a sending service that advances have queries to DNS if the information can’t be found in a NIS map. The Solaris working climate additionally permits you to set up the nsswitch.conf record with the goal that has query demands go just to DNS, or to DNS and afterward NIS on the off chance that not found by DNS, or to NIS and afterward DNS if not found by NIS.

NIS Machine Types: There are three kinds of NIS machines:

◉ Ace mainframe
◉ Slave mainframe
◉ Customers of NIS mainframes

Any machine can be a NIS customer, however, just machines with plates ought to be NIS workers, either ace or slave. Workers are likewise customers, ordinarily of themselves.

NIS Servers:

The NIS mainframe doesn’t need to be a similar machine as the NFS record worker. NIS mainframes come in two assortments, ace, and slave. The machine assigned as ace worker contains the arrangement of guides that the framework administrator makes and updates as important. Every NIS space must have one, and just one, ace worker, which can engender NIS refreshes with the least presentation debasement. We can assign extra NIS workers in the domain as slave workers. A slave worker has a total duplicate of the ace arrangement of NIS maps. At whatever point the ace worker maps are refreshed, the updates are proliferated among the slave workers. Slave workers can deal with any flood of solicitations from the ace worker, limiting “worker inaccessible” mistakes. 

Ordinarily, the framework administrator assigns one ace worker for all NIS maps. Be that as it may, on the grounds that every individual NIS map has the machine name of the ace worker encoded inside it, you could assign various workers to go about as ace and slave workers for various guides. To limit disarray, assign a solitary worker as the ace for all the guides you make inside a solitary area. The models in this part expect that one worker is the ace for all guides in the space.

NIS Clients:

NIS customers run measures that demand information from maps on the workers. Customers don’t make a differentiation among ace and slave workers, since all NIS workers ought to have a piece of similar information.

NIS Elements:

The NIS naming service is made out of the accompanying components:

◉ Domains
◉ Guides
◉ Daemons
◉ Utilities
◉ NIS Command Set

The NIS is an information base that contains a progression of tables. It makes tables from text records like/and so on/passwd,/and so forth/services, and some other plain documents. Each table may contain one section or more with a novel key on each line. You can consider it like any typical information base. You can question these tables in two different ways:

◉ Posting the whole table
◉ Pulling a particular passage via looking

At the point when a program solicitations to look for a client secret phrase subtleties, the customer checks the/and so on/passwd record to check on the off chance that the client doesn’t exist there; the customer at that point approaches the NIS worker to look for it in the/and so on/passwd table from the NIS worker. You can utilize any of the services and applications that accompany the NIS mainframe:

◉ ypserv: This service sits tight for inquiries and offers responses to NIS customers.
◉ ypbind: This is the customer side of NIS.
◉ ypxfrd: You can utilize this service for sending the NIS information bases from ace MIS workers to slave workers.

The NIS Domain: A NIS domain is an assortment of machines that share a typical arrangement of NIS maps. Every space has an area name and each machine sharing the basic arrangement of guides has a place with that area. Any machine can have a place with a given area, as long as there is a mainframe for that space’s guides in a similar network. A NIS customer machine acquires its area name and ties to a NIS worker as a component of its boot cycle.

Five daemons are utilized in order to provide the NIS service:

Daemon Function 
ypserv  Server process
ypbind  Binding process
ypxfrd  High-speed map transfer  
rpc.yppasswdd   NIS password update daemon  
rpc.ypupdated   Modifies other maps such as publickey 

A total of 9 utilities support the NIS service:

Utility Function 
makedbm  Makes dbm record for a NIS map
ypcat  Records information in a guide 
ypinit  Fabricates and introduces a NIS information base and instates NIS customer’s ypservers list  
ypmatch  Finds a particular passage in a guide  
yppoll  Gets a guide request number from a worker 
yppush  Proliferates information from NIS ace to NIS slave worker 
ypset  Sets binding to a specific mainframe 
ypwhich  Records name of the NIS mainframe and alias interpretation table  
ypxfr  Moves information from ace to slave NIS mainframe 

Applications of NIS:

There are some valuable apparatuses that can assist you with dealing with the information in the information base.

◉ ypcat: You can utilize this to get information from the NIS worker by separating it from the NIS map.
◉ ypwhich: gets the name of the Linux NIS worker that is reacting to your solicitations.
◉ ypmatch: instead of snatching the whole guide, or you can look by key to get a particular section.