Tuesday, 29 September 2020

Benefits of Becoming an LPI Member

LPI Exam Prep, LPI Learning, LPI Certification, LPI Exam Prep, LPI Prep

Recently, Linux Professional Institute (LPI) launched a formal membership program for holders of its professional level certifications. This program includes holders of LPIC-1 certifications or higher, as well as those certified in the growing list of Open Technology topics.

Membership allows certificate holders to incrementally update their knowledge and prolong the lives of their certifications. It also changes the governance model of LPI and gives the ultimate authority over LPI to the people that it certifies. Since this program is new, there is an option for holders of inactive certifications, too. Read on for more details.

Impetus for the membership program

Incorporating as a non-profit organization in Canada in 1999 required LPI to define a unit of membership (with voting control) for itself, in contrast to for-profit companies that offer shares for this purpose. Initially, these members were the founding open source professionals and advocates that championed LPI's formation. However, the intention was always to hand over the reins of the organization to the certification holders through the mechanism of membership.

It has taken some time and a lot of work behind the scenes, but that goal was institutionalized in LPI's bylaws and culminated in the launch of the membership program this past summer.

What does it mean to be a member of LPI?

For LPI, the new program means that certification holders that become members are now the ones who vote for the Board of Directors. You don't have to be a member to run for a board position, though, since a board needs a diverse set of skills to be effective. Board elections are an annual occurrence along with an Annual General Meeting (AGM) of all members.

To make membership meaningful and appealing to certification holders, the board wanted a focus other than members’ role in governance. This structural change also afforded LPI the opportunity to transition from getting people their first or next job to helping more broadly in their careers and communities. This objective explains the various initiatives that have already launched and are being developed.

On a practical level, membership offers long-term benefits to those who obtained certifications. No one needs to become a member to maintain their certifications. The advantage of membership  is that  you don’t have to wait for your certification to expire and then retake the tests. Instead, you can keep your knowledge and your certification up to date by engaging in regular, small-scale activities that offer you a kind of continuing  education credit called Professional Development Units (PDUs).

Here is the background. Certifications, like university and college degrees, demonstrate a level of knowledge and experience at a fixed point in time. While they are extremely valuable, they also have a shelf life.  At the rate in which technology changes, this value can diminish quickly. Fortunately, LPI certifications age well.

However, as with most professions, LPI expects certification holders to keep and  update their knowledge along with changes in the field. This can be done through continuing education, as well as the use and expansion of the skills and knowledge that accompanied earlier training and credentials.

This is where the membership program steps in. Members can demonstrate their growth by engaging in education, work experience in the field related to the certification, and community participation to earn PDUs. 

Active certification holders can join before submitting any PDUs, but will need to submit PDUs as part of their member obligations by the end of a three-year cycle. This cycle commences with the membership. Holders of inactive certifications will need to submit some PDUs before joining in order to demonstrate that they are still active users of open source software. After joining, the same three-year PDU cycle will start as well.

Thus, PDUs play a critical role in maintaining the value of an LPI certification by allowing a certification holder to demonstrate a combination of experience, credentials and continuing education. The idea of a membership option without the PDUs was considered but rejected because members would have to be expunged if their certifications became inactive. Furthermore, if we didn’t require PDUs, we'd have to differentiate between the folk that have a certification and may have exceeded those expectations from members who actively demonstrate their growth beyond the certifications. This would get confusing.

LPI Exam Prep, LPI Learning, LPI Certification, LPI Exam Prep, LPI Prep
LPI members who want to undertake high-level campaigns to help the free and open source community can also join our Member Engagement Committee. This may also be a good step toward a board position.

Is It worth becoming a member?

If you just want to extend the active date of your certification, there's little need to join as a member. Nothing is changing in the existing certification programs, including the five-year expiration date of certifications. They are still publicly displayable and a testament to your skills. Plus, five years should be plenty of time to leverage the value of the certification or attain a higher level credential.

Afterward, if you ever need to dust off your certifications, you could become a member for one year. That will reactivate the cert for whatever needed purpose. The cost would be about 35% of the cost of taking one exam and less than 20% of the cost of retaking LPIC-1. In addition, if you had an LPIC-2 go inactive and wanted to get LPIC-3 certification, reactivating the LPIC-2 and carrying on would be much less expensive than retaking LPIC-1 and LPIC-2. Even the 3 year membership is 90% of the cost of an exam and 45% of the cost of retaking LPIC-1.

