[Autogenerated] One real advantage that we have in being
able to use re app in our regular expressions is that we
can search many files at once.
Sometimes we might not know the configuration file that is being used.
So we can start using our file globbing.
So our normal asterisk or question mark depending on what we need when
we go through and start then searching for maybe the PM underscore M O
T D module inside of E T C and PAM dot D.
Well, if we don't know which configuration file it could be in,
it might be in SSH shared configuration file or
individual for a particular service,
then using the asterisk becomes really useful.
So any file within Pam dot D, if we just want to look at the file names,
rather than seeing the output,
we can use grip minus lowercase L and then run the same search and it
will just list the file names that contain that string.
If we want to know a little bit more detail on any of our POM modules,
I know that's not what we're really looking at,
but we can then go through and open up the man page on PAM underscore M O T D
and we can move ahead then for our demonstration and we can start looking at
a scenario where we can implement this search.
We might find that we need to be able to go through and search for the file.
And then once we've located the relevant configuration,
editing that configuration,
so that we can display a different message of the day file for SSH
connections compared to our standard login connections.
Do you want to see how we're going to do it?
Come on,
let's find that command line and look at this a really big
warm welcome through to the command line.
We can go ahead and start searching for our information even if
we don't know which file to go through to.
So if we look for the PM underscore M O T D module,
once we've got that within our regular expression,
and we just need the string.
We can go ahead and we're going to find all of these files
underneath forward slash E T C forward slash pam dot D and
then using the asterisk,
we're looking for all files and we've got four lines coming back.
But when we look at it, we've got two matches in each of the files,
the login file, which is our standard log ins and the SSH D file,
which is going to be used when we're logging in via SSH.
Now,
if we want to have a different message of the day file
shown when we're logging in via SSH, we need to edit the SSH D configuration.
The log in is our standard console login program.
So if I go through then and take a look at creating my messages the day file,
so that's probably the first thing that we need to do.
To be honest, I've already created it, but it's a very simple one line file.
It doesn't really matter where you put it,
but it kind of makes sense that it's an E T C SSH message of the day.
And you can see then that I've just got the simple if you don't belong,
don't stay.
So this is then opening up log ins to perhaps the internet and anyone
who wants to be able to try and log into our system.
So if they do succeed,
we can at least give them a warning that they are not
welcome with that done and dusted.
The next thing is to go through and start editing our configuration file.
Remember, we only need to edit the E DC pam dot D ssh D.
So as we go through and start editing this,
I'm using VM, but of course, you can use any editor that you want.
Now, as we scroll our way down,
we can see the configuration option I want is towards the bottom of the screen.
So if I move towards that, and if I want to edit at the end of the line,
I use upper case A and that will allow me to append to the end of the line.
Ah But look at this Muppet, I've gone in without using sudo,
but this is really easy to fix.
So sd and Bang Bang,
the double exclamation mark is running the complete
last command and all of its arguments.
So we've opened the editor now whilst we our route,
I can move down,
use the upper case A and change then to point to the message of the day
file being E T C and forward slash SSH and M O T D.
Remember the file we've just created.
Now, the second line is running the standard message of the day file,
but without running any additional scripts.
Well, we don't need that so we can then go through and delete that line.
So we're going to be displaying just our line plus anything else
that is being run through the bash scripts.
But if I exit out and now when we log in,
we can see the top line displaying the message that
we've configured if you don't belong, don't stay.
So just a simple way of showing how we can use our re app search to
locate the configuration file that we need to edit.
And of course, this is looking at the message of the day module,
but we could be looking at anything.
And of course, it doesn't have to be pam related.
We're just giving you options that you can use in your own environment.
But having looked at this,
we're now going to go through it and start seeing how we can
process text files in different simple formats.
Be they space separated, commerce separated or colon separated.
Again, really useful for you creating simple reports based on text files.