1z0-821 Oracle Solaris 11 System Administration – Administering User Accounts Part 3

  • By
  • February 20, 2023
0 Comment

7. User Initialization Files pt. 1

Now that we’ve set up user accounts and learn how to manage users, we need to take a look at user initialization files. Now, initialization files are essentially just text files that are used to configure options for individual users whenever the system starts up and when the user logs on. Most of the ones we’ll take a look at right now are ones that affect the user at login. These particular initialization files that we’re going to look at help to manage the user’s work environment. And when I say work environment, I’m talking about the shells that they can use, the variables that they can use, and so forth. It may set things like the path, the home directory, just various other little nitroid things about the user’s work environment in the shell.

Now, which files may apply to a user depends a little bit upon which shell they’re actually using. And there are different shells and we can take a second to talk about those. A shell basically gives you the options of running different commands with different switches. Most shells are the same, but they react a little bit differently in terms of how they react with different command options switches and how they may output from the results of the command. Different people will actually get used to different shells over time and prefer those shells. For example, Bash, one of the most popular shells for typical users, is probably the most preferred because it’s very easy to use. And if you’re not an experienced user, bash is actually very friendly. A system administrator, on the other hand, may want something like the Z shell and a programmer may want something like the C shell because of the way it handles different programming languages and so forth and scripts.

So you’ll develop over time a preference for what shell you like. The two shells that we’ll talk about in particular with Solaris Eleven are the Bash shell and the Corn shell. The Corn shell sometimes represented by Ksh 93. Now, both of these shells have their own particular profile files that help set up a user’s work environment depending upon which shell they’re using. Now they both actually use the same template file and that’s located in Etsy scalelocal profile. And this file is basically the same for both Bash and Corn shell.

But if you want to change it and make alterations to it that apply to all users, you can do that. And the next time a new user is created, it will use that file as a template for its profile files. Now, let’s talk specifically about Bash for a moment. The born Again shell is what it’s typically called and it has several different profile or initialization files that are specific to its shell for the user. Now most of these are located in the user’s home directory. Now right here on the screen you see the dollar capital home and that is typically representative of the user’s home directory that’s the variable that represents that. We see that in dollar home, which might be homebobbie or home ted or whatever the user name is in that home directory. There’s the Bash underscore profile text file, initialization file and that defines the user’s environment and login. You also have the Bash underscore login and the dot profile files that are also in the user’s home directory. We’ll take a look at those in the next session. For the Corn shell, which is also located at Bensh, there’s the Slash etsy profile file and that defines the user’s environment. Whenever they log in.

For the Corn shell in their home directory, there’s also a profile file and that helps define the user’s environment even further. Now there’s a dollar env variable and then this variable that defines the user’s environment at login and that’s specified by, again, the environment variable. And we’ll look at some of these things, these variables here in a second. Environment variables are basically shell dependent and they’re typically good only for the logged in session. They won’t remain or persist between login sessions. If you needed to set one permanently, you’d edit the Bash RC file to do that. That way you would get the same variable over and over between login sessions. Now there’s a couple of different ways to see variables and their values in Bash. You can use the declare command or in the corner shell you can use the set command and you can also echo a variable to the screen. Remember that variables are usually all caps in Unix and Linux and preceded by the dollar sign. Let’s take a look at a couple of variables now.

Okay, we’re back in solaris eleven and we’re in Bash. So I want to run the declare command and you’ll see all the variables that are there assigned to Bash. Now there’s typical things like the shell, which shell to use the user ID, my username is shown things like this and these variables can be used in programming to reference their values. So that’s one reason you have variables. Let’s clear this and let’s go to the Corn shell and we can use the set command and we’ll see almost the same thing, different variables. And there may be a few differences here, but essentially they look the same. I’m going to exit back to the Bash cell and I could also type in Bash if I wanted to. Either way, I get back to Bash and I want to echo a variable to the screen. Let’s echo dollar home and that shows what the variable data is for the home variable. And there are different variables that we can look at and get that information from. So those are variables. And then the next session we’ll actually look at the profile files, the initialization files for the users that you can see in their home directory and in other directories.

8. User Initialization Files pt. 2

We’re back in our Solaris Eleven command line interface, or shell prompt. And what I want to do is show you some of the initialization files, the profile files, if you will. The first thing I want to do, let’s look at where we’re at in the system and we are in the we’re in my home directory, and that’s where you’re going to find a lot of these initialization files at. So let’s look at what we see in here. There’s not much in there. That’s because a lot of these profile files are preceded by a dot, which means they’re hidden from a normal directory view. Let’s do an Lsal. We’ll actually see a lot more in there than you might think. And there’s a dot profile file here, and there’s a lot of other files here, too, that we won’t go over that are different configuration files. And a lot of these are environmental files that will set up things like Gnome, for example, mozilla, Firefox or whatever.