However, our intention is to make the economic value to the member exceed the costs of joining irrespective of the extensions to the certifications’ active dates. Thus, we have added direct benefits in the form of discounts and other perqs from us and our partners.

Members will shape the future of LPI

We hope that people who choose membership will take seriously their role in  governance. Ultimately, it is up to the members to (help) shape LPI going forward. If you think there's something more that LPI, as an organization, should be doing (or should stop), please get involved. Or at least come to the AGM and shoot your mouth off for a while. Hmm, maybe that should be listed as a member benefit, too.

Source: lpi.org

Saturday, 26 September 2020

LPIC 2 – Linux Engineer

LPIC 2 – Linux Engineer, LPIC2 Certification, LPI Exam Prep, LPI Learning, LPIC-2 Guides

It is the second of LPI’s multilevel professional certification. It enables the candidate to administer small to medium-sized networks. To qualify for this certification, the candidate needs to have an active LPIC -1 Certification. However, the LPIC-1 and LPIC-2 exams can be taken in any order. The validity of this certification is 5 years. This certification covers the following topics:
  1. System StartUp
  2. Linux Kernel
  3. FileSystem and Devices
  4. Capacity Planning
  5. Advanced Storage Device Administration
  6. Network Configuration & System Maintenance
  7. File Sharing and Network Client Management
  8. Domain Name Server
  9. Web and Email
  10. System Security
LPIC 2 – Linux Engineer, LPIC2 Certification, LPI Exam Prep, LPI Learning, LPIC-2 Guides

To become LPIC-2 certified the candidate must be able to:

◉ perform advanced system administration, including common tasks regarding the Linux kernel, system startup and maintenance;

◉ perform advanced Management of block storage and file systems as well as advanced networking and authentication and system security, including firewall and VPN;

◉ install and configure fundamental network services, including DHCP, DNS,  SSH, Web servers, file servers using FTP, NFS and Samba, email delivery; and

◉ supervise assistants and advise management on automation and purchases.

Read More:

Thursday, 24 September 2020

LPIC 1 – Linux Administrator

LPIC 1 – Linux Administrator, LPI Exam Prep, LPI Learning, LPIC-1 Exam Prep

This certification enables a candidate to perform command-line maintenance tasks, install and configure a Linux system, and its basic networking. It validates a candidate’s ability to manage a real-world system administration. This certification does not require any prerequisites. The validity of this certification is 5 years. A candidate is required to pass both 101 and 102 exams to qualify for the certification. The main topics covered by this certification are:

  1. System Architecture
  2. Linux Installation
  3. Package Management
  4. GNU and Unix Commands
  5. Linux Filesystems, Filesystem Hierarchy Standard and Devices
  6. Shell & Shell Scripting
  7. Desktops and Interfaces.
  8. Administration
  9. System Services
  10. Fundamentals of Networking
  11. Security

LPIC 1 – Linux Administrator, LPI Exam Prep, LPI Learning, LPIC-1 Exam Prep

To become LPIC-1 certified the candidate must be able to:

◉ understand the architecture of a Linux system;

◉ install and maintain a Linux workstation, including X11 and setup it up as a network client;

◉ work at the Linux command line, including common GNU and Unix commands;

◉ handle files and access permissions as well as system security; and

◉ perform easy maintenance tasks: help users, add users to a larger system, backup and restore, shutdown and reboot.

Read More:

Tuesday, 22 September 2020

Exploring the Linux locate command

Linux locate command, LPI Study Materials, LPI Learning, LPI Guides, LPI Certification, LPI Exam Prep

The Linux locate command lets you easily find files in the filesystem. It works by maintaining a system-wide database of "all files which are publicly accessible". The database itself is updated periodically by a background process. Because of this approach it returns results much faster than the find command, which only looks for files when you tell it to. Depending on your system, the locate command may need to be configured initially, or it may be pre-configured to work out of the box.

The Linux locate command is easy to use. If you want to find a file named "foo", just use this locate syntax:

locate foo

The locate command returns all files it knows whose name contains the string "foo", like "foo1", "foobar", etc.

