Thursday 30 May 2019

LPIC-1: System Administrator

LPIC-1 is the first certification in LPI’s multi-level Linux professional certification program. The LPIC-1 will validate the candidate's ability to perform maintenance tasks on the command line, install and configure a computer running Linux and configure basic networking.

LPIC-1: System Administrator, LPIC-1 Certifications, LPI Study Materials, LPI Learning

The LPIC-1 is designed to reflect current research and validate a candidate's proficiency in real world system administration. The objectives are tied to real-world job skills, which we determine through job task analysis surveying during exam development.

Current Version: 5.0 (Exam codes 101-500 and 102-500)

Prerequisites: There are no prerequisites for this certification

Requirements: Passing exams 101 and 102

Validity Period: 5 years

Languages: English and German

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.

Exam 101 Topics


◈ System Architecture

◈ Linux Installation and Package Management

◈ GNU and Unix Commands

◈ Devices, Linux Filesystems, Filesystem Hierarchy Standard

LPIC-1 Exam 101 Objectives Version 4.0

Exam 102 Topics


◈ Shells, Scripting and Data Management

◈ Interfaces and Desktops

◈ Administrative Tasks

◈ Essential System Services

◈ Networking Fundamentals

◈ Security

LPIC-1 Exam 102 Objectives Version 4.0

Tuesday 28 May 2019

Linux Professional Institute DevOps Tools Engineer

Businesses across the globe are increasingly implementing DevOps practices to optimize daily systems administration and software development tasks. As a result, businesses across industries are hiring IT professionals that can effectively apply DevOps to reduce delivery time and and improve quality in the development of new software products.

DevOps Tools Engineer, LPI Study Materials, LPI Guides, LPI Tutorials and Materials

To meet this growing need for qualified professionals, LPI developed the Linux Professional Institute DevOps Tools Engineer certification which verifies the skills needed to use the tools that enhance collaboration in workflows throughout system administration and software development.

In developing the Linux Professional Institute DevOps Tools Engineer certification, LPI reviewed the DevOps tools landscape and defined a set of essential skills when applying DevOps. As such, the certification exam focuses on the practical skills required to work successfully in a DevOps environment -- focusing on the skills needed to use the most prominent DevOps tools. The result is a certification that covers the intersection between development and operations, making it relevant for all IT professionals working in the field of DevOps.

Current Version: 1.0 (Exam code 701-100)

Prerequisites: There are no prerequisites for this certification.

Requirements: Pass the Linux Professional Institute DevOps Tools Engineer exam. The 90-minute exam consists of 60 multiple choice and fill-in-the-blank questions.

Validity Period: 5 years

Languages: English

To receive the Linux Professional Institute DevOps Tools Engineer Certification the candidate must:

◈ Have a working knowledge of DevOps-related domains such as Software Engineering and Architecture, Container and Machine Deployment, Configuration Management and Monitoring.

◈ Have proficiency in prominent free and open source utilities such as Docker, Vagrant, Ansible, Puppet, Git, and Jenkins.

Skills in DevOps Tools Enhance Many Job Roles such as:


Developers

Front End Web Developer

Back End Web Developer

Java Developer

Python Developer

PHP Developer

Mobile Developer

SQL Database Developer

Embedded Systems Engineer/Developer

System Administrators

Cloud Architect

Database Administrator

Big Data Architect

Network or Server Virtualization Specialist

Systems Analyst

Engineers

Development Team Lead

Operations Team Lead

Quality Assurance/Quality Control Specialist

Cloud Architect

Software Architect

Microsoft Systems Engineer

Network Administrator

Information Security Specialist

DevOps Tools Engineer Certification holders validate that they:


DevOps Tools Engineer, LPI Study Materials, LPI Guides, LPI Tutorials and Materials
Have a working understanding of:

◈ Modern software applications and cloud services
◈ How tools support DevOps collaboration

Can apply their knowledge to:

DevOps Tools Engineer, LPI Study Materials, LPI Guides, LPI Tutorials and Materials
◈ Set up Continuous Integration and Continuous Delivery pipelines
◈ Build, deploy and orchestrate application containers
◈ Automate system configuration
◈ Build system images and run them locally and in the cloud
◈ Monitor applications and computing instances
DevOps Tools Engineer, LPI Study Materials, LPI Guides, LPI Tutorials and Materials
◈ Manage, collect and analyze log data
◈ Use Source Code Management and Version Control

