Saturday, 29 August 2020

Automatically Clean Unused Temporary files in Linux

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

How can I remove/clean unused files in Linux?. In this article, you will learn how to configure a timer that manages temporary files. In most Modern Linux systems, a large number of temporary files and directories are required for optimal processing. Accumulatively, they could consume gigabytes of storage space if not cleaned frequently. It is therefore necessary to purge the old files so that they do not fill up disk space.

Some users/applications will use the /tmp directory to hold temporary data, while others use a more task-specific location such as daemon and user-specific volatile directories under /run. Volatile means that the files only exist in memory. If the system is rebooted or when there is a lose of power, all the contents of volatile storage will be gone.

Automatically Clean Unused Temporary files in Linux


In Red Hat Enterprise Linux 7 and later, a new tool called systemd-tmpfiles is included. This tool provides a structured and configurable method to manage temporary directories and files.

You can check the services started with the command:

$ systemctl status  systemd-tmpfiles-*
● systemd-tmpfiles-setup.service - Create Volatile Files and Directories
   Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-setup.service; static; vendor preset: disabled)
   Active: active (exited) since Mon 2020-02-10 08:27:50 EAT; 1 weeks 3 days ago
     Docs: man:tmpfiles.d(5)
           man:systemd-tmpfiles(8)
  Process: 794 ExecStart=/usr/bin/systemd-tmpfiles --create --remove --boot --exclude-prefix=/dev (code=exited, status=0/SUCCESS)
 Main PID: 794 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/systemd-tmpfiles-setup.service

Feb 10 08:27:50 envoy-nginx.novalocal systemd[1]: Starting Create Volatile Files and Directories...
Feb 10 08:27:50 envoy-nginx.novalocal systemd[1]: Started Create Volatile Files and Directories.

● systemd-tmpfiles-setup-dev.service - Create Static Device Nodes in /dev
   Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-setup-dev.service; static; vendor preset: disabled)
   Active: active (exited) since Mon 2020-02-10 08:27:49 EAT; 1 weeks 3 days ago
     Docs: man:tmpfiles.d(5)
           man:systemd-tmpfiles(8)
  Process: 553 ExecStart=/usr/bin/systemd-tmpfiles --prefix=/dev --create --boot (code=exited, status=0/SUCCESS)
 Main PID: 553 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/systemd-tmpfiles-setup-dev.service

Feb 10 08:27:49 envoy-nginx.novalocal systemd[1]: Starting Create Static Device Nodes in /dev...
Feb 10 08:27:49 envoy-nginx.novalocal systemd[1]: Started Create Static Device Nodes in /dev.

When the systemd-tmpfiles-setup service unit is started, it runs the systemd-tmpfiles –create –remove command. The command checks for configuration files from:

◉ /usr/lib/tmpfiles.d/.conf
◉ /run/tmpfiles.d/.conf
◉ /etc/tmpfiles.d/*.conf

If there are files and directories marked for deletion in above configuration files, the’ll be removed. For the files and directories marked for creation, they are created with the correct permissions if necessary.

How Temporary Files are Cleaned with a Systemd Timer


A systemd timer unit called systemd-tmpfiles-clean.timer triggers the systemd-tmpfiles-clean.service on a regular interval, which then executes the systemd-tmpfiles –clean command.

You’ll specify how often the service should be started in the [Timer] section. See example below.

$ cat /usr/lib/systemd/system/systemd-tmpfiles-clean.timer
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Daily Cleanup of Temporary Directories
Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)

[Timer]
OnBootSec=15min
OnUnitActiveSec=1d

In above example, the systemd-tmpfiles-clean.service will be triggered 15 minutes after the system has booted up. Any other trigger happens 24 hours after the last service trigger. You can adjust the values to your liking.

If you make a change, ensure you reload service.

sudo systemctl daemon-reload
sudo systemctl enable --now systemd-tmpfiles-clean.timer

How To Manually Clean Temporary Files


Let’s configure systemd-tmpfiles to clean the /mytmp directory. This will ensure the directory does not contain files that that have not been used in the last 3 days.

You can copy the example configuration file and update it – /usr/lib/tmpfiles.d/tmp.conf

Edit the file like below.

$ sudo vim /etc/tmpfiles.d/mytmp.conf
See tmpfiles.d(5) for details
# Clear tmp directories separately, to make them easier to override
q /mytmp 1777 root root 3d

If you want to ensure a directoty exist with correct owneship, create a configuration like below.

d /run/mytmp 0700 root root 60s

Any file in this directory that remains unused in the last 60 seconds must be purged.

Once the file is created, use the following command to ensure the file contains the appropriate configuration.

sudo systemd-tmpfiles --create /etc/tmpfiles.d/mytmp.conf

If you don’t see any error in the output, then the it confirms that the configuration settings are correct. You can invoke a manual clean anytime with the command:

systemd-tmpfiles --clean /etc/tmpfiles.d/mytmp.conf

Thursday, 27 August 2020

Understanding the Landscape of Linux Certifications for Junior and Senior Systems Administrators

Linux Certifications, LPI Exam Prep, LPI Guides, LPI Learning, LPI Prep

Understanding the availability and viability of current Linux certifications for systems administrators can be a challenge. Because Linux is an open source project, no single company or organization can claim exclusive authority to validate the Linux skills of an IT professional. Intense competition has led to the arrival and departure of many certification programs through the years (here's looking at you SAIR, Novell, and Ubuntu). Some certifications have remained a staple in the marketplace and others are offering good alternatives. Here is a breakdown of certification organizations/companies and their offerings.

LPI - Linux Professional Institute


The Linux Professional Institute has its roots in the open source community as a non-profit certification organization. LPI's certifications have always been vendor neutral in nature. This is a blessing and a curse as LPI certified professionals will be well versed in the breadth of open source technologies that are not tied to any particular Linux distribution. The curse can be than an employer may need specific certification credentials based on vendor-mandated technologies. With an LPI certification, a professional will have the credentials for a generalized and versatile skill set that is not specific to a vendor. Look for the LPIC-1 certification for junior administrators and LPIC-2 for senior administrators. Each certification requires the completion of two exams and the exams can be completed at a Pearson Vue testing center.

LPI is known for a focus on system administrators. Recently the LPI certification portfolio has expanded into a new certification called DevOps Tools Engineer certification. This certification validates skills for use of tools in the workflow of systems administration and software development.

Linux Foundation


The new kid on the block for Linux certifications. The Linux Foundation has been a solid figure in the open source project space for many years. They host well over one hundred open source projects. Some of these projects are well known, including Kubernetes, Prometheus, NodeJS, Jenkins, and many other small and large projects. Arguably the most famous of projects they host is the development of the Linux kernel. This project is at the core of the Linux operating system.

The Linux Foundation has leveraged its long-standing relationship with the Linux kernel developers by offering to the public a unique catalog of certifications. Directly related to Linux systems administration are two certifications: the junior level certification is the LF Certified SysAdmin and the senior level is the LF Certified Linux Engineer. These are unique in the method used for the candidate to sit the exam. Unlike all the other vendors there is no need to go to a testing center, kiosk location, or classroom. The exams are administered online using a variety of tools and remote proctoring. Like the Red Hat exams, these exams are performance-based where candidates are faced with a simulation of real-world tasks and scenarios.

The online exam delivery format that the Linux Foundation has pioneered has been expended to other technologies in the open source space.  Be on the lookout for certifications related to Kubernetes, Cloud Foundry, and Hyperledger.

Red Hat


Although a for-profit corporation, Red Hat has been a big friend to the open source community. Red Hat has recently been acquired by IBM, which cements their quest to expand open source software into the enterprise. Their M.O. seems to be a precise ability to have a very healthy relationship with the open source community while profitably monetizing those technologies.

This respect can also be seen in Red Hat's IT certifications. They have maintained a respected status amongst industry experts, the rank-and-file systems administrators, and the open source community at large. Red Hat's exams are "performance-based." This term in Red Hat parlance requires the examinee to perform actual systems administration tasks on a working system. The completion of these tasks is then checked, validated, and scored.

Theoretical knowledge will only get you so far in a Red Hat exam. Arguably the most respected Linux certification is the RHCE – Red Hat Certified Engineer. The little brother RHCSA – Red Hat Certified Systems Administration is a prerequisite to receiving the RHCE. Taking Red Hat exams can be logistically challenging as candidates must locate, schedule, and travel to a limited number of kiosk and classroom locations. This logistical tension has made other certifications viable competitors.

CompTIA


An association of industry and IT professionals CompTIA is a juggernaut for IT and professional certifications. Up until this year CompTIA and LPI have partnered together to offer the Linux+. Now LPI and CompTIA have parted ways and CompTIA offers the Linux+ that is now *not* powered by LPI. This means that the reciprocal agreement is no longer in place. It used to be that if you received your CompTIA Linux+ powered by LPI then LPI would automatically give you the credentials for the LPIC-1 certification. Essentially the question bank for the two certifications exams were the same. Now they have diverged and CompTIA Linux+ is a different set of questions than the LPIC-1. CompTIA Linux+ is now just a one (1) exam test instead of two like the LPIC-1.

Other Less Popular Linux Certifications


You would think that with these four main players in the Linux certification space, this would be sufficient competition for the need. However, there are even more players and options for vendor-based certification. Here are a few:

◉ Oracle Certified Associate (OCA)
◉ Oracle Certified Professional (OCP)
◉ SUSE Certified Administrator (SCP)
◉ SUSE Certified Engineer (SCE)
◉ GCUX: GIAC Certified Unix Security Administrator

Junior and Senior Level Linux Certification Comparison


(listed in order of perceived popularity)

CERTIFICATION LEVEL  EXAM COST  EXAMINATION LOCATION
RHCE - Red Hat Certified Engineer Sr. Systems Administrator $400 Classroom, Kiosk
RHCSA – Red Hat Certified Systems Administrator  Jr. Systems Administrator  $400  Classroom, Kiosk
CompTIA Linux+  Jr. Systems Administrator  $319  Testing Center 
LPIC-1: Linux Professional Institute Certification Level 1  Jr. Systems Administrator  $200 x 2  Testing Center 
LPIC-2: Linux Professional Institute Certification Level 2  Sr. Systems Administrator  $200 x 2  Testing Center 
LFCS - Linux Foundation Certified SysAdmin  Jr. Systems Administrator  $300  Online 
LFCE - Linux Foundation Certified Engineer  Sr. Systems Administrator  $300  Online 
LPIC-2: Linux Professional Institute Certification Level 2  Sr. Systems Administrator  $200 x 2  Testing Center 

Tuesday, 25 August 2020

Counting Files and Directories in Linux

Directories in Linux, LPI Tutorials and Materials, LPI Exam, LPI Exam Prep, LPI Certification

Although at first counting files and directories in Linux may not seem the most exciting topic you will be surprised just how much you can learn from these tasks. They are also well suited to those starting out in Linux with one or two elements that may be new even to seasoned Linux users.

Firstly, if we want to be counting files and directories in Linux then ls may be a great option Used in conjunction with wc we can count the number of items returned. The command ls is used to list directory content and wc is used for word count, used with -l it can count lines.

$ ls | wc -l

Whilst this is good we will not show hidden files or directories. Hidden files start with a dot. To list these we can use the option -a or -A with ls. To show all files we use -a and almost all files with -A. Yes almost all, we exclude the . and .. directories which are system links.

[tux@packstack ~]$ ls
dir1  dir2  dir3  dir4

[tux@packstack ~]$ ls -a
.  ..  .bash_logout  .bash_profile  .bashrc  dir1  dir2  dir3  dir4

[tux@packstack ~]$ ls -A
.bash_logout  .bash_profile  .bashrc  dir1  dir2  dir3  dir4

[tux@packstack ~]$

If we want to count the output we are better not count the . and .. directory.

[tux@packstack ~]$ ls -A | wc -l
7

[tux@packstack ~]$

From the output we can see that we have a total of 7 items in the current directory.

If we want to count directories and files separetely then we can use the GNU command find. To list files we can use the option -type f. Of course we could count the output as before.

[tux@packstack ~]$ find . -type f
./.bash_logout
./.bash_profile
./.bashrc

Directories in Linux, LPI Tutorials and Materials, LPI Exam, LPI Exam Prep, LPI Certification
Listing directories is similar but we will see that we will include the current directory which we may not want.

[tux@packstack ~]$ find . -type d
.
./dir1
./dir2
./dir3
./dir4

To exclude the current directory from the count we can use the option -mindepth 1 to ensure that we start with the directories content and not the directory.[tux@packstack ~]$

find . -mindepth 1 -type d
./dir1
./dir2
./dir3
./dir4

So we can see that counting files and directories in Linux is not difficult but it can be even easier. Well at least counting directories. The hard link count for a directory can be used to show how many subdirectories there are in the directory. Each subdirectory has a link back to the parent. A directory start with a hard link count of 2 so just remove 2 from the current hard link count to see how many subdirectories.

[tux@packstack ~]$ ls -ld /etc
drwxr-xr-x. 112 root root 8192 Jun 8 15:03 /etc

The etc directory has 110 subdirectories on my system, 112 – 2 = 110

Saturday, 22 August 2020

A BIG collection of Unix/Linux ‘grep’ command examples

Grep Command, LPI Tutorial and Materials, LPI Exam Prep, LPI Certification, LPI Learning

Linux grep FAQ: Can you share some Linux/Unix grep command examples?

Sure. The name grep means "general regular expression parser", but you can think of the grep command as a “search” command for Unix and Linux systems: It’s used to search for text strings and regular expressions within one or more files.

I think it’s easiest to learn how to use the grep command by showing examples, so let’s dive right in.

.

.

.

this space intentionally left blank because of the long Table of Contents over there (and my poor CSS skills) -->

.

.

.

.

Abridged grep command examples


First up, if you don’t like reading a bunch of text and just want to see a collection of grep commands, this section is for you.

(If the Table of Contents over there on the right side is still in the way, click or tap the ‘hide’ link in its title to hide it):

search for a string in one or more files
----------------------------------------
grep 'fred' /etc/passwd              # search for lines containing 'fred' in /etc/passwd
grep fred /etc/passwd                # quotes usually not when you don't use regex patterns
grep null *.scala                    # search multiple files


case-insensitive
----------------
grep -i joe users.txt                # find joe, Joe, JOe, JOE, etc.


regular expressions
-------------------
grep '^fred' /etc/passwd             # find 'fred', but only at the start of a line
grep '[FG]oo' *                      # find Foo or Goo in all files in the current dir
grep '[0-9][0-9][0-9]' *             # find all lines in all files in the current dir with three numbers in a row


display matching filenames, not lines
-------------------------------------
grep -l StartInterval *.plist        # show all filenames containing the string 'StartInterval'
grep -il StartInterval *.plist       # same thing, case-insensitive


show matching line numbers
--------------------------
grep -n we gettysburg-address.txt    # show line numbers as well as the matching lines


lines before and after grep match
---------------------------------
grep -B5 "the living" gettysburg-address.txt        # show all matches, and five lines before each match
grep -A10 "the living" gettysburg-address.txt       # show all matches, and ten lines after each match
grep -B5 -A5 "the living" gettysburg-address.txt    # five lines before and ten lines after


reverse the meaning
-------------------
grep -v fred /etc/passwd             # find any line *not* containing 'fred'
grep -vi fred /etc/passwd            # same thing, case-insensitive


grep in a pipeline
------------------
ps auxwww | grep httpd               # all processes containing 'httpd'
ps auxwww | grep -i java             # all processes containing 'java', ignoring case
ls -al | grep '^d'                   # list all dirs in the current dir


search for multiple patterns
----------------------------
egrep 'apple|banana|orange' *                                                         # search for multiple patterns, all files in current dir
egrep -i 'apple|banana|orange' *                                                      # same thing, case-insensitive
egrep 'score|nation|liberty|equal' gettysburg-address.txt                             # all lines matching multiple patterns
locate -i calendar | grep Users | egrep -vi 'twiki|gif|shtml|drupal-7|java|PNG'       # oh yeah

multiple search strings, multiple filename patterns
---------------------------------------------------
grep -li "jtable" $(find . -name "*.java,v" -exec grep -li "prevayl" {} \;)           # find all files named "*.java,v" containing both
                                                                                      # 'prevayl' and 'jtable'

grep + find
-----------
find . -type f -exec grep -il 'foo' {} \;     # print all filenames of files under current dir containing 'foo', case-insensitive


recursive grep search
---------------------
grep -rl 'null' .                             # similar to the previous find command; does a recursive search
grep -ril 'null' /home/al/sarah /var/www      # search multiple dirs
egrep -ril 'aja|lpicentral' .                      # multiple patterns, recursive


grep gzip files
---------------
zgrep foo myfile.gz                           # all lines containing the pattern 'foo'
zgrep 'GET /blog' access_log.gz               # all lines containing 'GET /blog'
zgrep 'GET /blog' access_log.gz | more        # same thing, case-insensitive

That's the short version of the grep examples. The rest of this document describes many of these examples.

Searching for a text string in one file


This first grep command example searches for all occurrences of the text string 'fred' within the /etc/passwd file. It will find and display all of the lines in this file that contain the text string fred, including lines that contain usernames like "fred", and also other strings like "alfred":

grep 'fred' /etc/passwd

In a simple example like this, the quotes around the string fred aren't necessary, but they are needed if you're searching for a string that contains spaces, and will also be needed when you get into using regular expressions (search patterns).

Searching for a string in multiple files


Grep Command, LPI Tutorial and Materials, LPI Exam Prep, LPI Certification, LPI Learning
Our next grep command example searches for all occurrences of the text string joe within all files of the current directory:

grep 'joe' *

The '*' wildcard matches all files in the current directory, and the grep output from this command will show both (a) the matching filename and (b) all lines in all files that contain the string 'joe'.

As a quick note, instead of searching all file with the "*" wildcard, you can also use grep to search all files in the current directory that end in the file extension .txt, like this:

grep 'joe' *.txt


Case-insensitive file searching with the Unix grep command


To perform a case-insensitive search with the grep command, just add the -i option, like this:

grep -i score gettysburg-address.txt

This grep search example matches the string "score", whether it is uppercase (SCORE), lowercase (score), or any mix of the two (Score, SCore, etc.).

Reversing the meaning of a grep search


You can reverse the meaning of a Linux grep search with the -v option. For instance, to show all the lines of my /etc/passwd file that don't contain the string fred, I'd issue this command:

grep -v fred /etc/passwd


Using grep in a Unix/Linux command pipeline


The grep command is often used in a Unix/Linux pipeline. For instance, to show all the Apache httpd processes running on my Linux system, I use the grep command in a pipeline with the ps command:

ps auxwww | grep httpd

This returns the following output:

root     17937  0.0  0.0  14760  6880 ?        Ss   Apr01   0:39 /usr/local/apache/bin/httpd -k start
nobody   21538  0.0  0.0  24372 17108 ?        S    Apr03   0:01 /usr/local/apache/bin/httpd -k start
nobody   24481  0.0  0.0  14760  6396 ?        S    Apr03   0:00 /usr/local/apache/bin/httpd -k start
nobody   26089  0.0  0.0  24144 16876 ?        S    Apr03   0:01 /usr/local/apache/bin/httpd -k start
nobody   27842  0.0  0.0  24896 17636 ?        S    Apr03   0:00 /usr/local/apache/bin/httpd -k start
nobody   27843  0.0  0.0  24192 16936 ?        S    Apr03   0:00 /usr/local/apache/bin/httpd -k start
nobody   27911  0.0  0.0  23888 16648 ?        S    Apr03   0:01 /usr/local/apache/bin/httpd -k start
nobody   28280  0.0  0.0  24664 17256 ?        S    Apr03   0:00 /usr/local/apache/bin/httpd -k start
nobody   30404  0.0  0.0  24360 17112 ?        S    Apr03   0:00 /usr/local/apache/bin/httpd -k start
nobody   31895  0.0  0.0  14760  6296 ?        S    Apr03   0:00 /usr/local/apache/bin/httpd -k start
root     31939  0.0  0.0   1848   548 pts/0    R+   Apr03   0:00 grep http

(I deleted about half of the "httpd -k start" lines from that output manually to save a little space.)

Similarly, here's how you can find all the Java processes running on your system using the ps and grep commands in a Unix pipeline:

ps auxwww | grep -i java

In this example I've piped the output of the ps auxwww command into my grep command. The grep command only prints the lines that have the string "java" in them; all other lines from the ps command are not printed.

One way to find all the sub-directories in the current directory is to mix the Linux ls and grep commands together in a pipe, like this:

ls -al | grep '^d'

Here I'm using grep to list only those lines where the first character in the line is the letter d.

Using the Linux grep command to search for multiple patterns at one time (egrep)


You can use a different version of the grep command to search for multiple patterns at one time. To do this, just use the egrep command instead of grep, like this:

egrep 'score|nation|liberty|equal' gettysburg-address.txt

This Unix egrep command searches the file named gettysburg-address.txt for the four strings shown (score, nation, liberty, and equal). It returns any lines from the file that contain any of those words.

I should also note that "egrep" stands for "extended grep", and as you can see, it lets you do things like searching for multiple patterns at one time.

Searching for regular expressions (regex patterns) with grep


Of course the Linux grep command is much more powerful than this, and can handle very powerful regular expressions (regex patterns). In a simple example, suppose you want to search for the strings "Foo" or "Goo" in all files in the current directory. That grep command would be:

grep '[FG]oo' *

If you want to search for a sequence of three integers with grep you might use a command like this:

grep '[0-9][0-9][0-9]' *

This next grep command searches for all occurrences of the text string fred within the /etc/passwd file, but also requires that the "f" in the name "fred" be in the first column of each record (that's what the caret character tells grep). Using this more-advanced search, a user named "alfred" would not be matched, because the letter "a" will be in the first column:

grep '^fred' /etc/passwd

Regular expressions can get much, much more complicated (and powerful) than this, so I'll just leave it here for now.

Display only filenames with a grep search


If you're looking through a lot of files for a pattern, and you just want to find the names of the files that contain your pattern (or "patterns", as shown with egrep) -- but don't want to see each individual grep pattern match -- just add the -l (lowercase letter L) to your grep command, like this:

grep -l StartInterval *.plist

This command doesn't show every line in every file that contains the string "StartInterval"; it just shows the names of all the files that contain this string, like this:

com.apple.atrun.plist
com.apple.backupd-auto.plist
com.apple.dashboard.advisory.fetch.plist
com.apple.locationd.plist
org.amavis.amavisd_cleanup.plist

Of course you can also combine grep command arguments, so if you didn't happen to know how to capitalize "StartInterval" in that previous example, you could just add the -i argument to ignore case, like this:

grep -il startinterval *.plist

and that would have worked just fine as well, returning the same results as the previous grep command example.

Showing matching line numbers with Linux grep


To show the line numbers of the files that match your grep command, just add the -n option, like this:

grep -n we gettysburg-address.txt

Searching my sample gettysburg-address.txt file, I get the following output from this command:

9:Now we are engaged in a great civil war,
22:that we should do this.
24:But in a larger sense we can not dedicate -
25:we can not consecrate -
26:we can not hallow this ground.
29:have consecrated it far above our poor power
33:what we say here,
43:we take increased devotion to that cause
46:that we here highly resolve that these dead

grep before/after - Showing lines before or after your grep pattern match


After a recent comment, I just learned that you can display lines before or after your grep pattern match, which is also very cool. To display five lines before the phrase "the living" in my sample document, use the -B argument, like this:

grep -B 5 "the living" gettysburg-address.txt

This grep command example returns this output:

The world will little note,
nor long remember,
what we say here,
but can never forget what they did here.

It is for us, the living,

Similarly, to show the five lines after that same search phrase, use the -A argument with your Unix grep command, like this:

grep -A 5 "the living" gettysburg-address.txt

This grep "after" command returns the following output:

It is for us, the living,
rather to be dedicated here
to the unfinished work which they have,
thus far, so nobly carried on.
It is rather for us to be here
dedicated to the great task remaining before us -

Of course you can use any number after the -A and -B options, I'm just using the number five here as an example.

Power file searching with find and grep


A lot of times I know that the string "foo" exists in a file somewhere in my directory tree, but I can't remember where. In those cases I roll out a power command, a Linux find command that uses grep to search what it finds:

find . -type f -exec grep -il 'foo' {} \;

This is a special way of mixing the Linux find and grep commands together to search every file in every subdirectory of my current location. It searches for the string "foo" in every file below the current directory, in a case-insensitive manner. This find/grep command can be broken down like this:

◉ "." means "look in the current directory"
◉ -type f means "look in files only"
◉ -exec grep -il foo means "search for the string 'foo' in a case-insensitive manner, and return the matching line and filename when a match is found
◉ {} \; is a little bizarre syntax that you need to add to the end of your find command whenever you add the -exec option. I try to think of it as a placeholder for the filenames the find command finds.

Note that on Mac OS X systems you may be able to use the mdfind command instead of this find/grep combination command. The mdfind command is a command-line equivalent of the Spotlight search functionality.

Thursday, 20 August 2020

Best LPIC-1 and LPIC-2 certification study books 2020

LPIC-1 Certification, LPIC-2 Certification, LPI Guides, LPI Learning, LPI Exam Prep

To become proficient in administering Linux boxes which opens a plethora of other opportunities such as DevOps, Cloud Computing and System Administration to mention a few, then a lot of work needs to be put in mastering Linux together with other tools. In the quest to master this niche, this article generously provides resources in form of books that will propel one in the right direction. You will not only be able to pass your LPI exams but you will stick with something much more. And that is the power to administer systems. If that sounds great, please stick with me all through.

About LPIC-1 and LPIC-2 Certification


Linux Professional Institute (LPI) is the global certification standard and career support organization for open source professionals. 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.

Read More: LPI Books

On the other hand, LPIC-2 is the second certification in LPI’s multi-level professional certification program. The LPIC-2 will validate the candidate’s ability to administer small to medium–sized mixed networks (lpi.org, 2019).


Best LPIC-1 Certification Study Books



Below is a list of the best LPIC-1 certification study books.

1. LPIC-1: Linux Professional Institute Certification Study Guide: Exams 101 and 102 3rd Edition by Roderick W. Smith


Relying on the extensive experience and in depth experience from the author, this practical book covers key Linux administration topics and all exam objectives and includes real-world examples and review questions to help you practice your skills. In addition, you’ll gain access to a full set of online study tools, including bonus practice exams, electronic flashcards, and more. This book is quite suitable for you because it:

◉ Prepares candidates to take the Linux Professional Institute exams 101 and 102 and achieve their LPIC-1 certification
◉ Covers all exam objectives and features expanded coverage on key topics in the exam
◉ Includes real-world scenarios, and challenging review questions
◉ Gives you online access to bonus practice exams, electronic flashcards, and a searchable glossary
◉ Topics include system architecture, installation, GNU and Unix commands, Linux filesystems, essential system services, networking fundamentals, security, and more

To get your LPIC-1 exam right and have a good understanding of Linux, get your copy by clicking on the link below:

LPIC-1: Linux Professional Institute Certification Study Guide: Exams 101 and 102

2. Linux Command Line and Shell Scripting Bible, 3rd Edition


This book by Richard Blum serves as a basic and very essential Linux resource that will guide you with plenty of examples. Linux Command Line and Shell Scripting Bible goes right away into the fundamentals of the command line, introduces you to bash scripting which will be very important in your day to day Linux administration and goes an extra mile by providing detailed examples. The third edition being the latest release, it has new updated content and examples aligned with the latest Linux features which will help you fulfill the LPIC-1 objectives

What is attractive about this resource is how the author has gone out of the way to provide sound tutorials that you can easily follow through and actually understand. The examples are apt and relevant. Take is away from Amazon by clicking on the link below:

Linux Command Line and Shell Scripting Bible, 3rd Edition

3. Linux Essentials, Second Edition


Authored by experts Christine Bresnahan and Richard Blum Linux Essentials has a professional approach that aims at developing one for Linux Administration profession as well as passing the Linux Essentials exam which can serve as a lasting foundation to Linux and LPIC-1 at the same time. It has hands-on tutorials and learning-by-doing style of learning that equip you with a solid foundation as well giving you the confidence to pass the Linux Exam. For beginners with a keen interest in joining the IT industry as a professional, this book is highly recommended. You can check the reviews at Amazon below:

Linux Essentials, Second Edition

4. Linux Bible 9th Edition


Brought to you by veteran bestselling author Christopher Negus and Christine Bresnahan (contributor), Linux Bible brings to you a complete tutorial packed with major updates, revisions, and hands-on exercises so that you can confidently start using Linux today. There are exercises in abundance aimed to make your learning interesting and hence enable it as a better learning tool. Moreover, Linux Bible places an emphasis on the Linux command line tools and can be used with all distributions and versions of Linux.

Check it out on:

Linux Bible 9th Edition

5. Linux: The Complete Reference, Sixth Edition


Richard Petersen, a Linux Expert has once again released this book that gives the reader an in-depth coverage of all Linux features. As a beginner, you will have the advantage of having a thorough coverage of all aspects of Linux distributions ranging from shells, desktops, deployment of servers, management of applications, understanding security and a good grounding of basic network administration.

Linux: The Complete Reference is the ultimate guide where you will have the chance to learn how to:

◉ Administer any Linux distribution by installing and configuring them
◉ File and directory administration/manipulation from the BASH, TCSH, and Z shells
◉ Understand and use various desktop environments such as GNOME and KDE desktops, X Windows, and display managers
◉ Understand how to install essential applications such as office, database, connection to the Internet, and manage multimedia applications
◉ Have a good coverage of security by learning SELinux, netfilter, SSH, and Kerberos
◉ Get a good grounding of encryption such as encrypting network transmissions with GPG, LUKS, and IPsec
◉ Acquire skills of deploying FTP, Web, mail, proxy, print, news, and database servers and many more.

Check out the book at: Linux: Linux: The Complete Reference, Sixth Edition

Best LPIC-2 Certification Study Books


After you have had your LPIC-1 Certification and you have had the opportunity to practice your skills in administering systems, time will come when you will need to upgrade your certification level to get the trust from employers to handle more responsibilities in your wonderful career. This section gives you a place to select the resources that will help you climb the ladder stress-free.

1. LPIC-2: Linux Professional Institute Certification Study Guide: Exam 201 and Exam 202, 2nd Edition by Christine Bresnahan


The LPI-level 2 certification confirms your advanced Linux skill set, and the demand for qualified professionals continues to grow.

Christine once again goes over the objectives that LPIC-2 demands and produced this study guide that covers it all 100 percent. This book provides clear and concise coverage of the Linux administration topics you’ll need to know for exams 201 and 202. Crafted to benefit you to not only pass the exams, the examples provided highlight the real-world applications of important concepts, and together, the author team provides insights based on almost fifty years in the IT industry.

This brand new second edition has been completely revamped to align with the latest versions of the exams, with authoritative coverage of the Linux kernel, system startup, advanced storage, network configuration, system maintenance, web services, security, troubleshooting, and more.

You will be ahead by learning a lot for example:

◉ Understand all of the material for both LPIC-2 exams
◉ Gain insight into real-world applications
◉ Test your knowledge with chapter tests and practice exams
◉ Access online study aids for more thorough preparation

All this and more awaits you when you purchase your copy on the link below:

LPIC-2: Linux Professional Institute Certification Study Guide: Exam 201 and Exam 202, 2nd Edition

2. LPIC-2 Linux Professional Institute Certification Study Guide: Exams 201 and 202 1st Edition by Roderick W. Smith


Compiled from a long period of Linux exposure and confident experiences of Roderick, this book picks up from your LPIC-1 journey and takes you a step at a time to master the advanced stuff hidden in Linux. You will be sure to get satisfied by the manner in which the clear explanations and language has been done. This study guide provides unparalleled coverage of the LPIC-2 objectives for exams 201 and 202. Clear and concise coverage examines all Linux administration topics while practical, real-world examples enhance your learning process. What is more, the book:

◉ Prepares you for exams 201 and 202 of the Linux Professional Institute Certification
◉ Offers clear, concise coverage on exam topics such as the Linux kernel, system startup, networking configuration, system maintenance, domain name server, file sharing, and more
◉ Addresses additional key topics for the exams including network client management, e-mail services, system security, and troubleshooting

There is no other place to look than Amazon for a copy of this book. Click on the link below and you will be taken there

LPIC-2 Linux Professional Institute Certification Study Guide: Exams 201 and 202 1st Edition

3. LPIC-2 Cert Guide: (201-400 and 202-400 exams) (Certification Guide) 1st Edition by William Rothwell


There is so much that one can learn from a veteran or one with so much experience in a given area of expertise especially when they go out of their way to put it all on paper. Expert Linux/Unix instructor William “Bo” Rothwell does this and shares preparation hints and test-taking tips, helping students identify areas of weakness and improve both conceptual knowledge and hands-on skills. Material is presented in a concise manner, focusing on increasing understanding and retention of exam topics such as

◉ Capacity planning
◉ Managing the kernel
◉ Managing system startup
◉ Managing filesystems and devices
◉ Administering advanced storage devices
◉ Configuring the network
◉ Performing system maintenance
◉ Administering Domain Name Server (DNS)
◉ Configuring web services
◉ Administering file sharing
◉ Managing network clients
◉ Administering e-mail services
◉ Administering system security

This can be of real value to your preparation process. If you are inspired, head over to Amazon and take a look at it below:

LPIC-2 Cert Guide: (201-400 and 202-400 exams) (Certification Guide)

Tuesday, 18 August 2020

Open source careers: How Mehdi Hamidi became a DevOps Specialist

LPI Tutorial and Materials, LPI Exam Prep, LPI Certification, LPI Exam Prep, LPI Learning

In 2019, Linux Professional Institute (LPI) celebrated 20 years of offering training and tests. The LPI20 Birthday Contest gave us the opportunity to hear from you some amazing stories about your careers in open source and how the LPI certification program helped you. Over the next weeks, we’ll share some of these stories.

We are gratified to start with the story of Mehdi, a SysAdmin and DevOps Engineer from Iran.

Pentium 133, DevOps, and everything in between


LPI Tutorial and Materials, LPI Exam Prep, LPI Certification, LPI Exam Prep, LPI Learning
I’m Mehdi Hamidi, a DevOps Specialist with 5 years of work experience in System Administration and DevOps. I believe my current position grew from of a change in direction I took early in my education. And I think I have been lucky in my life. So, let me tell you my “techie life” story…

In the beginning


When I was 13, my aunt had a Pentium 133 computer and I was curious about how a computer works. I almost immediately started writing code, before having my own computer. I had read a QBasic book and I was writing the code on… paper. My first memorable achievement, which I’m still incredibly proud of, was a Qbasic Code to calculate prime numbers up to 1000.

It was six months before I could visit my aunt again.The code worked fine.

I am very happy to share my story about how LPI has changed my life and helped me in pursuing my goals.

Linux and Open Source: many kernels ago


The first Linux environment that I was involved with was RedHat Linux 7.2 in high school. I loved writing code in C and testing it on Linux. At that time I started learning the Linux commands.

At the university, courses required mostly Microsoft environments and C# language; however, I always kept an eye on Linux.

The path seemed clear: to get my Master of Science, send out CVs, start work. But halfway through my postgrad program, I found out that it wasn’t what I expected. I needed something more practical, something that I could do. I left the university. But I wasn’t quitting the computer field: I was looking for a way to get more involved in something that was not teached in universities, something related to my technical goals, by which I could become a prominent expert.

The Linux Community and me


I immediately started looking for a community of developers and SysAdmins in Iran. I started attending the Tehran LUG meeting and the other events such as the Ubuntu Release Parties.
Then I opened my Twitter account. Twitter had an undeniable impact on allowing me to connect with my technical friends as well as industry experts.

It seemed that It was for a big change. I quit my routine job and went for learning PHP, as I wanted my applications web-based. The problem is: I genuinely hated PHP! It seemed the end of the line. But I was wrong.

I hadn’t realized that having a good knowledge of Linux is a great key for aspiring to System Administrator positions. I heard of LPI for the first time at an Ubuntu Release Party. Meanwhile, a SysAdmin friend told me a small company was developing its private cloud. I wasn’t sure what it was about, but it was something Linux related, and that was enough. ;-)

After two months studying Linux and virtualization, I started the job. Meanwhile, I bought a Raspberry Pi and built up a home server, just to keep me (more) busy. I implemented a Wordpress blog with Apache on that Raspberry Pi with a single core CPU. Just imagine, what would happen with all of the LAMP stack on a single SD Card…

This was the beginning of my learning about web servers, logs, optimization. I implemented an NFS server for home file sharing. I started synching my Phone Contacts with CardDav Server on Raspberry Pi. Thank you, RaspberryPi, for making a junior SysAdmin of me!

The LPI Certification


And then LPI came into play. I wanted to give more consistency to my CV through a worldwide acknowledged certification. That’s why I attended an LPI exam.

I signed up for preparation classes for LPIC-1. The classes were dramatically important to help me navigate through the topics and objectives of the exam.

I started to read the reference books, which contain the majority of exam objectives, and took notes from the most important parts, which I referred to on the next iteration of studying. The most significant insight I got during the studying phase, when I was involved in many important details, was the many gaps in my knowledge. Study made me aware of my weaknesses and lack of knowledge, which I wouldn’t have found out otherwise. The details matter, because they distinguish between a beginner and experienced system administrator. LPIC-1 made me involved in the details, and that is the most significant effect it had on my techie life.

Although the exam was tougher than I expected, I passed and I became an LPIC-1 certified professional.

Me, a DevOps, today


My approach to my career involves continuous learning. I implemented Zabbix monitoring for the company I was working in. The need for agile development and integration made me go in Docker and Jenkins direction. Nginx. SaltStack. And then microservices and Kubernetes.

I applied for LPIC-2 preparation classes, two years ago, in order to apply for more professional work positions. I want to dare: again, and more. It’s time to prove myself going for LPIC-2!

Source: lpi.org

Thursday, 13 August 2020

Linux mv command examples

Linux mv Command, Linux Study Material, Linux Exam Prep, Linux Tutorial and Material

The Linux mv command lets you move one or more files or directories. Since it's very similar to the cp command, I'll move through this post quickly.

Basic Linux mv examples


To rename a file currently named "foo" to a new file named "bar" just type:

mv foo bar

Although it's called the Linux mv command, it's commonly used to rename files.

To move a file named "foo" to the /tmp directory type:

mv foo /tmp

To move a file named "foo" to a new file named "bar" in the /tmp directory type:

mv foo /tmp/bar

Conversely, if the file "foo" is in the /tmp directory, and you want to move it to the current directory you'd type this:

mv /tmp/foo .

No matter where you are in the filesystem, if you want to move the same file to your home directory you can type this:

mv /tmp/foo ~

The ~ character is a shortcut character that refers to your home directory (and works with all shell commands, not just the mv command). To move the same file to a directory named "dir1" in your home directory you could type this:

mv /tmp/foo ~/dir1

More complicated mv examples


To move several files named "foo1", "foo2", and "foo3" into a directory named "dir1", use a mv command like this:

mv foo1 foo2 foo3 dir1

That's the long way to type it out. This command does this same thing:

mv foo[123] dir1

And if you don't have any other file beginning with the string "foo" you can just take this shortcut:

mv foo* dir1

How to move directories


Assuming that you have a directory named "dir1" that you want to rename to "dir2" you can use a command like this:

mv dir1 dir2

Don't clobber existing files


The mv command has several options to keep you from clobbering existing files during copy operations. The -i option prompts you before performing a move operation that would overwrite an existing file. Assuming that "bar" is a file that already exists, the interaction looks something like this:

/Users/al/yada> mv -i foo bar 
overwrite bar? (y/n [n]) n
not overwritten

In this example the system prompted me with the overwrite bar? (y/n) prompt, and I responded with n.

Instead of using -i you can use -n, which just doesn't allow this to happen at all. Unfortunately it doesn't give you any output, unless you also use the -v option, like this:

/Users/al/yada> mv -nv foo bar
bar not overwritten

mv aliases


Because of the potential danger of clobbering existing files a lot of people create an alias for the mv command, like this:

alias mv="mv -i"

As with the cp command I don't see any harm in doing this, and you can always undo it, so I highly recommend it.

Tuesday, 11 August 2020

Configure User Password Aging / Expiry Policy in Linux

In this post, you’ll learn to configure password aging and expiry policy for Linux users, as well as manually lock and unlock user accounts. The password aging and expiration features were implemented to ensure better security of user accounts.

Linux Study Materials, LPI Tutorial and Material, Linux Exam Prep, Linux Prep, Linux Tutorial and Material

How Password Verification works


When a user tries to log in, the system looks up the entry for the user in the /etc/shadow file, combines the salt for the user with the unencrypted password that was typed in, and encrypts them using the hashing algorithm specified. If the result matches the encrypted hash, the user typed in the right password. If the result does not match the encrypted hash, the user typed in the wrong password and the login attempt fails.

Read More: LPIC-OT 701: DevOps Tools Engineer

You’ll learn to:

◉ Force a password change on the first time login.
◉ Force a password change every X number of days.
◉ Set a user account to expire X days from the current day.

Before we get started, I’ll create a user account for this exercise.

sudo useradd user1
sudo passwd  user1

You’ll learn about other user operations with examples.

Exercise 1: Force a password change on the first login


To force a password change for the user on first login, use the command:

sudo chage -d 0 user1

If you log in as user1, you’ll be prompted to change the password.

$ ssh user1@localhost
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
user1@localhost's password:
You are required to change your password immediately (administrator enforced)
Last login: Wed Feb 12 06:48:43 2020 from ::1
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for user user1.
Current password:
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Connection to localhost closed.

You can now login with updated password.

ssh user1@localhost
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
user1@localhost's password:
Last login: Wed Feb 12 06:48:53 2020 from ::1
[user1@localhost ~]$ exit
logout
Connection to localhost closed.

Exercise 2: Change the password policy for user


Let’s now set a password policy to require a new password every 90 days.

sudo chage -M 90 user1

Confirm that the password policy is successfully set.

$ sudo chage -l user1
Last password change : Feb 12, 2020
Password expires : May 12, 2020
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 90
Number of days of warning before password expires : 7

Exercise 3: Set user account to expire after X number of days


We’ll set the user1 account to expire 120 days from the current day.

Get the date and time 120 days from the current:

$ date -d "+120 days" +%F
2020-06-11

Now set the account to expire on the date displayed above.

sudo chage -E 2020-06-11 user1

Verify that the account expiry date is successfully set:

$ sudo chage -l user1
Last password change : Feb 12, 2020
Password expires : May 12, 2020
Password inactive : never
Account expires : Jun 11, 2020
Minimum number of days between password change : 0
Maximum number of days between password change : 90
Number of days of warning before password expires : 7

Exercise 4: Lock & Unlock user account


Locking the account prevents the user from authenticating with a password to the system. The usermod command can be used to lock an account with the -L option.

sudo usermod -L user1

Confirm:

$ su - user1
Password: 
su: Authentication failure

The account can later be unlocked with usermod -U command option.

sudo usermod -U user1

As a System administrator, you may lock and expire an account with a single usermod command. This is ideal for exited employees.

sudo usermod -L -e 2020-02-20 user1

The date must be given as the number of days since 1970-01-01, or in the YYYY-MM-DD format.

Exercise 5: Set password policy for all users


Set the password for all users to expire 90 days from the current date. Administrative rights are required to edit the file /etc/login.defs.

sudo vim /etc/login.defs

Set PASS_MAX_DAYS to 90.

PASS_MAX_DAYS   90

It should look like this:

Linux Study Materials, LPI Tutorial and Material, Linux Exam Prep, Linux Prep, Linux Tutorial and Material

All password aging parameters you can configure are:

◉ PASS_MAX_DAYS Maximum number of days a password may be used.
◉ PASS_MIN_DAYS Minimum number of days allowed between password changes.
◉ PASS_MIN_LEN Minimum acceptable password length.
◉ PASS_WARN_AGE Number of days warning given before a password expires.

When you edit the file /etc/login.defs, the default password and account expiry settings will be effective for new users but not for existing users.

Saturday, 8 August 2020

How To Create Hard and Soft (Symbolic) Links in Linux

LPI Exam Prep, LPI Tutorial and Materials, LPI Learning, LPI Certifications

How can I create Symbolic Links in Linux?. In this tutorial, you’ll learn how to make multiple file names reference the same file using hard links and symbolic, also called “soft” links. The two common ways of creating multiple names that point to the same file in Linux are:

◉ Creating a soft link (symbolic link) to the file
◉ Creating a hard link to the file.

Working with Soft link (Symbolic link)


A soft link is a special type of file that points to an existing file or directory. It can be used to link two files on different file systems. A soft link can point to a special file as well.

The ln -s command is used to create a soft link. Let’s consider an example:

In the following example, the ln -s command is used to create a new soft link for the existing file /tmp/file1.txt that will be named to /tmp/file2.txt:

$ echo "Hello from file1" > /tmp/file1.txt
$ ln -s /tmp/file1.txt /tmp/file2.txt

Confirm by listing the files:

$ ls -l /tmp/file1.txt /tmp/file2.txt
-rw-------. 1 jkmutai jkmutai 17 Feb  4 22:37 /tmp/file1.txt
lrwxrwxrwx. 1 jkmutai jkmutai 14 Feb  4 22:38 /tmp/file2.txt -> /tmp/file1.txt

You can see the first character of the long listing for /tmp/file2.txt is l instead of -. This indicates that the file is a soft link and not a regular file. (A d would indicate that the file is a directory.)

Check the contents of the symbolic link file.

$ cat /tmp/file2.txt
Hello from file1

For directory, use:

ln -s /dir /dir2

If you delete the original regular file, the soft link will still point to missing file – a “dangling soft link.”

Working with Hard Links


Every file in Linux starts with a single hard link. By creating a new hard link to a file, you are creating another name that points to that same data.

The new hard link acts exactly like the original file name. It is hard to tell the difference between the new hard link and the original name of the file. You use the ln command to create a hard link – Another name that points to an existing file.

$ echo "Hello World from Hard Link" >/tmp/hello1.txt
$ ln /tmp/hello1.txt  /tmp/hello2.txt

Where:

◉ /tmp/hello1.txt is a path to the existing file
◉ /tmp/hello2.txt is the hard link that you want to create.

Use the ls -i option to ls list the files’ inode number. If the inode numbers are the same, the files are hard links pointing to the same data.

$ ls -li /tmp/hello1.txt  /tmp/hello2.txt
2591191 -rw-------. 2 jkmutai jkmutai 27 Feb  5 08:16 /tmp/hello1.txt
2591191 -rw-------. 2 jkmutai jkmutai 27 Feb  5 08:16 /tmp/hello2.txt

--- Let's add third file and recheck ---
$ ln /tmp/hello1.txt  /tmp/hello3.txt
$ ls -li /tmp/hello1.txt  /tmp/hello2.txt /tmp/hello3.txt
2591191 -rw-------. 3 jkmutai jkmutai 27 Feb  5 08:16 /tmp/hello1.txt
2591191 -rw-------. 3 jkmutai jkmutai 27 Feb  5 08:16 /tmp/hello2.txt
2591191 -rw-------. 3 jkmutai jkmutai 27 Feb  5 08:16 /tmp/hello3.txt

All hard links referencing the same file have the same:

◉ link count
◉ access permissions
◉ user and group ownerships
◉ time stamps
◉ file content

Compare with ones for Soft link:

$ ls -li /tmp/file1.txt /tmp/file2.txt /tmp/file3.txt
2442008 -rw-------. 1 jkmutai jkmutai 17 Feb  4 22:37 /tmp/file1.txt
2442949 lrwxrwxrwx. 1 jkmutai jkmutai 14 Feb  4 22:38 /tmp/file2.txt -> /tmp/file1.txt
2601927 lrwxrwxrwx. 1 jkmutai jkmutai 14 Feb  5 08:24 /tmp/file3.txt -> /tmp/file1.txt

Key difference between Soft link and Hard link


◉ A hard link points a name to data on a storage device
◉ A soft link points a name to another name, that points to data on a storage device

Thursday, 6 August 2020

The .lpi command

.lpi command, LPI Tutorial and Materials, LPI Exam Prep, LPI Learning, LPI Prep

The .lpi command sets the number of lines per inch for output. If the printer does not support the specified number of lines per inch, this command has no affect.

Note: 

It may be necessary to change the term setting to get the required number of lines to print on a page.

Syntax


.lpi number.lines

Parameter(s)


number.lines - Specifies the number of lines per inch. The default is 6.

Learn More


Linux Professional


.lpi command, LPI Tutorial and Materials, LPI Exam Prep, LPI Learning, LPI Prep
Linux Professional Institute‘s Linux Professional Track is designed to evaluate the knowledge and skills of Linux systems administrators. To keep pace with evolving technology, the exam objectives are updated on average every three years and Linux Professional Institute certifications are valid for five years before you must recertify or certify at a higher level.

Linux Professional Institute LPIC-1 tests ability to perform maintenance tasks with the command line, install and configure a computer running Linux and be able to configure basic networking.

Prerequisites: There are no prerequisites for this certification.
Requirements: Passing the 101 and 102 exams. Each 90-minute exam is 60 multiple-choice and fill-in-the-blank questions.
Validity period: 5 years unless retaken or higher level is achieved.

101-500: Linux Administrator - 101 (LPIC-1 101)
102-500: Linux Administrator - 102 (LPIC-1 102)

Linux Professional Institute LPIC-2 tests ability to administer small to medium–sized mixed networks.

Prerequisites: An active LPIC-1 certification.
Requirements: Passing exams 201 and 202. Each 90-minute exam is 60 multiple-choice and fill-in-the-blank questions.
Validity period: 5​ years unless retaken or higher level is achieved.

201-450: Linux Engineer - 201 (LPIC-2 201)
202-450: Linux Engineer - 202 (LPIC-2 202)

Linux Professional Institute LPIC-3 Enterprise Mixed Environment tests ability to integrate Linux services in an enterprise-wide mixed environment.

Prerequisites: An active LPIC-2 certification.
Requirements: Passing the 300 exam. The 90-minute exam is 60 multiple-choice and fill-in-the-blank questions.
Validity period: 5 years

LPIC-3 300: Linux Enterprise Professional Mixed Environment

Linux Professional Institute LPIC-3 Enterprise Security tests ability to secure and harden Linux-based servers, services and networks enterprise-wide.

Prerequisites: An active LPIC-2 certification.
Requirements: Passing the 303 exam. The 90-minute exam is 60 multiple-choice and fill in the blank questions.
Validity period: 5 years

LPIC-3 303: Linux Enterprise Professional Security

Linux Professional Institute LPIC-3 Enterprise Virtualization and High Availability tests ability to plan and implement enterprise-wide virtualization and high availability setups using Linux-based technologies.

Prerequisites: An active LPIC-2 certification.
Requirements: Passing the 304 exam. The 90-minute exam is 60 multiple-choice and fill in the blank questions.
Validity period: 5 years

LPIC-3 304: Linux Enterprise Professional Virtualization and High Availability

Tuesday, 4 August 2020

Unix TimeStamp Command

Unix TimeStamp Command, LPI Tutorial and Material, LPI Certification, LPI Exam Prep

What is Unix Timestamp


Unix timestamp is the representation of time as the running total of number of seconds since the unix epoch time on January 1st, 1970. Simply the Unix timestamp is the number of seconds between the particular date and the Unix Epoch.

The unix timestamp become standard in computer systems for tracking the information especially in distributed processing system like hadoop, cloud computing etc.

Here we will see how to convert the unix date to timestamp and unix timestamp to date. We will also see how to generate the unix current timestamp. Let see each one:

1. Unix Current Timestamp


To find the unix current timestamp use the %s option in the date command. The %s option calculates unix timestamp by finding the number of seconds between the current date and unix epoch.

date '+%s'
1327312578

You will get a different output if you run the above date command.

2. Convert Unix Timestamp to Date


You can use the -d option to the date command for converting the unix timestamp to date. Here you have to specify the unix epoch and the timestamp in seconds.

date -d "1970-01-01 956684800 sec GMT"
Tue Apr 25 10:46:40 PDT 2000

3. Convert Unix Date to Timestamp


You have to combine the -d option and the %s option for converting the unix date to timestamp.

date -d "2000-01-01 GMT" '+%s'
946684800

Saturday, 1 August 2020

Understanding the Linux File System Hierarchy

How can I master the Linux File System Hierarchy?. This is a short explanation of the Linux file system Hierarchy. In a Linux system, all files are stored on file systems. A file-system hierarchy is the organization of these files into a single inverted tree of directories. The tree of directories is said to be inverted since its root at the top of the hierarchy, and the branches of directories and sub-directories stretch below the root.

The below diagram is a Red Hat Enterprise Linux(RHEL) 8 file-system directories.

LPI Exam Prep, LPI Tutorial and Material, LPI Certification, LPI Learning, Linux Command

As seen in the diagram, the / is the root directory at the top of the file system tree. All other directories are separated by the / character. So var is a subdirectory of the root directory (/). How then can we describe the file-system directory contents?.

Linux File System Hierarchy Content types


LPI Exam Prep, LPI Tutorial and Material, LPI Certification, LPI Learning, Linux Command

These are the major types of content stored in a Linux filesystem.

1. Persistent – These are the contents which should be persistent after a reboot, e.g system and applications configuration settings.

2. Runtime – Content generated by a running process; usually deleted by a reboot

3. Variable / Dynamic – These content may be appended or modified by processes running in the Linux system.

4. Static content – This remains unchanged until explicitly edited or reconfigured.

Important Linux Directories – May vary from one distro to another


These are the standard Linux directories – This is pulled from a RHEL 8 server.

System Directory
Purpose 
/etc
Contains configuration files used by system services
/root 
This is a home directory for the Linux superuser account, root 
/boot 
Contains all the files needed to start the boot process.
/home 
This is where standard users store their personal configurations and data such as Documents, Videos, Music e.t.c. 
/var 
Has variable data that is required to persist between boots – databases, log files, mails, cache directories, Web data e.t.c. 
/tmp 
Stores temporary files. All Linux users can write to this directory. Files older than 10 days are deleted automatically. 
/usr 
This directory contains shared libraries, installed software, and read-only program data.
Some of the important subdirectories include:

• /usr/bin: Mostly user commands are located here.
• /usr/sbin: Hosts System administrative commands that required privilege escalation to run.
• /usr/local: For locally customized software. 
/dev 
This contains special device files used by the system to access hardware. 
/run 
The processes started since the last boot stores their runtime data here, e.g. process ID files and lock files. These contents are recreated on reboot. 

Other directories that may be symlinks to other:

◉ /bin and /usr/bin
◉ /sbin and /usr/sbin
◉ /lib and /usr/lib
◉ /lib64 and /usr/lib6