Linux locate command, LPI Study Materials, LPI Learning, LPI Guides, LPI Certification, LPI Exam Prep

You can also use the usual filename wildcard characters, including ? and *. For instance, this locate example command will list every Java file on your system:

locate "*.java"

(Be prepared, that can be a very long list.)

Finally, you can also perform a case-insensitive search using the locate command with the -i argument, like this locate command example:

locate -i "*.java"

Saturday, 19 September 2020

vi/vim delete commands and examples

vi/vim Delete Commands, LPI Study Material, LPI Learning, LPI Certification, LPI Exam Prep

vi/vim editor FAQ: Can you share some example vi/vim delete commands?

The vim editor can be just a little difficult to get started with, so I thought I’d share some more vim commands here today, specifically some commands about how to delete text in vi/vim. (vim is the modern version of the older vi.)

vi/vim delete commands - quick reference

A lot of times all people need is a quick reference, so I’ll start with a quick reference of vim delete commands:

x   - delete current character

dw  - delete current word

dd  - delete current line

5dd - delete five lines

d$  - delete to end of line

d0  - delete to beginning of line

:1,.d

delete to beginning of file

:.,$d

delete to end of file

If those commands don’t make sense on their own, the next sections will provide a brief description of each vim delete command.

vim delete character command

When you’re in “command mode” in the vim editor (just hit the [Esc] key and you’ll be there) and you want to delete the character at the current cursor position, just use the vim delete character command -- the lowercase letter x -- like this:

x

That command deletes the character at your current cursor position. If instead you want to delete ten characters, you can press the letter x ten times, or you can use this command instead:

10x

vim delete word commands

When you’re in command mode in the vi editor and you want to delete the current word, use the vi delete word command:

dw

Just like the delete character command, if you want to delete the next five words, just precede the dw command with the number 5, like this:

5dw

vim delete line commands

When you’re in command mode in the vi editor and you want to delete the current line, use the vi delete line command:

dd

Just like the delete character and delete word commands, if you want to delete the next five lines, just precede the dd command with the number 5, like this:

5dd

delete to end of line or beginning of line

vi/vim Delete Commands, LPI Study Material, LPI Learning, LPI Certification, LPI Exam Prep

To delete all the characters from your current cursor position to the beginning of the current line, use the d0 command, like this:

d0

Similarly, to delete from your current cursor position to the end of the current line, use the d$ command, like this:

d$

Whenever you’re working with vi, the letter 0 (zero) typically refers to the beginning of the current line or the beginning of the file, and the $ character typically refers to the end of the current line or end of file, so I find these commands fairly easy to remember.

delete to beginning or end of file

To delete all the lines from the beginning of the file to your current cursor position in vim, use this command:

:1,.d

That command can be read as “From line 1 to the current position, delete”, or if you prefer, “Delete from line 1 to the current line position.”

Similarly, to delete everything from the current line to the end of the file, use this vim delete command:

:.,$d

Again, that can be read as “From the current position to the end of file, delete.” 

Thursday, 17 September 2020

Dorothy K. Gordon Joins the Linux Professional Institute (LPI) Board of Directors

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

I am very happy to introduce Ms. Dorothy K. Gordon as the latest Board Director for the Linux Professional Institute.

Born in Ghana, Dorothy also spent much of her early life in the United Kingdom and Nigeria.  She is fluent in English and French, and is currently studying Spanish and Russian.

Dorothy has extensive experience with various organisations within the United Nations since 1987.

From 2003 to 2016 Dorothy was the founding director-general of the Ghana-India Kofi Annan Centre of Excellence in ICT (AITI), located in Accra, Ghana. Over a little more than 12 years, she built a record of progressive achievement and advancement to establish and strategically position AITI as a Centre of Excellence in ICT with a global reputation and strong leadership within Africa on technology for development issues.

She moved the center from total dependence on government funding to financial sustainability through consistent growth and an expansion of activity in areas of training, consulting, community engagement, and advisory services with thousands of organisations and individuals benifitted from the work of the Centre over the years of her tenure. The Centre was run exclusively on Open Source technologies.

I first met Dorothy in 2008 when she invited me to IDLELO in Senegal, a meeting produced by the Free Software and Open Source Foundation for Africa (FOSSFA), a group in which she played an active role.

