Basic Configuration / Profile & Environment Variables
Subtitles of the Movie
Profile and Environment Variables. Every user has several, in fact a bunch of profile and environment variables which are based on standards such as the current user name, the default editor and the PATH. But before we continue some of you may realize there's literature that suggests that shell and environment variables are different. But for Linux, so long as you're using the default bash shell as assumed by the Linux+ Objectives, they're effectively the same thing. That leaves Profile and Environment variables. Profile variables are configured in the etc/profile file. Some versions of this file revert to individual files in the etc/profile.d directory. In addition, Environment variables are listed in the output to the env command. Now let's look at the specific variables listed in the Linux+ Objectives. If you want to find the current value of a variable apply the echo command and add a dollar sign in front of it so to find the value of the prompt variable, also known as PS1, I run echo dollar ps1 and that gives me the user name, the at symbol as shown here, michael is the user name, h is the host name and w is the directory. The tilde is the Linux way of referencing the current home directory. The PS2 prompt is what you see if you have an incomplete command. One way to show an incomplete command is with a single quote. Let's try printing some file, but I forget to enclose it in the second quote, I get that PS2 prompt. Great. I Ctrl-C out of that and we go on to the next variable. The PATH, perhaps, is the most important environment variable. Let's go to CentOS as that shows the greatest difference in the PATH between the regular user and the root administrative user. Look at that. If I'm running as a regular user and want to execute, say, a file in the user/kerberos/sbin directory I'd have to type in the whole path to that particular file. And that's a lot of extra typing. If you want to change the path for all users you can change the settings in the etc/profile file. If you want to change the path for an individual user options depending on your distributions may be already available in the. profile or. bash underscore profile files. The dot in front of a file means it's hidden. Next, let's look at the EDITOR variable. It's the default editor associated with certain utilities. The default editor for many Ubuntu systems is nano, but let's say I want to use vi, which is the default editor listed in the Linux+ Objectives. To change that environment variable I can export it. EDITOR equals vi and now I can verify the EDITOR has been set to vi and now when I run the crontab command I'm in the vi Editor. How about that? The term variable is sort of obsolete. While it refers to something like Linux or perhaps XTERM that console is superseded in the various Desktop environments such as GNOME, KDE and Xfce. Next, the PAGER variable. There's no default shown here so when I say read a man page it already has some default, in this case the LESS command as a PAGER. If you want to change that to the MORE command we can export it in the same way and now when we run the man man page I can only go forward as is the characteristic of the MORE command. I change it to LESS and not only do I have up and down scrolling capabilities I can search as is characteristic of the LESS PAGER. The HOME variable is a bit more straightforward. As you can see here it's the current user's home directory. If you want to set a PRINTER variable normally it's configured through CUPS, if you exported a PRINTER variable that would set the default printer associated with commands like lpr, the line print command. Well, those are the basics of Profile and Environment Variables. Thank you and on to the next video.
Tutorial Information
| Course: | CompTIA Linux+ Certification 2009 |
| Author: | Michael Jang |
| SKU: | 34070 |
| ISBN: | 1-935320-91-2 |
| Release Date: | 2009-12-22 |
| Duration: | 6.5 hrs / 82 lessons |
| Captions: | Available on CD and Online University |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 98,729 Video Tutorials (23,265 free)
- Video Available as Flash or QuickTime
- Over 1026 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 