Exam 701 Topics

◈ Software Engineering
◈ Container Management
◈ Machine Deployment
◈ Configuration Management
◈ Service Operations

Detailed Exam 701 Objectives

Saturday 25 May 2019

Linux Essentials: Overview

Linux adoption continues to rise world-wide as individual users, government entities and industries ranging from automotive to space exploration embrace open source technologies. This expansion of open source in enterprise is redefining traditional Information and Communication Technology (ICT) job roles to require more Linux skills. Whether you’re starting your career in Open Source, or looking for advancement, independently verifying your skill set can help you stand out to hiring managers or your management team.

Linux Essentials, LPI Study Materials, LPI Guides, LPI Learning, LPI Tutorials and Materials

The Linux Essentials Professional Development Certificate (PDC) is a great way to show employers that you have the foundational skills required for your next job or promotion. It also serves as an ideal stepping-stone to the more advanced LPIC Professional Certification track for Linux Systems Administrators.

The Linux Essentials Professional Development Certificate validates a demonstrated understanding of:

◈ FOSS, the various communities, and licenses
◈ knowledge of open source applications in the workplace as they relate to closed source equivalents
◈ basic concepts of hardware, processes, programs and the components of the Linux Operating System
◈ how to work on the command line and with files
◈ how to create and restore compressed backups and archives
◈ system security, users/groups and file permissions for public and private directories
◈ how to create and run simple scripts

Current Version: 1.6 (Exam code 010-160)

Prerequisites: There are no prerequisites for this certification

Requirements: Passing the Linux Essentials 010 exam

Validity Period: Lifetime

Languages: English, German and Dutch.

About Objective Weights: Each objective is assigned a weighting value. The weights range roughly from 1 to 10 and indicate the relative importance of each objective. Objectives with higher weights will be covered in the exam with more questions.

Linux Essentials Exam Topics


◈ The Linux community and a career in open source
◈ Finding your way on a Linux system
◈ The power of the command line
◈ The Linux operating system
◈ Security and file permissions

Detailed Linux Essentials Objectives Version 1.5

LPI Linux Essentials Test Center Portal


For the new Linux Essentials exam LPI is using a new method of internet-based testing (IBT) through accredited testing locations. This method of test delivery requires a computer lab, a proctor, and a secure browser. The IBT Linux Essentials testing solution is offered by LPI Inc.

Thursday 23 May 2019

Community Engagement. Looking back. Looking forward.

LPI Study Materials, LPI Certifications, LPI Certifications, Linux Certifications

