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.

Thursday, 12 November 2020

5 UNIX / Linux Anacron Command Example for Background Jobs

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

The main advantage of anacron is that you don’t need to have the system be up and running always to execute the background jobs.

This is very helpful when you want to run background jobs on laptops, which might not be available 24×7. But, you still can schedule routine jobs on these machines using anacron.

This way whenever the laptop starts again, any pending scheduled jobs will be executed by anacron

1. Test Anacron Syntax

All anacron jobs are located under /etc/anacrontab file as shown below:

# cat /etc/anacrontab

1       5       cron.daily              nice run-parts /etc/cron.daily

7       25      cron.weekly             nice run-parts /etc/cron.weekly

@monthly 45     cron.monthly            nice run-parts /etc/cron.monthly

@bimonthly 45   cron.bimonthly          nice run-parts /etc/cron.bimonthly

In the above example, the last line is invalid, as the timeperiod “bimonthly” it not support by anacron.

So, you can check for any syntax error, or other issues with the anacrontab file using the following command.

This output indicates that we have an unknown name period in the file.

# anacron -T

anacron: /etc/anacrontab: Unknown named period on line 17, skipping

If you have your own crontab file, you can test that syntax using -T -t and specifying your custom anacrontab file name as shown below.

# anacron -T -t /etc/myanacron

anacron: Invalid syntax in /etc/myanacron on line 14 - skipping this line

anacron: Invalid syntax in /etc/myanacron on line 15 - skipping this line

2. Custom Spool directory

Apart from specifying your own anacrontab file, you can also specify your own spool directory for anacron. This is helpful when you are testing some anacron jobs, and don’t want to messup the standard anacrontab file and spool directory.

The following uses /root/myspool to store all the timestamp information for the jobs that are defined in the /etc/myanacron file.

# anacron -S /root/myspool -t /etc/myanacron

# ls -altr /root/myspool/

total 8

dr-xr-x---. 9 root root 4096 Jan 31 23:35 ..

-rw-------. 1 root root    0 Jan 31 23:36 myjob

drwxr-xr-x. 2 root root 4096 Jan 31 23:36 .

The default spool directory is /var/spool/anacron as shown below, which stores the timestamp for the jobs from the /etc/anacrontab file.

# ls -l /var/spool/anacron

total 16

-rw-------. 1 root root 9 Jan 31 23:56 cron.daily

-rw-------. 1 root root 9 Jan 31 23:56 cron.monthly

-rw-------. 1 root root 9 Jan 31 23:56 cron.weekly

They typically store the information on when was this particular job last executed:

# cat /var/spool/anacron/cron.daily

20140131

# cat /var/spool/anacron/cron.monthly

20140131

3. Run Anacron in the Foreground

You can also run the anacron in the foreground. Sometime this is easy, as you can see the output on the screen itself. This is good for checking something very quick during testing purpose.

For example, when you don’t give -d option, anacron forks a background jobs, and it will just not display anything on the screen. This example, just updates the timestamp for the jobs, but really doesn’t execute anything. You won’t know what really happened.

# anacron -u

But, when you run the anacron in the foreground, using -d option, you can see what it is doing. Don’t do this when you have jobs that will run for long period of time.

# anacron -d -u

Updated timestamp for job `cron.daily' to 2014-01-31

Updated timestamp for job `cron.weekly' to 2014-01-31

Updated timestamp for job `cron.monthly' to 2014-01-31

4. Force the Job Execution

LPI Exam Prep, LPI Tutorial and Material, LPI Guides, LPI Certification
The -f option will do a force execution of the jobs. But this will still consider the delay specs that you’ve set in the anacrontab file.

# anacron -d -f

Anacron started on 2014-01-31

Will run job `cron.daily' in 24 min.

Will run job `cron.weekly' in 44 min.

Will run job `cron.monthly' in 64 min.

However, -n option will execute the job immediately. This will not consider any delay specs that you’ve set in the anacrontab file. Please note that -n option also implies -s option.

# anacron -d -n

Anacron started on 2014-01-31

Checking against 0 with 31

Normal exit (0 jobs run)

5. Specify a Job Name

If you have defined multiple jobs in the anacrontab file, you can execute only a specific job by specifying its job name.

In the following example, it will execute only the job with the name “myjob” from the custom /etc/myanacron tab file.

# anacron -f -d -t /etc/myanacron myjob