My shell history file, my Bash history file, and so forth. So there’s different files in here we could look at. And all of these files help configure our particular login environment. We’re not going to look at all of them. I just want to show you just a few that we’ve discussed so far. What I want to show you is the profile file, and that’s for Bash. So let’s do a cat profile and we may have to scroll a little bit to see what it all contains. And it’s basically used to set up a few things. Our export path, our pager. And our pager is what we use to paginate long files like less or more. So this sets up whether we’re going to use less or more by default if we don’t specify one.

And it also sets up our prompt. And the prompt is like the little dollar sign or the number sign. We can actually change our prompt to make it look almost like a Windows prompt if we wanted to. And some shells do that by default, show you the path name, where you’re at in their prompt. And we could set this up if we wanted to. And so there’s not much in this particular file. And if we go to the Etsy profile, one that applies to all users, and there’s some different things it shows. Let’s take a quick look. Scroll up just a bit and we see that. First of all, it traps some error possibilities such that when the profile is run before the user logs in, that prevents certain things from happening before the profile takes effect. Sets your terminal. It looks at your different shells that you’re going to use. So it knows how to pass this off to the particular shell profile that you’re going to use, the one that we just looked at in your home directory. And it lists different shells.

It lists the born shell, the born again shell. Obviously, bash, the K shell. There’s a couple of shells that list that we didn’t talk about, the Z shell and the J shell. There are other ones we can use. There’s also the Seashell we didn’t include in there. It looks to see if there’s quotas involved. It also looks to see if you have mail, if mail is set up for your account. So it looks at a couple of different things and sets up a couple of different options. One of the things you’ll see that it sets up there is the umask, and that you mask is 22. And we’ll talk more about the U mask when we talk about file permissions and file and system access later on the course. But it sets that umask for you, the user, right there. So there’s a couple of different profile files that take place here, and we’ve looked at a couple of them, and there are many more in here. Obviously, there’s your shell history file.

There’s your Bash history, as a matter of fact. And if we want to look at that, let’s see if we can move our cursor a little bit better here. We could take a look at that. We could also take a look at the Bash RC file. And that’s the file where if you want some variables to be persistent between login sessions, that’s where you would set that up at. Now, these profile files can call each other. In fact, there’s probably several profile files or initialization files that your computer looks at while you’re in the login process, before you actually get to a shell prompt or before you even get to the desktop. And it sets up different variables for you, different pieces of your environment for you, so you don’t have to worry about doing that when you log in. If you didn’t have these initialization files, you would probably get to a bear prompt and not know exactly where you’re at in the file system. You wouldn’t have certain things set up for you. You’d have to manually go in and set those things up first before you could even probably work at the shell or at the desktop. So they’re very useful for those kinds of things. And again, there’s more than just the initialization files that we discussed, but those are the primary ones you probably need to be familiar with for the exam and just to start out your knowledge of profile files and so forth. So take a look at those, and you can also change a few of them if you like. Just be very careful. They typically won’t cause bad damage to the system or to your login. If you change them in a bad way, you just may have to back them up and restore them from a backup. That probably would be the smartest thing to do. So go in and play with them and practice a little bit. Looking at them and seeing what they contain and then you’ll be on your way to much better understanding of the initialization files that you might see on the exam and in real life.

9. Shell Metacharacters

Now let’s take a look at using shell meta characters. Shell meta characters are no different than normal characters. In fact, they are normal characters. However, these particular characters have special meaning to Unix, to Linux, even to Windows in certain circumstances. But particularly they have special meaning to the shell itself, the command line interface, and they interact differently with the command line interface in the shell than normal characters do. Some of these characters are used to add command options, command parameters. They’re used to separate paths in the file system, concatenate, information, traverse directories, and so on. And there are many different meta characters out there. I’ve included a few examples on the screen.

The ones in red are the actual meta character, the commas in blue are not. They include things like the star dollar sign, the question mark, the single dot, the double dot, the dash, the slash, the ampersand, and the pipe signal. And there are several others as well that I didn’t mention here. Any case, these metacaracters interact differently with the shell and do different things. Because of that, you probably should not include them in file names. They’ll typically be called illegal characters in a file name, and you may not want to use them in certain other instances as well, because the shell may interpret them as doing something differently, as performing an action versus part of a file name. So having said that, let’s go to Solaris Eleven to a command shell, and we’ll just do a couple of commands that have these in there so you can kind of see how they interact and what they do. Okay, we’re in Solaris Eleven at the command shell, and I just want to show you a few things about these shell meta characters. And I’m sure you’ve actually seen this stuff before. In fact, during this course we’ve actually used shell meta characters several times.