During the military dictatorship in my country, Brazil, which lasted from 1964 until 1985, a cry by the students at the University of Sao Paulo became popular. At night, all the lights in the University would suddenly be turned off, so the students all cried: "Ninguém solta a mão de ninguém" (Nobody lets go of anyone's hand). So everyone would try to hold onto someone else's hand and, in the darkness, they tried to find a building column or any other place where they could hold. When the lights came on again, they would start calling for every colleague by their names, nicknames, or both. More than a few times, someone would not respond. After the results of our presidential election at the end of 2018, this cry became popular again, mostly thanks to social media and a tattoo design by the Brazilian artist, Thereza Nardelli.

LPI Study Materials, LPI Certifications, LPI Certifications, Linux Certifications
In the place where I live, there is a community of entrepreneurs called Taquari Valley. Yes, we do use the word "Valley" in English and "Taquari" is the river that crosses 40 small cities with a total of roughly 300 thousand inhabitants. This brings us the old saying "Think globally. Act locally," sometimes reversed to "Think locally. Act globally." This community wishes to learn about what works the world over in terms of generating businesses, employment, income, and reducing poverty, and from that information, decide what can be applied locally. They also try to return to the world what they believe are good local, potentially global businesses and ideas. In early April, 2019, we all got together in a coworking place to see a series of talks organized by Day 1 Endeavour (https://day1.endeavor.org.br/) and talked among ourselves about the entrepreneurship cases and ideas presented.

Now, what does "Nobody lets go of anyone's hand" and "Taquari Valley" have in common? Communities are born and thrive when people are in danger and need to protect themselves, but also when they consciously want to better their lives. And better lives are also lives better protected. Thus the need for strong communities.

It also helps to strengthen communities when there is a need to fight identifiable threats in order to really survive and thrive. These threats include some physical, being starved to death, being tortured, or killed, as well as some social, such as losing your job, personal rights, or freedom. However, when threats are mitigated, the communities built around them tend to weaken, sometimes allowing an environment for the same -- or similar -- threats to reappear. So we need stories reminding us of the dangers of weak communities the same way we need stories envisioning a common future for people within the local communities, or communities within a global village. We need stories we can act upon in the present, learn from in the past, and stories to build a better future. Stories to help us live long and prosper.

At times, it seems impossible for a single individual and even a single community to survive and thrive. There is a need for themes, as well as phased and coordinated approaches. As individuals we are naturally part of several different communities independent of our awareness. Our brains are built in ways that make us curious. We also seek pleasure and so we invent ways to satisfy our curiosity and get pleasure. Some will say curiosity is fed by the seeking of pleasure and some will say curiosity is already a pleasure satisfied by its findings. For me they say the same thing. Pleasure and curiosity are both parts of what makes us alive. It will likely take quite a long time to build a machine that will work to have pleasure by satisfying its curiosity. As a community of communities in a global village, we will build machines that will provide everything else.

I mentioned phased, themed, and coordinated approaches related to communities, so let's talk about the community that will build machines providing "everything else". There are definitely not enough people in this community. Even considering the enormous amount of people jumping into the Science and Technology wagon there is just a few who can turn a city into a self cleaning, energy independent one, and here is an example of a community inside the big community building a machine that will provide everything else.

There are not enough people building a complete feeding chain that will drive transportation to a minimum, allowing the consumption of fresh, healthy produce at a zero or close to zero cost, while at the same time preserving natural resources.

There are not enough people working on clean methods of transportation, and also allowing people to live and work with lesser need for transportation in the first place. Other than for exercising their need for pleasure and curiosity. Of course.

There are definitely not enough people thinking about how to educate and develop the professionals who will be able to think and produce all the things needed by the several communities working on building the machines that will provide everything else. We are absolutely out of sync here. In order to develop these professionals, we need to understand that they will not be ready or productive (in the way we define productivity today) when they graduate. Communities (or the so called Society) will need to invest in their formation for a longer time. Thus, in economic terms, it makes no sense that money is a barrier to knowledge. Fortunately, we have visionaries (Elon Musk, being one example) who understand that knowledge must be open and free, if we want to build a better world.

I work with LPI, the Linux Professional Institute, whose mission is to promote the use of open source and free technologies by elevating the people who work with it. Elevating the people who work with it to the level where they will be able to contribute to the communities building those machines that will provide everything else. Of course, as a community by itself, LPI is sustained by creating and providing certifications in Linux and other open source technologies. To help prepare professionals who will work in an uncertain future, we are continually developing and updating our certification programs so we can keep up with our mission while sustaining ourselves.

Community engagement is embedded in the root of our mission. We cannot elevate people without engaging people. Sometimes, you will see us going deep into very technical issues and, in the same event, having a group teaching how to do artwork or even produce beer, telling the participants all of this is free knowledge they can use to produce their own, with the added bonus that it may give them pleasure or entice their curiosity.

Technology can make our future a bright one if we are able to have enough engaged, bright, and committed people working within communities to build this future. At the same time, young people (and their parents) are quite uncertain of what kind of profession or form of income will be available in the future. This is a wonderful time to bring whole families into events where we are talking about free technologies, free knowledge, and the future. A workshop on kites, for instance, will easily illustrate that kites came before planes, which came before the spaceships they will have a chance to help build or take a ride in. Inside this spaceship, there will probably be good holographic entertainment, and excellent food, all of it envisioned and provisioned by other curious communities in the global village.

Thursday 16 May 2019

Find Command in Unix and Linux Examples

Find Command, LPI Study Materials, LPI Certifications, LPI Learning

Find is one of the powerful utility of Unix (or Linux) used for searching the files in a directory hierarchy. The syntax of find command is

find [pathnames] [conditions]

Let see some practical exercises on using find command.

1. How to run the last executed find command?

!find

This will execute the last find command. It also displays the last find command executed along with the result on the terminal.

2. How to find for a file using name?

find -name "sum.java"
./bkp/sum.java
./sum.java

This will find all the files with name "sum.java" in the current directory and sub-directories.

3. How to find for files using name and ignoring case?

find -iname "sum.java"
./SUM.java
./bkp/sum.java
./sum.java

This will find all the files with name "sum.java" while ignoring the case in the current directory and sub-directories.

4. How to find for a file in the current directory only?

find -maxdepth 1 -name "sum.java"
./sum.java

This will find for the file "sum.java" in the current directory only

5. How to find for files containing a specific word in its name?

find -name "*java*"
./SUM.java
./bkp/sum.java
./sum.java
./multiply.java

It displayed all the files which have the word "java" in the filename

6. How to find for files in a specific directory?

find /etc -name "*java*"

This will look for the files in the /etc directory with "java" in the filename

7. How to find the files whose name are not "sum.java"?

find -not -name "sum.java"
.
./SUM.java
./bkp
./multiply.java

This is like inverting the match. It prints all the files except the given file "sum.java".

8. How to limit the file searches to specific directories?

find -name "sum.java"
./tmp/sum.java
./bkp/var/tmp/files/sum.java
./bkp/var/tmp/sum.java
./bkp/var/sum.java
./bkp/sum.java
./sum.java

You can see here the find command displayed all the files with name "sum.java" in the current directory and sub-directories.

a. How to print the files in the current directory and one level down to the current directory?

find -maxdepth 2 -name "sum.java"
./tmp/sum.java
./bkp/sum.java
./sum.java

b. How to print the files in the current directory and two levels down to the current directory?

find -maxdepth 3 -name "sum.java"
./tmp/sum.java
./bkp/var/sum.java
./bkp/sum.java
./sum.java

c. How to print the files in the subdirectories between level 1 and 4?

find -mindepth 2 -maxdepth 5 -name "sum.java"
./tmp/sum.java
./bkp/var/tmp/files/sum.java
./bkp/var/tmp/sum.java
./bkp/var/sum.java
./bkp/sum.java

9. How to find the empty files in a directory?

find . -maxdepth 1 -empty
./empty_file

10. How to find the largest file in the current directory and sub directories

find . -type f -exec ls -s {} \; | sort -n -r | head -1

The find command "find . -type f -exec ls -s {} \;" will list all the files along with the size of the file. Then the sort command will sort the files based on the size. The head command will pick only the first line from the output of sort.

11. How to find the smallest file in the current directory and sub directories

find . -type f -exec ls -s {} \; | sort -n -r | tail -1

Another method using find is

find . -type f -exec ls -s {} \; | sort -n  | head -1

12. How to find files based on the file type?

a. Finding socket files

find . -type s

b. Finding directories

find . -type d

c. Finding hidden directories

find -type d -name ".*"

d. Finding regular files

find . -type f

e. Finding hidden files

find . -type f -name ".*"

13. How to find files based on the size?

a. Finding files whose size is exactly 10M

find . -size 10M

b. Finding files larger than 10M size

find . -size +10M

c. Finding files smaller than 10M size

find . -size -10M

14. How to find the files which are modified after the modification of a give file.

find -newer "sum.java"

This will display all the files which are modified after the file "sum.java"

15. Display the files which are accessed after the modification of a give file.

find -anewer "sum.java"

16. Display the files which are changed after the modification of a give file.

find -cnewer "sum.java"

17. How to find the files based on the file permissions?

find . -perm 777

This will display the files which have read, write, and execute permissions. To know the permissions of files and directories use the command "ls -l".

18. Find the files which are modified within 30 minutes.

find . -mmin -30

19. Find the files which are modified within 1 day.

find . -mtime -1

20. How to find the files which are modified 30 minutes back

find . -not -mmin -30

21. How to find the files which are modified 1 day back.

find . -not -mtime -1

22. Print the files which are accessed within 1 hour.

find . -amin -60

23. Print the files which are accessed within 1 day.

find . -atime -1

24. Display the files which are changed within 2 hours.

find . -cmin -120

25. Display the files which are changed within 2 days.

find . -ctime -2

26. How to find the files which are created between two files.

find . -cnewer f1 -and ! -cnewer f2

So far we have just find the files and displayed on the terminal. Now we will see how to perform some operations on the files.

1. How to find the permissions of the files which contain the name "java"?

find -name "*java*"|xargs ls -l

Alternate method is

find -name "*java*" -exec ls -l {} \;

2. Find the files which have the name "java" in it and then display only the files which have "class" word in them?

find -name "*java*" -exec grep -H class {} \;

3. How to remove files which contain the name "java".

find -name "*java*" -exec rm -r {} \;

This will delete all the files which have the word “java" in the file name in the current directory and sub-directories.

Similarly you can apply other Unix commands on the files found using the find command. I will add more examples as and when i found.

Tuesday 14 May 2019

Linux/Unix Command: zcat

zcat Command, Linux Certifications, Linux Tutorials and Materials, Linux Guides, Linux Learning

Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modification times. (The default extension is -gz for VMS, z for MSDOS, OS/2 FAT, Windows NT FAT and Atari.) If no files are specified, or if a file name is "-", the standard input is compressed to the standard output. Gzip will only attempt to compress regular files. In particular, it will ignore symbolic links.

Name


◈ gzip, gunzip, zcat - compress or expand files

Synopsis


◈ gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ]
◈ gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ]
◈ zcat [ -fhLV ] [ name ... ] 