In August of 2009 I was invited to an IT development conference (WITFOR) held in Hanoi, Vietnam. This was not my first time to Hanoi (the first was in 1995 and the second in 2005), but I was able to be active in the conference due to Dorothy's invitation to attend.  I showed the conference how to make live and installable special distributions on DVDs and USB flash drives.

I also learned to enjoy “Fresh Beer”, unique to Hanoi, while attending the conference.

LPI Exam Prep, LPI Learning, LPI Tutorial and Material, LPI Guides
At Dorothy’s invitation, I attended another IDLELO conference in Accra in 2010. I brought copies of Linux Pro Magazine, a book called “Internet Blackout” (a Hackerteen book written by my friend Marcelo Marques and donated by O'Reilly), and about 160 Hackerteen T-shirt    s of different sizes to give away to the attendees. The latter caused a lot of consternation getting through customs since I had no documentation on the cost of the shirts (they were given to me) or the price of the shirts (I was giving them away). We finally determined that the proper customs duty was one large T-shirt for the customs inspector and three more T-shirts in small and medium sizes for her children.

The conference was a great success, and I was impressed with what Dorothy was doing with the Centre of Excellence in ICT.

Dorothy had also brought in several other International speakers, including a gentleman from Thailand who was setting up Internet infrastructure in Thailand.   I learned a lot from John over “beer talk” and we exchanged stories about Free and Open Source Software, “telecenters,” and “small industry”.

It was also the trip that I traveled to “Cape Coast Castle” on the coast of Ghana and learned about its infamous part in the slave trade, a visit I will never, ever forget.

I had one more customs issue with that trip. Red Hat had sent 500 DVDs with Fedora on it, and had marked them as worth 500 US dollars, which generated a 250 USD customs duty. I went to the Post Office and managed to convince them that 400 DVDs (100 had “disappeared”) were really worth about five cents each and had “free software” on them, so the 400 remaining were worth about 20 USD.  I personally paid the 5 USD in customs duties.

Dorothy was impressed with my negotiating skills.

During her distinguished career, Dorothy has provided strategic and operational leadership to diverse consulting teams for major consulting assignments, including disaster preparedness and post-crisis training for specialized teams in the Economic Community of West African States (ECOWAS). She gave support to e-government initiatives in health, education, agriculture and public service reform, and provided training on open source solutions for development as a tool for growth and business creation in Sub-Saharan Africa.

She has continued to focus on these topics while she demonstrated technology leadership through the introduction of emerging technologies and related new training products and methodologies, including high performance computing (HPC); cognitive computing; data analytics and Big Data; 3D printing; IPv6 labs; mobile application innovation; cloud solutions; financial technology ; cybersecurity; and strategic use of licensing regimes including Creative Commons and the GPL.

Dorothy formulated strong partnerships in development with leading global IT companies such as Google, IBM, Oracle, and several major companies in Ghana, as well as the start-up community. She has received multiple awards for her work from civic groups.

AITI is a model for best practices for India's IT diplomacy and South-South cooperation. The Centre has inspired the establishment of many similar Centres globally.

Dorothy is on the Advisory council of Creative Commons Global and continues to support FOSSFA. She has degrees from the University of Ghana and the University of Sussex - Institute of Development Studies.

Dorothy continues to be one of my main linkages with the continent of Africa, and I am happy and proud to have her on the Board of Directors.

Source: lpi.org

Tuesday, 15 September 2020

The Unix compress command

Unix compress command, LPI Tutorial and Material, LPI Exam Prep, LPI Guides

The Unix compress command is rarely used any more, and has largely been replaced by the Unix/Linux gzip and bzip2 commands. However, on some Unix systems the compress command is still used, so for them, here are a few examples of how to use it.

Unix compress command examples


The following command will compress the file named foo.tar into a new file named foo.tar.Z:

compress foo.tar

This command compresses the file named foo.tar, and replaces it will a file named foo.tar.Z. (Very important note: Your original foo.tar file will no longer exist.)

You can also use the -v argument to get more output information during the file compression process, like this:

compress -v foo.tar

This compress command works just like the previous example, but gives more verbose output during the compression process. This is useful if you like to see the compression ratio you're getting with this utility.

Saturday, 12 September 2020

Zigging while others are zagging

These days, at least in the US, it’s common for airline safety announcement to conclude with something like, “We know you have a choice of carriers and we appreciate that you chose us today”. It’s a nice sentiment, but it would be great if that message wasn’t so often undermined by the usually miserable experience of getting on the plane.

LPI Certifications, LPI Learning, LPI Tutorials and Material, LPI Study Materials

I’m mindful of that message, though, as I look at the current landscape of IT certification in which LPI resides. Someone looking  for a career in information technology, and specifically open source technology, has an abundance of choices. Some of these choices drew their inspiration from us and a few even started out as LPI partners.

It’s only natural that LPI’s global success has attracted the eye of some who see certification as a path to revenue. Indeed, for many IT programs the certification exams themselves may not be highly income-producing, but the official courses and training materials certainly are. Other programs also apply marketing strategy invented by Novell (the deceased spiritual leader of most IT certifications). Under the Novell strategy, certification itself may not be profitable, but its promotion of vendor lock-in (or at least vendor bias) more than compensates. After all, once you’re hired and able to influence a purchase decision you would very likely stick with the products in which you were certified.

These tactics certainly work for many certification programs, but they’re not ours. In fact, LPI was, from the very beginning, an attempt to disrupt conventional IT certification much as open source software development has been disrupting the IT market.

For starters, we intended to disrupt the use of certification as a path to vendor lock-in. From the very start, LPI has been adamantly neutral towards specific distributions, or other elements of Linux diversity. In the beginning, we actually had a choice of exams for LPIC-1 depending on whether you wanted to be tested using the Red Hat “rpm” or Debian “deb” systems for software installation and upgrade management. (We’ve since figured out how to merge them into a single exam that tests both but doesn’t penalize you for knowing only one.) Recently we have started to implement the BSD certification exam so our support for open source diversity extends not only to Linux distributions but to the operating systems themselves.

This striving for neutrality extends to training methods as well. LPI has never had, and will not have by policy, a single “approved” training path. Our global network of partners assists those who need support through various means. As well, we provide a full and detailed list of objectives for each exam for the benefit of those who choose self-study. Traditionally, LPI never became involved in developing learning materials, but has done so recently at the request of our community, to support our academic partners that need something they can work with. These materials, which will soon call learning.lpi.org their home, will be made freely available to all.

The other thing that separates LPI is our desire to make our programs more accessible. While the trend has been to gradually increase prices for certification exams, LPI is actively looking at ways to reduce them. For us, the end goal is maximizing the open source talent pool rather than maximizing revenue. Our short-term accessibility effort takes the form of lower pricing in developing economies, and even lower pricing when we are able to do classroom-type “exam labs” at events around the world. Yes, this means resorting to pencils and paper forms in some instances, but consider that this way -- for now -- enables us to minimize the expense and thus the price. Going forward we are actively engaging in R&D to lower the cost to take exams even further; exciting and innovative results lie ahead.

And then there’s the new LPI membership program coming this year. Members will be able to participate in the governance of LPI, while using professional development activity (rather that just retaking exams) to maintain active status. In this respect, LPI is going to evolve into a body that more resembles a lawyer’s association or engineering society rather than a conventional IT certification. The certified professionals will have a voice in the direction of the body that sets their skills standards.

I think that what all this points to is the reality that LPI is cut from a different cloth than that used by most other IT certifications, even the other nonprofits. Consider LPI’s recently-refined mission statement:

“LPI exists to advance the use of open source software by elevating the people who work with it.”

That statement doesn’t even mention certification, because that’s not what we are at our core.

To us, certification is a means to an end -- more people finding and succeeding in open source careers -- rather than the end in itself. That perspective guides us to make different choices in strategy and tactics. We are not primarily concerned with selling as many certifications as possible to the exclusion of any greater social goal.

Read More: LPI Certifications

I’m looking forward to LPI’s coming years of membership, making our exams more affordable, and continuing to advocate for the use of open source in business, government, NGOs, and other non-profit organisations. This is a clearly a different direction than the certification mainstream, and one that I’m proud to be part of. To all the hundreds of thousands who have worked with LPI and entrusted us to help support your careers in open source, I know you had a choice and sincerely thank you for choosing LPI. Going forward, we will continue to earn that trust, helping our old friends, and making new ones along the way.

Thursday, 10 September 2020

uniq Command in LINUX with examples

Uniq Command, Linux Study Material, Linux Exam Prep, Linux Tutorial and Material, LPI Certification

The uniq command in Linux is a command line utility that reports or filters out the repeated lines in a file.

In simple words, uniq is the tool that helps to detect the adjacent duplicate lines and also deletes the duplicate lines. uniq filters out the adjacent matching lines from the input file(that is required as an argument) and writes the filtered data to the output file.

Syntax of uniq Command :


 //...syntax of uniq...// 
$uniq [OPTION] [INPUT[OUTPUT]]

The syntax of this is quite easy to understand. Here, INPUT refers to the input file in which repeated lines need to be filtered out and if INPUT isn’t specified then uniq reads from the standard input. OUTPUT refers to the output file in which you can store the filtered output generated by uniq command and as in case of INPUT if OUTPUT isn’t specified then uniq writes to the standard output.

Now, let’s understand the use of this with the help of an example. Suppose you have a text file named kt.txt which contains repeated lines that needs to be omitted. This can simply be done with uniq.

//displaying contents of kt.txt//

$cat kt.txt
I love music.
I love music.
I love music.

I love music of Kartik.
I love music of Kartik.

Thanks.

Now, as we can see that the above file contains multiple duplicate lines. Now, lets’s use uniq command to remove them:

//...using uniq command.../

$uniq kt.txt
I love music.

I love music of Kartik.

Thanks.

/* with the use of uniq all
the repeated lines are removed*/

As you can see that we just used the name of input file in the above uniq example and as we didn’t use any output file to store the produced output, the uniq command displayed the filtered output on the standard output with all the duplicate lines removed.

Note: uniq isn’t able to detect the duplicate lines unless they are adjacent. The content in the file must be therefore sorted before using uniq or you can simply use sort -u instead f uniq.

Options For uniq Command:


1. -c – -count : It tells how many times a line was repeated by displaying a number as a prefix with the line.

2. -d – -repeated : It only prints the repeated lines and not the lines which aren’t repeated.

3. -D – -all-repeated[=METHOD] : It prints all duplicate lines and METHOD can be any of the following:

◉ none : Do not delimit duplicate lines at all. This is the default.

◉ prepend : Insert a blank line before each set of duplicated lines.

◉ separate : Insert a blank line between each set of duplicated lines.

4. -f N – -skip-fields(N) : It allows you to skip N fields(a field is a group of characters, delimited by whitespace) of a line before determining uniqueness of a line.

5. -i – -ignore case : By default, comparisons done are case sensitive but with this option case insensitive comparisons can be made.

6. -s N – -skip-chars(N) : It doesn’t compares the first N characters of each line while determining uniqueness. This is like the -f option, but it skips individual characters rather than fields.

7. -u – -unique : It allows you to print only unique lines.

8. -z – -zero-terminated : It will make a line end with 0 byte(NULL), instead of a newline.

9. -w N – -check-chars(N) : It only compares N characters in a line.

10. – – help : It displays a help message and exit.

11. – – version : It displays version information and exit.

Examples of uniq with Options


1. Using -c option: It tells the number of times a line was repeated.

//using uniq with -c//

$uniq -c kt.txt
3 I love music.
1
2 I love music of Kartik.
1
1 Thanks.

/*at the starting of each 
line its repeated number is
displayed*/

2. Using -d option : It only prints the repeated lines.

//using uniq with -d//

$uniq -d kt.txt
I love music.
I love music of Kartik.

/*it only displayed one
 duplicate line per group*/

3. Using -D option: It also prints only duplicate lines but not one per group.

//using -D option//

$uniq -D kt.txt
I love music.
I love music.
I love music.
I love music of Kartik.
I love music of Kartik.

/* all the duplicate lines 
are displayed*/

4. Using -u option: It prints only the unique lines.

//using -u option//

$uniq -u kt.txt
Thanks.

/*only unique lines are
displayed*/

5. Using -f N option: As told above, this allows the N fields to be skipped while comparing uniqueness of the lines. This option is helpful when the lines are numbered as shown in the example below:

//displaying contents of f1.txt//

$cat f1.txt
1. I love music.
2. I love music.
3. I love music of Kartik.
4. I love music of Kartik.

//now using uniq with -f N option//

$uniq -f 2 f1.txt
1. I love music.
3. I love music of Kartik.

/*2 is used cause we needed to
compare the lines after the
numbering 1,2.. and after dots*/

6. Using -s N option: This is similar to -f N option but it skips N characters but not N fields.

//displaying content of f2.txt//

$cat f2.txt
#%@I love music.
^&(I love music.
*-!@thanks.
#%@!thanks.

//now using -s N option//

$uniq -s 3 f2.txt
#%@I love music.
*-!@thanks.
#%@!thanks.

/*lines same after skipping
3 characters are filtered*/

7. Using -w option: Similar to the way of skipping characters, we can also ask uniq to limit the comparison to a set number of characters. For this, -w command line option is used.

//displaying content of f3.txt//

$cat f3.txt
How it is possible?
How it can be done?
How to use it?

//now using -w option//

$uniq -w 3 f3.txt
How

/*as the first 3 characters
of all the 3 lines are same
that's why uniq treated all these
as duplicates and gave output 
accordingly*/

8. Using -i option: It is used to make the comparison case-insensitive.

//displaying contents of f4.txt//

$cat f4.txt
I LOVE MUSIC
i love music
THANKS

//using uniq command//
$uniq f4.txt
I LOVE MUSIC
i love music
THANKS

/*the lines aren't treated
as duplicates with simple 
use of uniq*/

//now using -i option//

$uniq -i f4.txt
I LOVE MUSIC
THANKS

/*now second line is removed
when -i option is used*/

9. Using -z option: By default, the output uniq produces is newline terminated. However, if you want, you want to have a NULL terminated output instead (useful while dealing with uniq in scripts). This can be made possible using the -z command line option.

Syntax:

//syntax of using uniq
with -z option//

$uniq -z file-name

Tuesday, 8 September 2020

tar gzip example - How to work with files that are tar'd and gzip'd

LPI tar gzip, LPI Exam Prep, LPI Tutorial and Material, LPI Cert Exam, LPI Certifications

tar gzip FAQ: How do I work with tar archives that have been created with tar and gzip?


When you work on Unix, Linux, and Mac OS X systems, you'll quickly find that tools like tar and gzip are your good friends, so learning how to work with them is very important. Here's a quick look at how to work with the most common tar/gzip scenarios.

1) Create a tar'd and gzip'd archive of a directory


A lot of times you'll have a directory that you want to either (a) make a backup copy of, or (b) share with other people. The most common way to do that these days is to create an archive that is "tar'd and gzip'd".

Here's how you create a tar'd and gzip'd archive of a directory (i.e., a "tar tgz" file) in your current folder named mydirectory:

tar czvf mydirectory.tgz mydirectory

A few quick notes about this tar/gzip example:

1. I've included four options with the tar command:

      1. c - create a new archive.
      2. z - gzip'd the archive.
      3. v - work verbosely, showing me the name of each file you add. This is optional.
      4. f - specifies that you want to use the following filename (mydirectory.tgz) as the name of the archive.

2. When creating an archive that has been tar'd and gzip'd, this is considered a "tar tgz" file, so it's common practice to end your filename with the extension tgz (though you can call it whatever you want).

2) Extract the contents of a tar/gzip (tar tgz) archive