And maybe you didn’t know what they were called. You’ve seen them if you’ve used Linux or Unix before, and even if you used Windows. Again, you just may not have known that’s what they were called. So let’s take a quick look. First of all, I want to do a directory command. Let’s see where I’m at. I’m in my home directory. I want to just look at everything in my directory. So if I just do an LS, I get just that. But if I use some options with the LS command such as LS al, I see a whole lot of things in there. And I noticed that the separated command options out, they added to the command itself. Now there are some other types of files in here that we can see the hidden files. Now let’s change directory using the double dots, and that actually takes us up one. Now we’re in the home directory for everyone, and right now that’s the only user that has a directory in the home directory. But you saw how the double dots kind of took us up one directory. Now let’s change to a different directory altogether.

Let’s go to, let’s say, Temp and see what’s inside there. So we use the backslash as a meta character. Now let’s do an LS again, and we see several files in here. Now we can do an LS Al again to get a complete listing. And that’s everything that’s in the Temp directory. Now, let’s say I didn’t want to see everything. I just want to see certain files, maybe a list of all the files that have dbus at the beginning. What I may do is type something like LSD bus and put a star there. That star is a wild card indicator. It’s a meta character. And it shows me all the files that start with the word D bus. And there’s two of them. So that’s another example of a meta character in there. Now, there’s also a meta character that redirects files, and that’s the less than greater than sign.

And those two signs can do different things. It can redirect command input to another file. Let me show you what I mean. Let’s do an Lsal, but let’s send it instead of sending it to the screen, let’s send the standard input to a file to direct dory text, and let’s send it there. And it didn’t go anywhere. We didn’t see it on the screen, but it actually became part of that directory text file. So if we look in the directory now, it’s there. So if we were to cat that, we’ll see that actual directory in that text file. It’s the text file we’re looking at. So that’s kind of a neat thing with the command redirection thing. There’s also a pipe symbol that you can use to take commands and pipe them to another command. That’s the pipe symbol, and it’s usually on near the right hand side of your keyboard, usually above the inner key. It really depends on how your keyboard is laid out. And you can do things like PS, for example, and get all the processes.

And what if you did a PS? Let’s say let’s do an EF, see if that works with Solaris. It does, and there’s a lot of processes there. So what if we wanted to look for a particular thing? Maybe we wanted to look for, say, Bash itself. So we would look for PS EF, and then we would pipe that using that meta character into grab the grep command, and we’d search on Bash. So it takes that output from the PS EF command. It pipes that output into the input for another command, the Grep command. And we’re looking specifically for Bash. And we get that. So that meta character can be used to find specific information from another command or use specific information in another command. So that’s just an example of metacaracters in the shell and how you would use them. We haven’t covered all of them. There’s still a few more out there, but kind of do some reading and playing around and you’ll learn them a little bit better. And you need to know them for the exam.

Comments
* The most recent comment are at the top

Interesting posts

Everything ENNA: Cisco’s New Network Assurance Specialist Certification

The landscape of networking is constantly evolving, driven by rapid technological advancements and growing business demands. For IT professionals, staying ahead in this dynamic environment requires an ongoing commitment to developing and refining their skills. Recognizing the critical need for specialized expertise in network assurance, Cisco has introduced the Cisco Enterprise Network Assurance (ENNA) v1.0… Read More »

Best Networking Certifications to Earn in 2024

The internet is a wondrous invention that connects us to information and entertainment at lightning speed, except when it doesn’t. Honestly, grappling with network slowdowns and untangling those troubleshooting puzzles can drive just about anyone to the brink of frustration. But what if you could become the master of your own digital destiny? Enter the… Read More »

Navigating Vendor-Neutral vs Vendor-Specific Certifications: In-depth Analysis Of The Pros And Cons, With Guidance On Choosing The Right Type For Your Career Goals

Hey, tech folks! Today, we’re slicing through the fog around a classic dilemma in the IT certification world: vendor-neutral vs vendor-specific certifications. Whether you’re a fresh-faced newbie or a seasoned geek, picking the right cert can feel like trying to choose your favorite ice cream flavor at a new parlor – exciting but kinda overwhelming.… Read More »

Achieving Your ISO Certification Made Simple

So, you’ve decided to step up your game and snag that ISO certification, huh? Good on you! Whether it’s to polish your company’s reputation, meet supplier requirements, or enhance operational efficiency, getting ISO certified is like telling the world, “Hey, we really know what we’re doing!” But, like with any worthwhile endeavor, the road to… Read More »

What is Replacing Microsoft MCSA Certification?

Hey there! If you’ve been around the IT block for a while, you might fondly remember when bagging a Microsoft Certified Solutions Associate (MCSA) certification was almost a rite of passage for IT pros. This badge of honor was crucial for those who wanted to master Microsoft platforms and prove their mettle in a competitive… Read More »

5 Easiest Ways to Get CRISC Certification

CRISC Certification – Steps to Triumph Are you ready to stand out in the ever-evolving fields of risk management and information security? Achieving a Certified in Risk and Information Systems Control (CRISC) certification is more than just adding a prestigious title next to your name — it’s a powerful statement about your expertise in safeguarding… Read More »

img