If the compressed file name is too long for its file system, gzip truncates it. Gzip attempts to truncate only the parts of the file name longer than 3 characters. (A part is delimited by dots.) If the name consists of small parts only, the longest parts are truncated. For example, if file names are limited to 14 characters, gzip.msdos.exe is compressed to gzi.msd.exe.gz. Names are not truncated on systems which do not have a limit on file name length.

By default, gzip keeps the original file name and timestamp in the compressed file. These are used when decompressing the file with the -N option. This is useful when the compressed file name was truncated or when the time stamp was not preserved after a file transfer.

Compressed files can be restored to their original form using gzip -d or gunzip or zcat. If the original name saved in the compressed file is not suitable for its file system, a new name is constructed from the original one to make it legal.

gunzip takes a list of files on its command line and replaces each file whose name ends with .gz, -gz, .z, -z, _z or .Z and which begins with the correct magic number with an uncompressed file without the original extension. gunzip also recognizes the special extensions .tgz and .taz as shorthands for .tar.gz and .tar.Z respectively. When compressing, gzip uses the .tgz extension if necessary instead of truncating a file with a .tar extension.

gunzip can currently decompress files created by gzip, zip, compress, compress -H or pack. The detection of the input format is automatic. When using the first two formats, gunzip checks a 32 bit CRC. For pack, gunzip checks the uncompressed length. The standard compress format was not designed to allow consistency checks. However, gunzip is sometimes able to detect a bad .Z file. If you get an error when uncompressing a .Z file, do not assume that the .Z file is correct simply because the standard uncompress does not complain. This generally means that the standarduncompress does not check its input, and happily generates garbage output. The SCO compress -H format (lzh compression method) does not include a CRC but also allows some consistency checks.