Now imagine that you have just received a tar/gzip archive like this from someone else. To extract the contents of the archive issue a very similar command, this time using an x (for "eXtract") instead of the c argument, like this:

tar xzvf mydirectory.tgz

This command extracts whatever was in that tar'd and gzip'd archive to your filesystem.

3) List the contents of a tar/gzip archive


If that previous command sounded scary, maybe it should be. If this is an archive you just received from someone else, you may want to look at its contents before just extracting it to your filesystem.

Fortunately you can list the contents of an archive very easily, using the t option ("lisT") instead of the x argument, like this:

tar tzvf mydirectory.tgz

This command lists the contents of the archive, but does not extract the files in the archive to your filesystem.

4) How to gzip an existing tar file


As you work in the Unix world you'll also run into files named with a "tar.gz" extension, like this:

foo.tar.gz

When you see this ".tar.gz" file extension, it indicates that the file has probably been tar'd first, and then gzip'd second. This is a two-step process -- and the way I used to do this -- that works like this:

# step 1
tar cvf mydirectory.tar mydirectory

# step 2
gzip mydirectory.tar

As a practical matter you can treat a tar.gz file just like a tgz file, and extract its contents using the same command that was shown earlier:

tar xzvf mydirectory.tar.gz

Once I learned that I could tar and gzip a file with one command I stopped using this two-step process, but again, either way will work.