Anacron started on 2014-01-31

Will run job `myjob' in 1 min.

Job `myjob' started

Job `myjob' terminated

Normal exit (1 job run)

Tuesday, 10 November 2020

Difference between Linux and Windows

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

Linux:

Linux could be a free and open supply OS supported operating system standards. It provides programming interface still as programme compatible with operating system primarily based systems and provides giant selection applications. A UNIX operating system system additionally contains several severally developed parts, leading to UNIX operating system that is totally compatible and free from proprietary code.

Read More: LPI Certification

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


Windows:

Windows may be a commissioned OS within which ASCII text file is inaccessible. it’s designed for the people with the angle of getting no programming information and for business and alternative industrial users. it’s terribly straightforward and simple to use.

The distinction between Linux and Windows package is that Linux is completely freed from price whereas windows is marketable package and is expensive. Associate operating system could be a program meant to regulate the pc or computer hardware Associate behave as an treater between user and hardware.

Linux is a open supply package wherever users will access the ASCII text file and might improve the code victimisation the system. On the opposite hand, in windows, users can’t access ASCII text file, and it’s a authorized OS.

Let’s see that the difference between Linux and windows:

LINUX WINDOWS 
Linux is a open source operating system. While windows are the not the open source operating system.
Linux is free of cost. While it is costly.
It’s file name case-sensitive. While it’s file name is case-insensitive.
In linux, monolithic kernel is used. While in this, micro kernel is used.
Linux is more efficient in comparison of windows.  While windows are less efficient.
There is forward slash is used for Separating the directories. While there is back slash is used for Separating the directories.
Linux provides more security than windows. While it provides less security than linux.
Linux is widely used in hacking purpose based systems. While windows does not provide much efficiency in hacking.

Saturday, 7 November 2020

How to Contribute to an Open Source Project

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

It is great to see that the strategic relevance of open source software for the software industry is rapidly increasing (e.g. shown by IBM and Microsoft investing heavily into open source) and companies as well as individuals increasingly acknowledge the importance and advantages of open source.

One of the special things about an open source project is the amazing open source community. Open source software solutions manage to gather a community of developers and users around them. Ideally, they are actively involved in testing, developing and promoting the product. A diverse global community can generate more ideas, report and fix bugs, develop and troubleshoot faster than an internal team. Also, a free software can easily be adapted to fit exactly your needs. And with every improvement by an individual, a big user community will benefit.

That is why I want to encourage you to contribute to open source software. And it is not only about software developers to contribute new product features or the likes. Everyone can contribute in different ways and the product evolves with every contribution. Even as a less tech savvy person you can bring a lot to the table.

As I am one of the founders of the open source project management software OpenProject, I would like to use it as an example to show you how you can contribute to open source software, even if you don’t have a technical background.

OpenProject is free and open source software. The Community version can be downloaded and installed for free. We recommend the packaged installation of OpenProject with a compatible Linux distribution. The OpenProject Enterprise on-premises offers additional premium features and comes as an upgrade to your on-site Community installation. With the Enterprise Cloud, OpenProject does the hosting for you and the premium features are also included.

All three OpenProject versions are open source and will benefit from your contribution. Let’s take a look at what you can do for the OpenProject community or for any other open source project.

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

Make a difference with user support

Each open source project will benefit from dedicated user support. This is where you can step in. Our community forum is at the heart of OpenProject. This is where we connect with you and you can connect with other users, ask any question you want and support other OpenProject users. Topics like OpenProject development, support, plugins, general topics are discussed.

You can contribute by sharing your OpenProject experience with other users and help them thrive with their projects. Together we keep the conversation going.

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

Share your ideas for new features

New ideas about features or improvements are always worth sharing with the open source community to improve the product. You are using OpenProject and discover a feature that we haven’t on our roadmap yet but would be beneficial for your project management? Please let us know and open a ticket for a feature idea. You are also welcome to go through the feature ideas and comment on the ones created by someone else that you would also wish for. We are reviewing all feature requests and evaluate them by relevance and effort and then include them into our product roadmap for the upcoming releases. We want to give you as much transparency as possible, hence you can track the progress of all feature requests. We have also documented our product development process in order to make it as clear as possible how new features are being prioritized.

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

Create relevant content for the community

The open source community is there to learn from each other, share your thoughts on topics that interest you, the community will appreciate it. We love to exchange topics and views with our users and the open source community to inspire and share knowledge.

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

Help to improve the product with bug reporting

Open source software can be superior because of an active community that is involved to find and report bugs that will still appear despite extensive testing by the development team. Nobody is perfect. If you are an OpenProject user and encounter a behavior that you had not expected, we welcome you to report this bug. We have easy instructions on how you can report the bug here. Don’t be afraid to report a bug with less technical explanations, we attend to all tickets and are looking forward to improving OpenProject with your help.

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

Be the first to test new features

In order to identify possible bugs before releasing a new version, the open source community is invited to beta test new releases. You can also support OpenProject with testing. We have a quality assurance environment that is always at the latest stage of development. Just register an account and then you can test the new features that we are working on before they go live for everyone. You can for example take a work package of the next OpenProject release and test it. If you find any bugs while testing, report it as described above.

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

Support others by contributing to the documentation

Not only the software itself but also the documentation of an open source software can be open for collaboration. We have an extensive OpenProject documentation and are aiming to make it as complete as possible. Nevertheless, you might find some aspects missing or not detailed enough. Please feel free to add to the documentation regarding additional sections, screenshots or whatever can help yourself and our users to improve the usage of OpenProject.

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

Translate into your mother tongue

The open source community is global and speaks many languages. English is spoken by most but nevertheless everyone is most comfortable in their mother tongue. Thus, contributions in different languages are always welcome in the open source community. Are you native in any other language than German or English? OpenProject is used worldwide and already available in more than 40 languages but there is still a lot to do. We would be very glad if you contributed with more translations. 

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

Enjoy the freedom to add new features with your development

The first thing you think about when you hear contribution to open source software is usually software development. I spoke mostly about non-developmental contribution as it is less talked about but such an integral part of the open source community. Nevertheless, I would like to invite the software developers to contribute as well. Our development guide will give you an overview of what options there are and how to develop for OpenProject. If you are rather new to OpenProject, we have created a feature list for you that contains features that are relatively easy to develop.

Source: lpi.org

Thursday, 5 November 2020

AWK command in Unix/Linux with examples

AWK Command, AWK Exam Prep, LPI Tutorial and Material, LPI Certification, LPI Exam Prep

Awk is a scripting language used for manipulating data and generating reports.The awk command programming language requires no compiling, and allows the user to use variables, numeric functions, string functions, and logical operators.

Awk is a utility that enables a programmer to write tiny but effective programs in the form of statements that define text patterns that are to be searched for in each line of a document and the action that is to be taken when a match is found within a line. Awk is mostly used for pattern scanning and processing. It searches one or more files to see if they contain lines that matches with the specified patterns and then performs the associated actions.

Awk is abbreviated from the names of the developers – Aho, Weinberger, and Kernighan.

WHAT CAN WE DO WITH AWK ?

1. AWK Operations:

(a) Scans a file line by line

(b) Splits each input line into fields

(c) Compares input line/fields to pattern

(d) Performs action(s) on matched lines

2. Useful For:

(a) Transform data files

(b) Produce formatted reports

3. Programming Constructs:

(a) Format output lines

(b) Arithmetic and string operations

(c) Conditionals and loops

Syntax:

awk options 'selection _criteria {action }' input-file > output-file

Options:

-f program-file : Reads the AWK program source from the file 

                  program-file, instead of from the 

                  first command line argument.

-F fs            : Use fs for the input field separator

Sample Commands

Example:

Consider the following text file as the input file for all cases below.

$cat > employee.txt 

ajay manager account 45000

sunil clerk account 25000

varun manager sales 50000

amit manager account 47000

tarun peon sales 15000

deepak clerk sales 23000

sunil peon sales 13000

satvik director purchase 80000 

1. Default behavior of Awk: By default Awk prints every line of data from the specified file.

$ awk '{print}' employee.txt

Output:

ajay manager account 45000

sunil clerk account 25000

varun manager sales 50000

amit manager account 47000

tarun peon sales 15000

deepak clerk sales 23000

sunil peon sales 13000

satvik director purchase 80000 

In the above example, no pattern is given. So the actions are applicable to all the lines. Action print without any argument prints the whole line by default, so it prints all the lines of the file without failure.

2. Print the lines which matches with the given pattern.

$ awk '/manager/ {print}' employee.txt 

Output:

ajay manager account 45000

varun manager sales 50000

amit manager account 47000 

In the above example, the awk command prints all the line which matches with the ‘manager’.

3. Splitting a Line Into Fields : For each record i.e line, the awk command splits the record delimited by whitespace character by default and stores it in the $n variables. If the line has 4 words, it will be stored in $1, $2, $3 and $4 respectively. Also, $0 represents the whole line.

$ awk '{print $1,$4}' employee.txt 

Output:

ajay 45000

sunil 25000

varun 50000

amit 47000

tarun 15000

deepak 23000

sunil 13000

satvik 80000 

In the above example, $1 and $4 represents Name and Salary fields respectively.

Built In Variables In Awk

Awk’s built-in variables include the field variables—$1, $2, $3, and so on ($0 is the entire line) — that break a line of text into individual words or pieces called fields.

NR: NR command keeps a current count of the number of input records. Remember that records are usually lines. Awk command performs the pattern/action statements once for each record in a file.

NF: NF command keeps a count of the number of fields within the current input record.

FS: FS command contains the field separator character which is used to divide fields on the input line. The default is “white space”, meaning space and tab characters. FS can be reassigned to another character (typically in BEGIN) to change the field separator.

RS: RS command stores the current record separator character. Since, by default, an input line is the input record, the default record separator character is a newline.

OFS: OFS command stores the output field separator, which separates the fields when Awk prints them. The default is a blank space. Whenever print has several parameters separated with commas, it will print the value of OFS in between each parameter.

ORS: ORS command stores the output record separator, which separates the output lines when Awk prints them. The default is a newline character. print automatically outputs the contents of ORS at the end of whatever it is given to print.

Examples:

Use of NR built-in variables (Display Line Number)

$ awk '{print NR,$0}' employee.txt 

Output:

1 ajay manager account 45000

2 sunil clerk account 25000

3 varun manager sales 50000

4 amit manager account 47000

5 tarun peon sales 15000

6 deepak clerk sales 23000

7 sunil peon sales 13000

8 satvik director purchase 80000 

In the above example, the awk command with NR prints all the lines along with the line number.

Use of NF built-in variables (Display Last Field)

$ awk '{print $1,$NF}' employee.txt 

Output:

ajay 45000

sunil 25000

varun 50000

amit 47000

tarun 15000

deepak 23000

sunil 13000

satvik 80000 

AWK Command, AWK Exam Prep, LPI Tutorial and Material, LPI Certification, LPI Exam Prep

In the above example $1 represents Name and $NF represents Salary. We can get the Salary using $NF , where $NF represents last field.

Another use of NR built-in variables (Display Line From 3 to 6)

$ awk 'NR==3, NR==6 {print NR,$0}' employee.txt 

Output:

3 varun manager sales 50000

4 amit manager account 47000

5 tarun peon sales 15000

6 deepak clerk sales 23000 

More Examples

For the given text file:

$cat > lpicentral.txt

A    B    C

Tarun    A12    1

Man    B6    2

Mahesh    M42    3

1) To print the first item along with the row number(NR) separated with ” – “ from each line in lpicentral.txt:

$ awk '{print NR "- " $1 }' lpicentral.txt

1 - Tarun

2 – Manav    

3 - Mahesh

2) To return the second row/item from lpicentral.txt:

$ awk '{print $2}' lpicentral.txt

A12

B6

M42

3) To print any non empty line if present

$ awk 'NF > 0' lpicentral.txt

0

4) To find the length of the longest line present in the file:

$ awk '{ if (length($0) > max) max = length($0) } END { print max }' lpicentral.txt

13

5) To count the lines in a file:

$ awk 'END { print NR }' lpicentral.txt

3

6) Printing lines with more than 10 characters:

$ awk 'length($0) > 10' lpicentral.txt

Tarun    A12    1

Mahesh    M42    3

7) To find/check for any string in any column:

$ awk '{ if($3 == "B6") print $0;}' lpicentral.txt

8) To print the squares of first numbers from 1 to n say 6:

$ awk 'BEGIN { for(i=1;i<=6;i++) print "square of", i, "is",i*i; }'

square of 1 is 1

square of 2 is 4

square of 3 is 9

square of 4 is 16

square of 5 is 25

square of 6 is 36

Tuesday, 3 November 2020

Join Command in Unix/Linux Examples

Join Command, Linux Command, Unix Command, Command Line

Join command is one of the text processing utility in Unix/Linux. Join command is used to combine two files based on a matching fields in the files. If you know SQL, the join command is similar to joining two tables in a database.

The syntax of join command is

join [options] file1 file2

The join command options are

-1 field number : Join on the specified field number in the first file
-2 field number : Join on the specified field number in the second file
-j field number : Equivalent to -1 fieldnumber and -2 fieldnumber
-o list : displays only the specified fields from both the files
-t char : input and output field delimiter
-a filenumber : Prints non matched lines in a file
-i : ignore case while joining

Unix Join Command Examples


1. Write a join command to join two files on the first field?

The basic usage of join command is to join two files on the first field. By default the join command matches the files on the first fields when we do not specify the field numbers explicitly. Let's say we have two files emp.txt and dept.txt

> cat emp.txt
10 mark
10 steve
20 scott
30 chris
> cat dept.txt
10 hr
20 finance
30 db

Here we will join on the first field and see the output. By default, the join command treats the field delimiter as space or tab.

> join emp.txt dept.txt
10 mark hr
10 steve hr
20 scott finance
30 chris db

Important Note: Before joining the files, make sure to sort the fields on the joining fields. Otherwise you will get incorrect result.

2. Write a join command to join the two files? Here use the second field from the first file and the first field from the second file to join.

In this example, we will see how to join two files on different fields rather than the first field. For this consider the below two files as an example

> cat emp.txt
mark 10 1
steve 10 1
scott 20 2
chris 30 3
> cat dept.txt
10 hr 1
20 finance 2
30 db 3

From the above, you can see the join fields are the second field from the emp.txt and the first field from the dept.txt. The join command to match these two files is

> join -1 2 -2 1 emp.txt dept.txt
10 mark 1 hr 1
10 steve 1 hr 1
20 scott 2 finance 2
30 chris 3 db 3

You can also see that the two files can also be joined on the third filed. As the both the files have the matching join field, you can use the j option in the join command.

Here -1 2 specifies the second field from the first file (emp.txt) and -2 1 specifies the first field from the second file (dept.txt)

> join -j 3 emp.txt dept.txt
1 mark 10 10 hr
1 steve 10 10 hr
2 scott 20 20 finance
3 chris 30 30 db

3. Write a join command to select the required fields from the input files in the output? Select first filed from first file and second field from second file in the output.

By default, the join command prints all the fields from both the files (except the join field is printed once). We can choose what fields to be printed on the terminal with the -o option. We will use the same files from the above example.

> join -o 1.1 2.2 -1 2 -2 1 emp.txt dept.txt
mark hr
steve hr
scott finance
chris db

Here 1.1 means in the first file select the first field. Similarly, 2.2 means in the second file select the second field

4. Write a command to join two delimited files? Here the delimiter is colon (:)

So far we have joined files with space delimiter. Here we will see how to join files with a colon as delimiter. Consider the below two files.

> cat emp.txt
mark:10
steve:10
scott:20
chris:30
> cat dept.txt
10:hr
20:finance
30:db

The -t option is used to specify the delimiter. The join command for joining the files is

> join -t: -1 2 -2 1 emp.txt dept.txt
10:mark:hr
10:steve:hr
20:scott:finance
30:chris:db

5. Write a command to ignore case when joining the files?

If the join fields are in different cases, then the join will not be performed properly. To ignore the case in join use the -i option.

> cat emp.txt
mark,A
steve,a
scott,b
chris,C
> cat dept.txt
a,hr
B,finance
c,db

> join -t, -i -1 2 -2 1 emp.txt dept.txt
A,mark,hr
a,steve,hr
b,scott,finance
C,chris,db

6. Write a join command to print the lines which do not match the values in joining fields?

Join Command, Linux Command, Unix Command, Command Line

By default the join command prints only the matched lines from both the files which means prints the matched lines that passed the join condition. We can use the -a option to print the non-matched lines.

> cat P.txt
A 1
B 2
C 3
> cat Q.txt
B 2
C 3
D 4

Print non pairable lines from first file.

> join -a 1 P.txt Q.txt
A 1
B 2 2
C 3 3

Print non pairable lines from second file.

> join -a 2 P.txt Q.txt
B 2 2
C 3 3
D 4

Print non pairable lines from both file.

> join -a 1 -a 2 P.txt Q.txt
A 1
B 2 2
C 3 3
D 4