Files created by zip can be uncompressed by gzip only if they have a single member compressed with the 'deflation' method. This feature is only intended to help conversion of tar.zip files to the tar.gz format. To extract zip files with several members, use unzip instead of gunzip.

zcat is identical to gunzip -c. (On some systems, zcat may be installed as gzcat to preserve the original link to compress.) zcat uncompresses either a list of files on the command line or its standard input and writes the uncompressed data on standard output. zcat will uncompress files that have the correct magic number whether they have a .gz suffix or not.

Gzip uses the Lempel-Ziv algorithm used in zip and PKZIP. The amount of compression obtained depends on the size of the input and the distribution of common substrings. Typically, text such as source code or English is reduced by 60-70%. Compression is generally much better than that achieved by LZW (as used in compress), Huffman coding (as used in pack), or adaptive Huffman coding (compact).

Compression is always performed, even if the compressed file is slightly larger than the original. The worst case expansion is a few bytes for the gzip file header, plus 5 bytes every 32K block, or an expansion ratio of 0.015% for large files. Note that the actual number of used disk blocks almost never increases. gzip preserves the mode, ownership and timestamps of files when compressing or decompressing.

OPTIONS


-a --ascii

◈ Ascii text mode: convert end-of-lines using local conventions. This option is supported only on some non-Unix systems. For MSDOS, CR LF is converted to LF when compressing, and LF is converted to CR LF when decompressing.