Thursday, 3 September 2020

LPI: Perl printing examples

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

Perl printing FAQ: Can you share some Perl printing examples?

There are several different ways to print in Perl, and I thought I'd share some examples here today.

The Perl print function


Generally you'll print simple output with the Perl print function. As a simple example, you can print a string literal using the Perl print function, like this:

print "Hello, world.\n";

Also Read: LPI Certifications


Notice that you need to supply the newline character at the end of your string. If you don't supply that newline character, and print multiple lines, they'll all end up on one long line of output, like this:

Hello, world.Hello, world.Hello, world.

So, when using the Perl print function, don't forget the newline character at the end of the string you're printing.

Printing Perl variables with print


In any real-world Perl script you'll need to print the value of your Perl variables. To print a variable as part of a a string, just use the Perl printing syntax as shown in this example:

$name = 'LPICentral';
print "Hello, world, from $name.\n";

When you run this Perl script, you'll see the following output:

Hello, world, from LPICentral.

Perl does the work of replacing the variable $name with the value of that variable, LPICentral.

Perl printing - Double and single quotes


One important thing to note in this example is the use of double quotes with that Perl print statement. In Perl, when you place a variable inside of double quotes, Perl can replace the value of the variable name. This is called "variable interpolation", and it works when you use double quotes, but it does not work when you use single quotes.

