Okay, let's go ahead and get started here, recording.
Okay Good morning everyone.
So what we're going to focus on today is tutorial three.
So what we talked about today but first.
me an assignment one right.
Thank you. Yes.
So, uh, so make sure you get checked off as soon as possible with the TA.
So you can go to any ta to get mark for a tutorial.
So, basically this rice on the aside the whole purpose of having it as a TA assigned to you with someone to try to track your progress. And to that end, it would be good if you try to go to the same ta over time.
But the big thing is we want you to.
We don't want you to get behind with the tutorials, because it's very easy kind of sense of participation more you kind of think oh it's fine as, you know.
we don't want to get behind you really need to keep up with the tutorials, and it's okay to have questions on that but you know at least look at the material try to do what you can, with them because that's what the assignments are based on, we will walk
you through the tutorials and give you whatever answers you want. Now, one thing our tutorials is.
no solution keys once you leave school.
So.
So you need to be focusing on how to, how to learn the answers like what how to understand these resources and I can show you some of and I do this in class when I demonstrate stuff but you have to walk yourself through it and see that.
Oh yeah, this is how, and put the pieces together.
Yeah. So looking at tears.
So there are lots of resources on assembly language.
There are lots of books, I'm not going to me. I will can look up somebody.
I don't think it's good for you to spend too much time learning assembly language for this class.
So if you want to learn it on your own I'm happy to do that but that's not what necessary to succeed in this class. I'm so behind it yeah Bryce. Bryce.
It's,
it's not progress grades.
Provide probably so um,
it's not bright press progress grades it's bright space progress things out.
Yeah.
Thank you mom but yes, exactly, you have four assignments, you're going to get marks on and you can also talk to your teachers and they will talk to you.
That's the point for you to talk to your TA and they will tell you answers. If you don't understand things What I'm saying is, I'm not just going to give you signed where you just look up the answer.
The point is to get the feedback, that's the most important feedback to get for this class is are you going about getting the answers in a useful way.
We're going to walk you should give me a book to look at it's like, That's not how your.
We're not an age where you just look it up in a book if I not say there aren't useful books for learning these things but you have to integrate multiple sorts of information, along with what you observe in order to understand what's going on.
Yeah, the office hours are, you know, are there at the bottom yes exactly and also the T's regularly post in the tutorial channel, when they are available.
So, so that that's that's all there. So because it's in there. I've also posted it to teams the two announcements. When pendant there were the sort of duty officer so resources are there.
And again, you can get checked off during your assigned tutorial time that's when the TA so there. Go online go in person, talk to them.
Okay, but you need to get checked off before, you know, before your, you know, the assignments do.
So, be in touch with your TX.
Now moving on now.
I am, if you have specific questions about tutorial one in tutorial to or things that are unclear up the assignment I will not give too much away from the assignment.
I will give talk about what I got for tutorials, but I would like to walk through tutorial three First, Let's just say this really bugging you
cuz tutorial three. So what you'll notice about this class is that
it goes in circles. So tutorial one covered a lot of ground in a very superficial way. This tutorial goes back to some of those things and we'll show some of those ideas in more depth.
So,
and specifically what we're talking about here is this program called 3000 shell and there's various questions about ask me about how it works and stuff,
which we're still on the same chapters.
So let's actually let's good thing let go. That's good point let's go through the textbook here.
We'll go to.
So here we've got the here.
I've got the textbook.
Let me go. There's textbook.
So here's the textbook.
Let's look at these things here so what's here I told you now talk about three four and I believe five.
Correct.
Um.
We're still, we're still talking about this stuff.
We haven't gotten past the stuff we certainly are on the scheduling, and we certainly on on to address spaces on things yeah what was a little bit extra space.
Yeah.
There are different ways of going through of learning this material.
I will walk you through the material.
The textbook has different things. There's a turtle soup but there's also the entire internet of all kinds of resources.
Use whatever works for you.
I mean there's because this there's so much stuff on operating systems.
Me, I'm here to help the tears are here to help. But, um, but yeah this is not a course I mean, I certainly can point you to a note to text that will you there's lots of standard textbooks and operating system and you can read them through them.
But at the end of the day, what I want you to be able to do is I've got this program here.
This is 3000 shell.
What is this program do it.
The textbook is helpful, you should look through the textbook, it is interesting. If you find it confusing you can.
If you know you can use it I mean look through everything, see what works for you.
Because I. All of you learn in a different way, all of you will find different things but what I want you to be able to do first is, can you understand this program.
No, that's, that's what really matters.
So, let me first.
Okay.
I'm just copying it, I would suggest you use w get
the proper care let's, let's do that.
There we go.
Now we have 3000 show.
Here's the program.
Yep.
Yeah, go, go, go to give you come in person. That's one reason we support the in person tutorials.
Show up, talk with people.
Exchange things, I have a very generous collaboration policy on purpose.
So let me have this program here, but let's first try to compile it so at least we can see what it does.
So when you type it.
You get a prompt and type ls, you know, but we also have a few other commands that are built in.
P list, which gives a list of processes. So there's all the parts of my system which we need more that's on your VM.
And then it also supports a little bit of IoT interaction.
Yeah, I think that's okay.
Okay.
Remember how that works.
So, let me explain to you what's going on here. So the way this code works is, so this is a basic shell. Now, we'll talk about what these things are doing in a second.
You know, you know these little things but first, the important part to not look at this, all this here in Maine it's set up.
And we'll talk what you should understand what all those lines of setup, we talked about so many things but the big thing to look at is that there is this.
So, the appeal is returned to the design process but so prompt loop is the main part of this code that that's like the heart of it. And so probably loop.
And what using the username that was passed into it.
It then gets the user input, which is up to the buffer size buffer size the constant at the top I think it's like 4096 nine, but it does this from standard in, and puts it into this thing called buffer and checks to see, you know, do you have we reached
end to file, you know if we've got to give us know when the file and then we just, you know, click, you know, print Africa, the next line and then we exit.
So, so if you have, that means that
if I hit control D.
I'll exit, because control D. This is one little thing to note.
So, little things now control the dough is there so we've got.
So here we checked to see if it's know and it's not. and then we parse the arguments.
And so we've got a functionary to parse the arguments and that puts them into this Argh, you know, we get this number of arguments and you get the arguments and the right size so we have a person then that says like well, if we don't have any arguments,
we just continue.
If the first argument that's given it the first thing is type is exit, we exit the show, if we, if it's.
So now what now what questions Why am I doing an exclamation Bob besides string compare, so you'll know why I do this
string compare. Yeah, exactly.
Exactly. When straight when string compare returns up when, when it returns zero, it means that it's successfully matched,
which is a little bizarre.
But anyway, so, so we put the site put the exclamation point so basically if we match this, then we know, because we're just 10 commands here here appeal is we run p list.
And then we run, we say specifically continue here, because it means we want to go back to the top of the loop.
And then we set this thing called background is zero.
And so the idea is that we're going to run things in the background.
If this is true.
So, what is background processing. What does that mean.
So remember, when you.
normally run a command in the shell. It waits for it to finish.
So the show on the command or running at the same time.
What it means to run at the same time on a Unix system. For now, you can just think of it as at the same time, they actually have to share resources, especially if there's only one core.
How does that work there's this whole concept called scheduling, which we will be talking about later in the term, but for now we can say they're running at the same time.
So in practical terms, what this means is.
was that the string string compares a number of non matching map things, I forget how string compare works, but I would look, I can bring up the man page and look at it, but it's not relevant right now.
Anyway, um, so this is the idea that it's this foreground versus background.
So, so this is so now we're talking about fork and exactly eat, which I've mentioned.
But, so.
So these are the two things for duplicates the current process. Exactly. He replaces the program in the current process.
With that from a file.
So we now remember we actually now so we've seen this now. You've seen the system calls before and you'll see them in the assignment to but that these have been been there and the tutorial, every time we run a program.
You have to.
Now I will say, I just have to give this little caveat.
You say fork exactly, er,
they are far from perfect API's and there's actually a lot of people can go on these really limit performance they have semantic issues and stuff and that's, I could send you a links to that stuff but for.
Know that stuff is really used that stuff's all in development to look at windows that as a different way of creating things. So, this is it's a cute way of doing things.
It's actually very nicely designed for the use case of shells,
which actually was historically a big use case for lip for Unix systems. So it makes sense but I wouldn't be surprised if then five to 10 you know in five years.
I'll be teaching this class and saying oh actually we used to do it this way and now we do it this other way.
So,
so, so we say duplicate. So, so I'm just saying that forking exactly may be going away in the future but let's, let's talk about.
I'm not sure what you're saying Carson for me to repeat. Real quick,
but it's
asked me in the discussion thing and I'm happy to post the link to what I'm talking about, but this is, this is all cutting edge stuff.
I'm just saying that to realize the world
for anything that a computer does any sort of API endpoint there's always a trade off there's one certain things that's designed that's good for and other things that's not so good for me badly designed API's you know it's mostly bad for everything, but
well designed ones are never perfect, they're good for certain contacts and not great for other certain contacts and for can exactly is like anything along those lines.
So let's talk about these a little more what we mean by fork.
So if I'm, if I have a program that.
So, Let's do this on.
Okay so, um, so we'll do.
I'm not even gonna bother with any arguments because we're not gonna do anything.
I'll talk about
never really heard about foreground processing foreground processing is the default
was all the rage selfish real quick.
rate of social work. So just be clear fire, no it doesn't do anything comes to this.
So just be clear.
If I type in LS.
So when you. So the first thing that happens is when you type out last, the shell forks, which means that you now have two copies of the show. It is literally create a clone of itself.
They're both exactly the same, except that one hat one is a new process ID, and the return value of Ford is different.
So you have to duplicate process.
And then.
the parent process while still right wait to the child process terminate.
So,
the only difference between.
So I typed out so if I type ls LS.
So notice the difference here so if I type ls here.
It just returns, I type ls out ampersand, I get a prompt immediately.
Whoo.
Okay, so
see a second batch window when one runs a command as well just whenever I see a second batch for what runs a quick oin completely run a command to create a new window.
But you wouldn't do that through a terminal. But what you get. So, when we talk about background processing.
So,
so does that mean that any system calls you make. So, when you type out a prompt, you're not making system calls.
These are not, you don't make as you're typing in commands programs make system calls, we do not direct me, you have to be a running program to make a system call it's not.
ls is not a system called LS is a program that makes many system calls. Now, you might say, Why do I want to do.
Why would I want to do background processing was not so much.
Let's say I want to do Oh, For example, let's
try to think about, well,
Let's do.
First of all, you can always does. io redirection. So this is where IO redirection is important with the background stuff so if I do LS.
I type this LS to a file here.
And I get a job here and then it does it says it's done.
And then I look here.
This is the contents of the file food.
What's happened is, is, I got a prop back by using IO redirection the program keeps running like LS, what if I did an ls command that takes a really long time.
Actually, I do have commands.
So now I'm typing in this du dash So this gets disk usage. I'm asking for a summary of the disk usage, and I'm saying of the current directory which is my home directory and machine, and I'm putting it into the file desktops.
So my usage tax.
Now I'm type that in.
And I'm going like, okay,
so yeah so that now that's running in the background. Yeah.
Yeah.
No, you can do exactly exactly he does not require you to make a new process, it just replaces the current process.
Yeah.
Okay, so, so now I'm missing here now. So now notice it's not done.
And in fact,
so if you look here.
So, is
ok now it's, it's not.
Fine.
Elected work.
Oh, now now that works.
So you see now the job finally ran so this is this is all background processing.
So that's how much space my home directory is using.
So, yeah, it's like 339 gigs. So, so it took a little while to walk my whole directory in order to find out how much space it took.
So, so that's why you do background processing is something that's going to take a while.
Let's go back to the code.
So, this. If you look at the code for bash bash had lots of features, it's very complicated.
The idea here is to show you a small slice of the functionality of a show and things so so here is if you put a ampersand is one of the arguments. This will cause this sets the background flag to one.
And it you know and then, and then here what we do is we go through and we say standard out is going to know. And then if.
Oh yeah, our anxiety is the first argument of that yeah that's that's what it was.
Ok so now let's.
Good.
That's what I expected.
there so you see the output of LS went to this file. Now how did that work.
That's because here. So here is right now going through all the arguments, beyond the actual command.
And it's checking to see if the first letter of any argument is a greater than sign. If it's a greater than sign that it takes the rest of it, and basically puts it into this standard basically makes puts that into the stand up function that's the file
name, and then it processes the rest of the arguments.
Yeah.
It basically moves all the arguments back down.
And then it decreased number of arguments and then make sure that you know last one is no and basically this is just all this is is to get rid of that argument that you had a race the bat I think because you could put that anywhere in there.
And then, you know, get that out of the arguments but then we want to have those argument list there.
Where are we saying the thing, what's the PATH environment so we're talking about all those things in a second. But this is basically all stuff needed for running the program.
So exactly takes priority over any current running processes.
No, That's not what's happening.
And let me show you why.
So I'm exiting out of it so I have here.
Try to switch to the terminal here.
So here I've got, I've got a terminal here right this buffer run top here, and knows where I run top here.
I can hit you exit box the prompt. So what that means is bash was running in the, you know, was running separately, it was waiting for top to finish.
And then it came back, if I were to run top in the background, things get messy. Try it.
It's kind of annoying.
But what if I did, exec top.
So it turns out what.
So if you, if you just say exactly you got it will skip the fork, we'll just do it exactly. So if you want to see what that is we say exact top.
It works fine. Everything seems exactly the same as before.
But IQ.
You know, Nothing's there, the terminals dead because the prompt I was running, and notice what it here it says chart know process.
There is no one I'm talking to here.
So this terminal dead.
So I kill it.
You turn on bash again, I've got terminal again.
So at what level is concurrency parallelism actually happening.
Um, so the, so
I didn't replace bash with 3000 shell, I replace.
Oh, so I can also do here is I can do an executive says 3000 show so so I just typed dot slash 3000 shell.
I type ls the prompts here it's running, if I exit out of the shell it control D there. I now get back to this prompt.
And so you know things are still working but if I said did exec 3000 show.
ls is all running and stuff. But now, if I exit
process terminal finished
this things done.
If you were to revive a terminal, I'm.
Typically the window. Typically when you exit out of the terminal window will exit and disappear at that point.
If you're logged in via SSH, you'll be logged out of the system. So it all depends on how you got in, but you don't mean normally the terminal program will I just started up a window but that window.
It's dead.
But, so now you're thinking of how it is exactly to a first approximation blows everything away.
The process was bash.
So we were running, we're running bash. Yeah, the process.
Steve, see what I'm not quite sure what exactly you're asking.
Do you want your own voice.
But,
But yeah but so so good questions.
Yeah, so every time you pass a command to a regular show at forks.
So fork exactly, exactly thing is what happens every time you enter an external command. That's what we mean by an external command. It's a separate program binary and so you have to.
So you create a new process, and it gets run in that new process. That's why you do the fork and then you do the Exactly. If it's an internal command it just handles it.
So looking through here, this shell does implement some internal commands. It will exit internal command that doesn't resolve the fork exactly p list is an internal command.
It doesn't require for can exactly, but that's it for this, for 3000 shell bash has lots of internal commands.
So, by the way, one of the reasons why this class has.
Why don't just lecture for the entire class and just ask you questions why you're supposed to do tutorials and get hands on experience with the stuff is because these concepts are confusing.
If you just hear about them.
The way they really make sense is by using them. So I don't know if you have not actually tried these commands and play within a trauma. I don't expect all of this to be clear.
I expect you to become clear. After you've tried it
up.
Yeah 14 doesn't apply it in Tropez but yes exactly fork exact is just for external commands.
Right, because that's what it means by external is it's in a separate program binary it's not in the code of the shell.
But shells can have arbitrary amounts of functionality that's the thing when you vary between any shell can be used to run any external command.
What varies between them is ways you can, you know, interact with the shell, and the things that has built in some shells have lots of stuff built in most most modern shells are include a full programming environment.
They have, you know, you can do all these know all these things so
you can't run exit in the background.
Exit in the background doesn't make sense because it's not going to.
It's an internal command it won't run. I mean, it just going to exit.
I don't think there's a binary called exit but what are the cases, the way this is processing, it's just going to interpret exit. And then exit the show, it's not surprising it's not going to start a new show on that I don't know.
if you just want to see a station.
Oh, your wings yeah was supposed to
really shift. Hold on one second, they
come in here. Yes, your.
You come here, you get to say hi to everyone.
She's sitting up the door, and just making a calling to me going like, come on, pay attention to me. Okay, you can say hi to everyone.
Are you happy now.
Are we happy.
Okay.
Okay, I gotta go. Okay, There you go.
That was shift shift will shift can open doors.
She'll jump on the handle like we've accessible have door handles, she'll jump on it and hang on it and then it will will open the door so I actually have to lock my door at night so she doesn't come into my bedroom.
So, it's literally exactly
the password. Yes, yes. Just Schiphol external commands. No no no, she does not. She does like laser pointers though she will sometimes go
back to where we were. So,
so to get your so. So what was it which.
So,
yeah, I got man pages for exit I do not have binaries for exit.
See what I was like, exit,
Huh.
Yeah, it does do that. I did not ever try doing that.
So, if you run exit.
Hi, is it that that is weird.
Let's fill me up. Ask slash some I'm suspecting, I don't know, you'll be able to tell me if this is something to do with either the terminal or the shell but I'm suspecting the way that they make Damon's work, and that's what like the ampersand does right
is just they just spawn another shell secretly and then they, they just tell you that the output.
After that command has been run on that other shell right. And that's why you can like, what it's what it's doing is the child processes the one processing the whole argument.
Yeah, we know is that defined by my shell or by my terminal emulator by your shell. Okay, yeah, definitely by remember your terminal emulator is really is really simulating a dumb device.
It is just doing input output.
It's really there to display text on the screen and take input from the keyboard and they can do some complex things and how it does things on the screen you know there's graphical shells, you can have colored text and other things, but the, the actual
work is being done by the program on the other end of the input yours, you're doing and the thing is providing output to your screen so all the semantics that we're talking about here, this is all bash.
Now when people talk to this term Damon, I should I should clarify, I didn't mention this, so.
If you look at the term Damon, there's kind of like some bad things but if you look in the mythological thing they're also just servants for doing things.
So runs commands right to left. Yeah, I think it may be during commands right to left.
But, yeah,
Yeah, which is 3000 show doesn't parse things that way it parses them differently.
These are the things that come up when you make your own show and you notice that Oh What do regular shows do they do things a bit differently.
But so when we say background things what sort of things are they doing.
So there's an SSH Secure Shell demon running on your virtual machines. That's how you can SSH to them. It is waiting for all the time in the background going like, and.
And in fact, many people can connect to the VM at once. Now there was a question earlier.
So processes.
So,
Now I should mention.
So if you do an S trace on model Linux systems when you do a fork call it won't actually turn into a fork system call it will turn into a clone system call, and it has a superset of forks functionality you go to the main page, really the starts getting
two threads. Again I I'm holding off on the thread thing.
because I can't wait to explain that more properly when we talk a little further but, um, but yeah.
So,
so I might be giving away things that are on the assignment.
Might be
might be.
I'm not gonna, I'm, I'm just talking here.
Um, Yeah, but how much does that help us really
yeah exactly like that's the whole thing it's like it's not about just the answers.
What it really is is you're trying to get a mental model of how all these things fit together. What is going on with the system when I am here and I type in LS what's really happening.
And there's a lot happening here. And it's not I'm we're peeling back the layers of it, the first thing we're taught this market exact.
But now we've got to talk about exactly now if you do a man of.
If we look at for fork is very nice because it just has no arguments, and it returns a process it so we've done this before we've created. Now we've done for consult but then if you look at exactly he.
This is what exactly is it takes three arguments.
It takes three arguments.
Yeah. If you look at.
Now what are the arguments here so some of these are very, you know, easy, its path name. That's the binary to run. That's the one that you mean loading into this process.
rd is the command line arguments that are given. So when you type something is the LS dash l or what you get those arguments. those are passed here by convention, the first element of this array is actually the name of the program being run
doesn't have to be. And in fact, the name of the command of the command that's being run it does not have to be the same as the file.
Those can different, and in fact it's possible to make it so that programs change their functionality based on the name they're given. But first argument in the commandment, or is the name under which it was invoked the rest of his rest of the arguments
in an array of strings.
You know, so. So basically when we type bash bash boards and stuff and does exactly you wish in places it's code with the codes and 16 around the Eliska.
Yep.
Antoine you've got it exactly right.
I'm running part of the executive API you, you get you actually are also paying in passing in command line arguments. Notice that is passed. This is some data that is preserved from the, from the original process before it affect commit suicide and replaces
itself with a new one. We know there are places that code with the code in the new program, the RV data is preserved.
Other thing that's preserved is empty, the environment variables.
Now, environment variables.
By type inside like end.
You'll get so like this, you get all these, and all these things.
What is all this stuff, this is all just data on my environment things like, what's my email list of it since I'm running a desktop I've got a got a lot of things yours, we, if we SSH on to the snow.
Okay, let's see if that works.
So here.
So now, on the, on my VM, I can type.
So, oh,
that's not necessarily better. Okay, that's so here oh these are my LS colors. Okay. These are the colors that are signed for ls this is my shell. So the two there's all these notice these are all key value pairs.
There's something, typically all caps and an equal sign, and then a string pwd, that's the president working directory I'm in home students what named I log in as a student, what type of session our TTY session, you know, manpower, you know, all, they're
all these things. So if you're familiar with Windows.
So.
So it says much key value pairs.
So,
is it working somewhat inefficient, is there a way to create an empty process. So, yes, unit so Linux has a super efficient version of pork.
The amount of memory at copies is actually very, very small.
It does a lot of tricks to do that will do this thing called copy on write memory and things.
So fork is actually pretty fast on Linux, but it could be faster.
And that's what people are working on improving that and that is why I said that before. Exactly. api combination is,
You know is not so thick so.
So working in the foreground is at fault. Why do we fork. So working. So remember, if you're working.
So the problem is if you say, what does it mean to come back to the prompt. The moment you do exactly he and a process the old program is gone.
You can't come back to it, it's been terminated. That's why we create a new process and have it do the exact thing, rather than have the original process do it because if it does do it, it's gone.
This play with it and you'll I think you'll understand it asked me again, still not clear up the next lecture.
Play with it and you'll see what I mean.
Yeah, yeah, we work as always you couldn't return to our shell because the show will be gone.
Exactly.
Oh.
But going back to environment variables, they just tell us all these different things.
So some things like our language.
You know, what we know what's my username, what you know what kind of terminal, am I using.
Oh this is Oh, that's funny.
What were those come from less open less clothes.
There's just all this stuff that could potentially, sometimes they have time zones and they're
just, it varies
Ah, so the reason why I wouldn't say manager and workers, that's typically more using a reading context. Remember the there co equal, except that one's newer than the other.
That's why the parent and child thing is there is because the parent process of the child process me the child is kind of under the control of the parent in various ways as we will, as we will discover, but the child can grow up, and can basically do
everything the parent could given certain circumstances, so it's it's fully functional.
So if you don't provide value for our VNV they're providing none No no, if you. Exactly. If you don't provide any, any values for RV and envy. Nothing is there.
Now, there are some API's that default to certain things but the epic system called level. Exactly. He only passes what you pass it.
So, and way you can see this is in
to forking can we kill the parent process and just keep the child.
Yes, it is possible for the parent process to exit.
And then, and in fact this is actually how you make a background process that's going to run for a long term make a demon is your fork a child and the parent terminates and the child keeps running might even have to do it twice but that's a that's a separate
separate thing.
Every, every program has RV and, you know, so when we type in main. So notice what I say. So there's couple of ways of getting access to environment variables and command line arguments are passed in, as an argument to main.
That's what this is, these are the arguments that are passed to exactly eat. They then show up as the parameters to maintain. And if you have this in environment variables, also work come in as a parameter to me.
You can also act instead of accessing it here you can also define a global symbol called environment.
And that will give you access to the environment variables as well,
your glutes.
So we do a fork the child process has a copy of the parents environment, because they have a copy of all memory.
So,
so defining MVP for your folks definitely gives you access to our belt, it only does it for me. Yes. You can't do it for.
are ones that we will be using.
Yes, you can transfer it to yeah you can pass it around in the program.
And in fact, that's exactly what happens here. We have RV, and MB here, and then we, you notice we pass them on as arguments to these different things.
So prompt loop gets the environment.
And then when we do run program, it gets the environment here. And it also gets arms, which are going to be the command line arguments that have been searched for for run program What is it doing here.
You're know exactly, he, the file name that we've gotten the arguments which we parsed from whatever the command the user types, and the environment variables that were passed in from before.
So we just we just you know basically pass those around now.
Honestly, I could have had NP as a global variable, because I couldn't just use environment but here I supposedly pass it around, because sometimes you might want to change it.
Yeah.
So when I say session, I use your session or shells. When I see a session it's this means when you log in.
Yeah.
The F command just dumps the correct environment variables.
That's all it does.
Rob probably a mind set. So you could actually let you change it run a program modified environment, and use it that way.
So with.
That's funny.
I even forgot about all these things you can do with it.
If you just don't do any arguments with it it just tells you know command Prince the resulting environment
is all I ever use it for.
Will we ever need to worry about modify individual environment variables. Oh yes, that is definitely something you potentially want to do is modify environment variables.
And the nice thing is, since it's local you can only. You can't mess it up for your entire system, unless you change your login thing. So, if I look at.
So, this is here.
Got profile. Yeah, there is that profile. So this is the file that gets loaded. When you first login dot profile executed by the command interpreter for login shells.
So when you first log in this is.
If bash profile of epsilon exists. This is a blood but we got dot profile. And what this does, in fact, is customized environment variables. So when the show first, when you first log in the initial shell will settle this up so every other process that
you create every other program that you run gets the right things, so it first says if you're running bash then include bash are See,
if you're if you're closing users private benefit exists. If you have a bin directory in your home directory it'll add it beginning of path.
If you is a private any of that and then set the man path to this, so this is all stuff manipulating environment variables, that's actually the primary task.
Traditionally, of the dot profile. And then, there's a dot.
This is bash RC.
This is, if you have, if you have an interactive show you one that you're interacting with versus ones that are used just to run commands. This is now setting up your environment to do various things.
It's worth looking through this to see like there's all kinds of stuff that gets changed around the command line, you might notice that LS, are these aliases for LS some colors, you know, loads bash aliases.
Yeah. And tomorrow when you play with that some. And then, then if.
And by the way, if you're wanting sex backup, it's in bash aliases. This is the backup command, and it's defined it as a bash function. Notice that bash has a full program Google environment.
So, we're going to talk more about this stuff and like what exactly happens when you log in and that whole process that's talking about sessions that is coming right now I just wanted to first talk about.
There's a lot of concepts that connect and lots of complex ways.
This is why you can't just read about it.
It's when you if you can, but it just doesn't tend to stick.
So different shells can have different kinds of configurations of Uz sh, they will have its own kind of thing is you see sh and as its own things to see as he has all think lots of different shells.
But dot profile is a bit more standard
program binaries and product executable.
Yeah.
I wouldn't normally refer to a library.
I would technically a library does contain files but libraries, I would say are a collection of object files I wouldn't call an object file a binary know let's see a binary is a reasonable program.
The main reason is not a missing executable program because there are executable programs that are not program binaries. For example, shell scripts.
So here's a fun thing you can do.
So notice I can do something go like.
So I just put sh.
So you see now I have a file here called my script sh.
So all I have to do is,
and it runs like a binary, but it's not. It's a shell script.
Because.
So by putting this magic line here with a pound sign and a interpreter for it to run the rest of it is run by that interpret in this case bash you can do the same thing for Python or for Pearl, or for job at actually for Node.
js can put it in there and then you can make a program that runs there you just have to make an executable program. So he's disease. Shut up.
What did you use Chabad to give permission to the executable. Exactly, because by default. These programs like your normal program, you know, 3000 shell dot c is just readable and rideable it's a text file.
And the way but the binary like 3000 shell the binary. So that will asterisk there at the end that's just to indicate that the experts have been set the executable bits, because every program so we haven't talked about permission but so much, so we'll
talk about that more.
But every file has this notion of this visit readable is it rideable as an executable. And so when you compile this with gcc and make a program binary, the expert gets set automatically.
But if you want to make a text file into a runner will program because you do things like put this at the beginning, you have to make it execute will manually.
And so the commanded desk is Jamaat and you can set those, as you see, like some odd, you know, a plus x will set all the executable bits.
So, we're going to talk about that more to, you know, It's a lot of this stuff showed up in the first tutorial.
There's lots of concepts here that all connect together and I'm trying to show them to you as I need to to explain things but
there's a lot going on, but the but the thing here to notice is that what is this what happens here when the program runs a shell script is.
You do the same thing. If you use the syntax here.
If I just, if I just type in here.
What's still happening here is you're doing a fork, the shelf bashes doing a fork.
And then you're doing exactly of this program, and the colonel actually looks at the file and says, oh, the first line starts with the pound sign followed by a slash and then there's a file and stuff it looks at that.
And then, doesn't exactly have that program, and passes in the text file that you gave it as its argument that goes into RV, and so then it knows. Oh, I was run with this program so I should load it and try running the code in it.
Yeah. Yeah, I agree binary files l files. Yes.
It's, I would not call it precise terminology.
So, There is a program that said it's called file.
This tells you the type of thing so if they say file.
So it says, See source Unicode text UTFA text.
Left along asking tax. But if I say file.
Also ask you.
It says elf 64 bit SB pie as president independent executable x86 version directly link corporate or this bill idea that's so executable and linkable format.
This is the format of binary executable binaries. To be precise. on Linux, they are, it's a standard for creating executable programs. And you might be going.
Why do I need a whole standard Isn't it just code. No and remember that's what you were seeing with object dump and things you saw that there's a lot of sections to it, because it's divided into pieces and those pieces are loaded into different parts
of memory. Some parts of it talk about global variables and some part of the heap and stack me. There's all kinds of stuff in an L file.
But it's the format of executable programs series called 55.
Oh, thank you.
I'm going to end up here. So, we should be is always a program by so we can be noted, yes, it's called object dump. What hex dump does it. Heck stuff does a very stupid version of it, object dump is what you want.