-c --stdout --to-stdout

◈ Write output on standard output; keep original files unchanged. If there are several input files, the output consists of a sequence of independently compressed members. To obtain better compression, concatenate all input files before compressing them.

-d --decompress --uncompress

◈ Decompress.

-f --force

◈ Force compression or decompression even if the file has multiple links or the corresponding file already exists, or if the compressed data is read from or written to a terminal. If the input data is not in a format recognized by gzip, and if the option --stdout is also given, copy the input data without change to the standard ouput: let zcat behave as cat. If -f is not given, and when not running in the background, gzip prompts to verify whether an existing file should be overwritten.

-h --help

◈ Display a help screen and quit.

-l --list

For each compressed file, list the following fields:

◈ Compressed size: size of the compressed file
◈ Uncompressed size: size of the uncompressed file
◈ Ratio: compression ratio (0.0% if unknown)
◈ Uncompressed_name: name of the uncompressed file

The uncompressed size is given as -1 for files not in gzip format, such as compressed .Z files. To get the uncompressed size for such a file, you can use:

◈ zcat file.Z | wc -c

In combination with the --verbose option, the following fields are also displayed:

◈ method: compression method
◈ crc: the 32-bit CRC of the uncompressed data
◈ date & time: time stamp for the uncompressed file

The compression methods currently supported are deflate, compress, lzh (SCO compress -H) and pack. The crc is given as ffffffff for a file not in gzip format.

With --name, the uncompressed name, date and time are those stored within the compress file if present.

With --verbose, the size totals and compression ratio for all files is also displayed, unless some sizes are unknown. With --quiet, the title and totals lines are not displayed.

-L --license

◈ Display the gzip license and quit.

-n --no-name

◈ When compressing, do not save the original file name and time stamp by default. (The original name is always saved if the name had to be truncated.) When decompressing, do not restore the original file name if present (remove only the gzip suffix from the compressed file name) and do not restore the original time stamp if present (copy it from the compressed file). This option is the default when decompressing.

-N --name

◈ When compressing, always save the original file name and time stamp; this is the default. When decompressing, restore the original file name and time stamp if present. This option is useful on systems which have a limit on file name length or when the time stamp has been lost after a file transfer.

-q --quiet

◈ Suppress all warnings.

-r --recursive

◈ Travel the directory structure recursively. If any of the file names specified on the command line are directories, gzip will descend into the directory and compress all the files it finds there (or decompress them in the case of gunzip ).

-S .suf --suffix .suf

Use suffix .suf instead of .gz. Any suffix can be given, but suffixes other than .z and .gz should be avoided to avoid confusion when files are transferred to other systems. A null suffix forces gunzip to try decompression on all given files regardless of suffix, as in:

◈ gunzip -S "" *       (*.* for MSDOS)

Previous versions of gzip used the .z suffix. This was changed to avoid a conflict with pack(1).

-t --test

◈ Test. Check the compressed file integrity.

-v --verbose

◈ Verbose. Display the name and percentage reduction for each file compressed or decompressed.

-V --version

◈ Version. Display the version number and compilation options then quit.

-# --fast --best

◈ Regulate the speed of compression using the specified digit #, where -1 or --fast indicates the fastest compression method (less compression) and -9 or --best indicates the slowest compression method (best compression). The default compression level is -6 (that is, biased towards high compression at expense of speed).

Advanced Usage


Multiple compressed files can be concatenated. In this case, gunzip will extract all members at once. For example:

◈ gzip -c file1  > foo.gz
◈ gzip -c file2 >> foo.gz

