Corning Community College
UNIX/Linux Fundamentals
Getting Started on the Journey
Information at Wikipedia:
In “UNIX for the Beginning Mage”, please read:
In “Harley Hahn's Guide to UNIX and Linux”, please read:
In “Learning the UNIX Operating System, 5th Edition”, please read:
UNIX is a multiuser, multitasking operating system.
Developed at Bell Labs in the early 1970s, UNIX has formed the foundation of much of computing as we know it. Just as the PDP/11 hardware that greatly influenced even today's computer architectures, UNIX is home to a philosophy of computing and information usage.
Computer Science curriculums over the past 30 years have reaped the benefits from having this relatively open, flexible, and in a way standardized environment to promote learning of essential concepts, as well as to drive innovation and to create new and exciting breakthroughs.
UNIX was created out of a need for a flexible operating system that would allow productive use of computer hardware. Truth be told, the original developers wanted a portable means of playing one of the first computer games- Space War.
But outside of those initial goals, UNIX found its use in the fields of text processing, filtering, programming, automation, and many other areas. With the dawn of packet switching computer networks (such as the internet), UNIX also acquired the legendary reputation it has today- a robust, reliable, and efficient server platform for deploying network services and other mission critical tasks.
With the growing popularity of Linux and the Open Source movement, the ideals of UNIX (whose dominance was being threatened by the likes of Novell Netware and Microsoft's Windows NT) were given a second chance, and in recent times we've been observing the rise of UNIX once again through Linux (as well as the open source BSDs), supplanting Netware, and is now considered by Microsoft one of the top threats to its monopoly.
No longer purely a server platform, Linux is also driving a newfound push for end-user desktop environments, games, web browsing, word processing, and other common computing uses.
Linux can no longer be termed “exotic” or “esoteric”. Instead, it is becoming a significant force in the computing industry and thus acquiring proficiency in Linux is a growing skill that is increasingly being sought by employers.
Rarely a week goes by now where Linux doesn't make the headlines in some way. Government bodies switching to Linux and Open Source Office Suites to save on operating costs and avoid vendor lock-in; Established industry players, such as IBM, HP, and Novell, put their support behind Linux, through using it internally, selling products with it, providing support for it, and even hiring people to develop functionality for it; Every so often we even see the bigger media stories of large investments involving Linux, such as when NASA bought 10,000 processor computing cluster from SGI that runs on Linux.
This class offers you the chance to partake in an incredible journey- one that can open many new doors and opportunities; to help you unlock some of the hidden potential trapped inside your computer (and what's more, within your own abilities to solve problems and view the world); and to be aware of other possibilities available to you when designated with the task of using the computer to solve a problem.
Be you in pursuit of the computer sciences, high-performance computing, networking, web development, traditional sciences and mathematics, education, liberal arts, or just new skills and experiences, welcome to the adventure!
To log onto the system, you will need to establish an SSH (Secure Shell) connection from your local host (the machine you are physically sitting at or operating) to Lab46, the remote host (the machine to which you are connecting).
Download
Click on the link to download: PuTTY.exe
For those using a Windows-based system, you will need to obtain an SSH client, as such tools are not typically installed by default. The recommended SSH client for Windows is PuTTY, which is a free download.
Upon downloading and running it (yes, it is okay to trust it), you simply:
The first connection attempt you make from any local host will prompt you with a query on whether or not you can trust the authenticity of this remote host. Simply answer “yes”.
You should then be prompted with a black screen with white lettering, asking you for your “Username:”… type in your CCC username (it is the same as your Lab46 username).
Note
When typing in your password, NOTHING will be echoed to the screen. This is normal. Type it in blindly.
Following that, you will be prompted for your “Password:”. Note that when you type your password in, NOTHING will be echoed to the terminal screen (not even *'s). You MUST type in your password blindly. This is a feature.
Assuming your username and password pair were entered successfully, you should now be logged into the system and met with any pertinent login information, typically the “Message Of The Day” (MOTD), and finally a prompt, that will look like:
lab46:~$
If so, you can skip ahead to the “Logged in” section below.
For those with the great fortune of being able to work from a machine with the command-line SSH tools installed, your task is as easy as:
Note that “USERNAME” is the same as your CCC username, and is all lowercase. ANY uppercase letters will be in error and prevent the successful authentication and subsequent login to the system. If you are in the habit of capitalizing the First Letter of Usernames, you should break that habit while working on the UNIX system.
If this is your first time connecting to Lab46 from the particular computer you are at, you will be prompted to confirm the authenticity of the remote host. Simply answer “yes” (and note that you literally have to answer y-e-s; simply trying 'y' will result in a request to enter a “yes” or “no” answer).
You should then see the following appear in your terminal:
USERNAME@lab46.corning-cc.edu's password:
Note that when you type in your password, it will NOT be echoed to the screen. You must type it in blind. This is a feature.
Assuming your username and password pair were entered successfully, you should now be logged into the system and met with any pertinent login information, typically the “Message Of The Day” (MOTD), and finally a prompt, that will look like:
lab46:~$
If so, you can move ahead to the “Logged in” section.
As you find yourself logged in and able to use the system, you key point of contact will be with the prompt.
The prompt is the system's way of informing you not only of your ability to interact with it (seeing it with the cursor after it indicates the system is ready for more input), but also some important information to help you identify your whereabouts.
In its default form, when you are residing within your Home Directory on the system (the default starting place whenever you log in), it will appear as follows:
lab46:~$
To break it down further, your prompt consists of the following information:
System Name | Field Separator | Current Working Directory | Prompt Symbol | |
---|---|---|---|---|
lab46 | : | ~ | $ |
Hopefully the system name makes sense– this is the system we are now on, to which we have connected. Our terminal window is an eye into this remote system.
The field separator is just that- something to visually/logically separate data, in this case so the Hostname (lab46) does not collide with the Current Working Directory.
The Current Working Directory represents your current location on the system. By default, if you are residing in your allocated home directory (the default starting place when you log in), the directory will be represented as a tilde (~) symbol. Consider this the universal symbol for your home directory. As you move about the system, you will notice how your directory representation changes.
Finally, you see the Prompt Symbol. The common representation these days is the '$', to designate a normal user. If you are an administrator, the typical symbol is '#'. This helps to visually differentiate authority, as it is not an uncommon activity to have multiple terminals in use at one time, and these visual cues help to anchor in our mind where we actually are, so we do not accidentally issue commands that would lead to unfavorable outcomes.
Although the formatting of the prompt is by no means set in stone nor uniform across different systems, becoming familiar with it on Lab46 will help you to better interpret the information being conveyed, and to better adapt should you encounter a different style prompt on another system.
As indicated, the presence of the prompt with the cursor immediately following it indicates that the system is ready to accept input from you. This comes in the form of commands, spells, incantations, etc. to operate within this universe.
Your zeroth quest has nearly been completed- the first requirement is to successfully instantiate yourself in this magical realm, which if you've been able to successfully log in, have already achieved.
As your skills increase, opportunities for putting them to the test will become available. Questing is the primary means by which you will be doing this.
The second requirement is to actually “go questing”. This is the basic requirement for any quests you will embark upon.
To enable yourself to quest, you must cast the 'quest' spell.
Go ahead and do so now— by typing 'quest' at the lab46:~$ prompt and hitting enter, you will accomplish this:
lab46:~$ quest Questing mode ENABLED. lab46:~$
At this point, you are able to commence upon any quests you are pursuing.
Continuing on in Questing mode, we want to establish a “data” directory in the base of your home directory (aka ~/data/).
This will be used for submitting requested materials for evaluation, and even providing some availability of status related to this course.
To get started, you will need to be introduced to a few spells to aid you in determining what is going on.
The first spell is: ls
ls is short for “list”, and when invoked on the command-line, will by default list all the files in your current working directory. ls can be considered one of your vision spells– whenever you want to see what is going on in any location, ls it and you can obtain further information about your surrounding environment. Cast it often.
Since you just started out, you SHOULD be in the root of your home directory… but just to be sure, here's another quick spell: cd
cd is short for “change directory”, and when invoked all by itself, will snap you back to the root of your home directory (it is sort of like the dorothy w/ red slippers remedy to your locational ailments— whenever you realize “there's no place like home”, just cast “cd” and hit enter, and bam! Back home you will instantly materialize!
So, go ahead and:
Most people will see two blue-colored files– “public_html” and “src”, these are actually directory files, and can be used for storing data. public_html is particularly noteworthy as it is an open terrace attached to your home, allowing you to interact with the realm of the world wide web.
Once you have taken a “look” with ls, let's create your data/ portal:
In a way, what we're doing is creating a portal… a directory for you already exists out on the system, but it is far away from your home. Instead of constantly seeking it out, we will instantiate a portal to allow you convenient access right from the comforts of your own home!
For this, you will encounter another spell; powerful, but not as regularly useful as ls. So be mindful of it, and add it to your mental inventory of available spells. The new spell is: ln
What ln does is create links. We use it to connect two realms together– in this case, we are bringing the availability of a distant directory right into your home! Such feats of magic, as you will soon realize, are but a regular occurrence in the mystical realm of UNIX.
At the moment, you may find the full purpose of ln to be a bit overwhelming. It isn't beyond your level of understanding, but it isn't something you can likely yet whip out as a trick to impress friends at parties.
Because of this, I will provide you with the necessary guidance… cast this invocation of the ln spell as follows:
lab46:~$ ln -s /usr/local/etc/data/$USER data
Of particular note with the above spell you are to type in to cast– you will see and some may correctly recognize as a variable, the text $USER. As we will learn in a few weeks, variables grant us a level of flexibility in our activities. For now, it is important to realize that you MUST type in literally $USER, and do not attempt to replace it with $yourusername, or accidentally not specify it in uppercase, otherwise your progress through quest #0 will encounter a confusing hiccup. So, again, make sure you type $USER, exactly as written.
Be very careful when casting spells. Spelling and case are quite important! As are spaces! Misspelling or messing up a portion of your spell could mean the difference between pulling a dove out of your magic hat, and turning your magic hat into an elephant, now crushing your hand beneath its mammoth weight!
When you cast a spell successfully, and all goes as according to plan, you will generally get your prompt back (unless there is any output associated with the spell). In this realm, the assumption is you are in command, so the universe will not hold your hand every step of the way.
With that said, at the sight of a typo, the universe will recoil from your error, and you can almost immediately sense something is awry. Pay attention to the resulting symptoms (using your READING SKILLS) and determine the appropriate course of action.
After casting the spell to instantiate the portal to the distant realm within your house, we should check to verify its existence.
lab46:~$ ls
Go ahead and cast your sight spell, and compare what is present now to what was there moments ago. Notice any change?
You should notice an additional file, this time colored cyan.
When dealing with links/portals, the emanate one of two colors— cyan indicates the portal is connected on both ends, and can be safely traversed (and spells cast through).
Portals that show up as red indicate that one of the ends is non-existent (the far end), and they are unsafe and unable to be traveled.
Okay, so if you've successfully created your portal, and can see it clearly residing within your home, let us wander through it to tend to some lingering matters on the far end.
To do this, we call upon a spell we've already learned: cd
Let us CHANGE DIRECTORY from our current location, to the destination on the far end of the portal:
lab46:~$ cd data lab46:~/data$
Hold up, what just happened here? Notice that? Your prompt changed.
Your prompt, being in some ways an ever-present assistant during your journeys in this universe, will do its best to automatically reflect your current location.
The “~” (tilde) symbol is actually the universal symbol for “home directory”.
The presence of “/” (forward slash) indicates a directory separator. In our case “~/data” will indicate we are now in the data subdirectory of our home directory.
Which is absolutely true, while at the same time being in a location far distant from our home directory. Portals are great like that.
Okay, so we've traversed through the portal… what's here?
Let's take a look: ls
Everyone should have a green colored file in all capital letters called “README”.
Green files indicate they are runnable (or executable), aka castable. They can be cast just like other spells… only they are not universal knowledge.
This particular file invokes some intuitive awareness hinting that its purpose is to be read, like a wayward signpost you can encounter on a journey… potentially host to some intrinsic knowledge of how the very universe is bound together! In this case, it merely contains some information important to the conclusion of our first, zeroth, quest. So let's have at it!
When dealing with a spell that is universal knowledge, you can cast it just by typing its name and hitting enter.
Go ahead and try that here… you may notice our efforts are not met with success:
lab46:~/data$ README bash: README: command not found lab46:~/data$
When you see this, it means you tried casting a spell (or instantiating an incantation of one or more spells), and the universe was unable to coalesce in harmony with you. No magic was able to take place.
Non-universal spells need a little extra help to get going, namely in the form of providing some locational information.
Introducing: .
Yes, the dot, or period symbol.
Like “~”, “.” also carries universal meaning— it is the universal symbol for “current location” or “current working directory”.
We can use that here to indicate that in our current location, we wish to cast this localized README spell, and see what insights it can produce. Go ahead and cast it:
lab46:~/data$ . README
AND EXPERIENCE THE INFINITE WISDOM THAT IS OFFERED!
Wow, that was pretty easy, huh?
Now that our zeroth quest has concluded, let's wrap things up.
The spell you just cast was actually a cast-once spell… as you read, it went up in a cloud of smoke after you cast it, and no longer possesses a tangible existence.
Go ahead, take a look: ls
Not there, is it? But wait! Is there something else in its place? THAT is the status file indicating your completion of the zeroth quest… it contains various bits of information pertinent to that quest.
Want to see inside it to see what it says? ls shows you that it is there, but to enable your x-ray vision of sorts, go ahead and cat it:
lab46:~/data$ cat results.unix.quests
How's that for pretty freaking amazing? Yeah, I thought so.
With nothing else left to analyze in our “data” room on this side of the portal, let us return home.
Hopefully you can all recollect one way to do that; we learned that can just enter “cd” and hit enter at the prompt.
But if you want to be a bit more economical, why not just walk back through the portal from whence we came?
To do that, we cast the following:
lab46:~/data$ cd .. lab46:~$
And bam! We are back home. Mission accomplished, all in a day's work.
To add to your repertoire: .. is the universal symbol for “parent directory”, or one level below where we presently are. We came through the portal from our home directory, so we were essentially one level above it, so going one level back leaves us in our home. Relative navigation.
You can now disengage quest mode:
lab46:~$ exit Questing mode DISENGAGED. lab46:~$
And be on your way. This quest is concluded.