The Perl print function is essentially blind to anything you place inside single quotes, and will just print whatever you put in between single quotes without giving it a second thought. For example, if you try that same Perl print statement with single quotes, like this:

# this won't work as desired:
print 'Hello, world, from $name.\n';

In this example, Perl can't see inside the single quotes, so it can't replace $name with LPICentral, and it ends up printing $name instead, as shown here:

Hello, world, from $name\n

I forgot to mention the \n character, but as you can see in that output, when you use single quotes, the Perl print function also can't see the \n character, so it just prints the two characters \ and n, instead of actually seeing that character and printing a newline character in its place.

Perl printing - Other ways to print Perl variables


I could have also printed that previous example as shown here:

$name = 'LPICentral';
print "Hello, world, from " . $name . ".\n";

The result is the same, but I don't care for this Perl printing approach very much. For me, it's much harder to read, especially when you need to print more than one variable at a time.

Tuesday, 1 September 2020

The Linux wc command (word count)

Linux WC Command, Linux Exam Prep, LPI Certification, LPI Learning, LPI Guides, LPI Study Material

The Linux word count command is named wc. The wc command counts the number of characters, words, and lines that are contained in a text stream. If that sounds simple or boring, it's anything but; the wc command can be used in Linux command pipelines to do all sorts of interesting things.

Also Read: LPI Certifications

Let's take a look at some Linux wc command examples to show the power of this terrific little command.

Linux wc command examples (words, lines, characters)


In its most basic use, the wc command can be used to count the number of lines, words, and characters in a file, like this:

$ wc /etc/passwd
      65     185    3667 /etc/passwd

In that example, the /etc/passwd file has 65 lines, 185 words (as wc determines words), and 3,667 characters.

If you just want to know the number of lines in a file just add the -l argument, like this:

$ wc -l /etc/passwd
      65 /etc/passwd

Or, if you want to know the number of words in a file, add the -w argument, like this:

$ wc -w MyStory.txt
     185 MyStory.txt

Using the Linux wc command in command pipelines


The wc command follows the paradigm of reading input from STDIN and writing output to STDOUT, so it can be used in all sorts of Linux command pipelines. This command shows the number of users currently logged into your Linux system:

who | wc -l

It does that by piping the output of the who command into the input of the wc command, which in this case is used to count the number of lines of output in the who command.

Similarly, this next command shows the number of processes currently running on your Linux system:

ps -e | wc -l

This works the same way as the previous example: Generate output using one command (the ps command), and use the wc -l command to count the number of lines of output from that command.