Then

◈ gunzip -c foo

is equivalent to

◈ cat file1 file2

In case of damage to one member of a .gz file, other members can still be recovered (if the damaged member is removed). However, you can get better compression by compressing all members at once:

◈ cat file1 file2 | gzip > foo.gz

compresses better than

◈ gzip -c file1 file2 > foo.gz

If you want to recompress concatenated files to get better compression, do:

◈ gzip -cd old.gz | gzip > new.gz

If a compressed file consists of several members, the uncompressed size and CRC reported by the --list option applies to the last member only. If you need the uncompressed size for all members, you can use:

◈ gzip -cd file.gz | wc -c

If you wish to create a single archive file with multiple members so that members can later be extracted independently, use an archiver such as tar or zip. GNU tar supports the -z option to invoke gzip transparently. gzip is designed as a complement to tar, not as a replacement.

Saturday 11 May 2019

Uses of the "xargs" Command

xargs Command, Linux Command, LPI Study Materials, LPI Guides, LPI Certifications

The xargs command is typically used in a command line where the output of one command is passed on as input arguments to another command.

Saturday 4 May 2019

LPI Releases Updates to LPIC-1 and Linux Essentials Certifications

Linux Professional Institute (LPI) has released updated versions of its LPIC-1 and Linux Essentials certifications. The updated LPIC-1 program is version 5.0 and a Linux Essentials is updated to version 1.6.

LPI Certifications, Linux Essentials, LPIC-1 Certifications, LPI Tutorials and Materials

LPI’s certification objectives are regularly updated to reflect changes to the skills required by open source professionals today. The update process involves a public community consultation in which Linux experts from all around the world review and comment on the certification objectives. In preparation for this update, beta exam labs were held in 19 countries to receive feedback on the new exams.

The LPIC-1 update to version 5.0 was required because of recent changes in the configuration and deployment of Linux-based systems. ‘The coverage of systemd was significantly increased, as it became the major init system in the most commonly used Linux distributions,’ said Fabian Thorns, LPI’s Director of Certification Development. ‘Also, the networking topic was redesigned to separate concepts, configuration and troubleshooting. A new objective covers specialties of Linux in the cloud and in virtual machines’.

Linux Essentials receives a minor update to version 1.6. ‘Linux Essentials has proven to cover fundamental Linux knowledge well. The update adds new knowledge areas, such as the Raspberry Pi, which is an important platform to teach and learn Linux and general IT skills’, said Thorns.

Detailed objectives for the updated Linux Essentials and LPIC-1 are available on the LPI website. The LPI wiki provides summaries of the changes in Linux Essentials and LPIC-1. A series of postings coming to the LPI blog will provide an overview of the new exam content.

The updated exams were released on October 29th 2018 in English, German and Japanese. Additional languages, including Chinese, Dutch, French, Italian, Portuguese and Spanish will be added shortly after the release. The previous versions of the exams will be available until July 1st, 2019.

Thursday 2 May 2019

cp command in Linux with examples

CP Command, Linux Certifications, LPI Study Materials, LPI Guides

cp stands for copy. This command is used to copy files or group of files or directory. It creates an exact image of a file on a disk with different file name. cp command require at least two filenames in its arguments.

Syntax:


cp [OPTION] Source Destination
cp [OPTION] Source Directory
cp [OPTION] Source-1 Source-2 Source-3 Source-n Directory

First and second syntax is used to copy Source file to Destination file or Directory.
Third syntax is used to copy multiple Sources(files) to Directory.

cp command works on three principal modes of operation and these operations depend upon number and type of arguments passed in cp command :

1. Two file names : If the command contains two file names, then it copy the contents of 1st file to the 2nd file. If the 2nd file doesn’t exist, then first it creates one and content is copied to it. But if it existed then it is simply overwritten without any warning. So be careful when you choose destination file name.

cp Src_file Dest_file

Suppose there is a directory named lpicentral having a text file a.txt.

Example:

$ ls
a.txt

$ cp a.txt b.txt

$ ls
a.txt  b.txt

2. One or more arguments : If the command has one or more arguments, specifying file names and following those arguments, an argument specifying directory name then this command copies each source file to the destination directory with the same name, created if not existed but if already existed then it will be overwritten, so be careful !!.

cp Src_file1 Src_file2 Src_file3 Dest_directory

Suppose there is a directory named lpicentral having a text file a.txt, b.txt and a directory name new in which we are going to copy all files.

Example:

$ ls
a.txt  b.txt  new

Initially new is empty
$ ls new

$ cp a.txt b.txt new

$ ls new
a.txt  b.txt

Note: For this case last argument must be a directory name. For the above command to work, Dest_directory must exist because cp command won’t create it.

3. Two directory names : If the command contains two directory names, cp copies all files of the source directory to the destination directory, creating any files or directories needed. This mode of operation requires an additional option, typically R, to indicate the recursive copying of directories.

cp -R Src_directory Dest_directory

In the above command, cp behavior depend upon whether Dest_directory is exist or not. If the Dest_directory doesn’t exist, cp creates it and copies content of Src_directory recursively as it is. But if Dest_directory exists then copy of Src_directory becomes sub-directory under Dest_directory.

Options:


There are many options of cp command, here we will discuss some of the useful options:
Suppose a directory named lpicentral contains two files having some content named as a.txt and b.txt. This scenario is useful in understanding the following options.

$ ls lpicentral
a.txt  b.txt

$ cat a.txt
LPI

$ cat b.txt
LPICentral

1. -i(interactive): i stands for Interactive copying. With this option system first warns the user before overwriting the destination file. cp prompts for a response, if you press y then it overwrites the file and with any other option leave it uncopied.

$ cp -i a.txt b.txt
cp: overwrite 'b.txt'? y

$ cat b.txt
LPI

2. -b(backup): With this option cp command creates the backup of the destination file in the same folder with the different name and in different format.

$ ls
a.txt  b.txt

$ cp -b a.txt b.txt

$ ls
a.txt  b.txt  b.txt~

3. -f(force): If the system is unable to open destination file for writing operation because the user doesn’t have writing permission for this file then by using -f option with cp command, destination file is deleted first and then copying of content is done from source to destination file.

$ ls -l b.txt
-r-xr-xr-x+ 1 User User 3 Nov 24 08:45 b.txt

User, group and others doesn't have writing permission.

Without -f option, command not executed
$ cp a.txt b.txt
cp: cannot create regular file 'b.txt': Permission denied

With -f option, command executed successfully
$ cp -f a.txt b.txt

4. -r or -R: Copying directory structure. With this option cp command shows its recursive behavior by copying the entire directory structure recursively.
Suppose we want to copy lpicentral directory containing many files, directories into lpi directory(not exist).

$ ls lpicentral/
a.txt  b.txt  b.txt~  Folder1  Folder2

Without -r option, error
$ cp lpicentral lpi
cp: -r not specified; omitting directory 'lpicentral'

With -r, execute successfully
$ cp -r lpicentral lpi

$ ls lpi/
a.txt  b.txt  b.txt~  Folder1  Folder2

5. -p(preserve): With -p option cp preserves the following characteristics of each source file in the corresponding destination file: the time of the last data modification and the time of the last access, the ownership (only if it has permissions to do this), and the file permission-bits.

Note: For the preservation of characteristics you must be the root user of the system, otherwise characteristics changes.

$ ls -l a.txt
-rwxr-xr-x+ 1 User User 3 Nov 24 08:13 a.txt

$ cp -p a.txt c.txt

$ ls -l c.txt
-rwxr-xr-x+ 1 User User 3 Nov 24 08:13 c.txt

As we can see above both a.txt and c.txt(created by copying) have same characteristics.

Examples:


Copying using * wildcard: The star wildcard represents anything i.e. all files and directories. Suppose we have many text document in a directory and wants to copy it another directory, it takes lots of time if we copy files 1 by 1 or command becomes too long if specify all these file names as the argument, but by using * wildcard it becomes simple.

Initially Folder1 is empty
$ ls
a.txt  b.txt  c.txt  d.txt  e.txt  Folder1

$ cp *.txt Folder1

$ ls Folder1
a.txt  b.txt  c.txt  d.txt  e.txt