User Tools

Site Tools


haas:fall2019:unix:labs:lab0

Corning Community College

CSCS1730 UNIX/Linux Fundamentals

Lab 0x0: Introduction to UNIX/Linux and Lab46

~~TOC~~

Objective

To become familiar with the command-line through exposure to some simple commands.

The student will also be presented with traditional UNIX conventions they are expected to become familiar with and use throughout the semester.

Reading

In “UNIX for the Beginning Mage”, please read:

  • Chapter 1 (pages 6-8).
  • Chapter 2 (pages 7-19).

In “Harley Hahn's Guide to UNIX and Linux”, please read:

  • Chapter 1 (“Introduction to UNIX”, pages 1-8).
  • Chapter 2 (“What is UNIX? What is Linux?”, pages 9-36).
  • Chapter 3 (“The UNIX Connection”, pages 37-54).
  • Chapter 4 (“Starting to Use UNIX”, pages 55-72).

In “Learning the UNIX Operating System, 5th Edition”, please read:

  • Chapter 1 (“Getting Started”, pages 1-16).
  • Section from Chapter 3 (“Changing Your Password”, pages 62-63).
  • Section from Chapter 6 (“Electronic Mail”, pages 108-118).

What is UNIX?

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 Microsoft's monopoly.

No longer purely a server platform, Linux is also driving a newfound push for alternate desktop environments, games, and other common computing uses.

Linux can no longer truly 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. City of Munich's (in Germany) city government is in the process of switching to Linux to save on operating costs. Big name support by the likes of IBM, HP, Novell. NASA buys 10,000 processor Linux cluster from SGI.

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 to be aware of another option available to you when designated with the task of using the computer to solve a problem.

Be you in pursuit of the computer sciences, networking, web development, traditional sciences and mathematics, education, liberal arts, or just new skills and experiences, welcome to the adventure!

Case Sensitivity

UNIX/Linux is case sensitive!

What this means is that commands typed on the system are distinguished from one another not only based on their spelling, but also whether or not they use upper or lowercase letters.

For example, in UNIX/Linux: “Word” is distinguished from “word” is distinguished from “WORD” is distinguished from “wORD”. Case matters.

Usernames on UNIX systems are traditionally in lowercase, so be sure your CAPSLOCK key is turned off and you do NOT capitalize the first letter when entering your username on login. Passwords are often composed of many letters, numbers, and symbols, so unless you specifically know something is uppercase, chances are you need to use the lowercase equivalent.

Logging In

If you haven't already, obtain your CCC username/password. (This information will be given out by your instructor or e-mailed to the e-mail address you have registered with MyCCC).

IMPORTANT: If you have not received information on your Lab46 account, please contact your instructor (haas@corning-cc.edu) immediately. Send along your CCC username (what you use to log into the MyCCC website or log into the computer labs).

1. Using a Secure Shell terminal program of your choice (such as PuTTY for Windows), do the following:
a.Log into the following host: lab46.corning-cc.edu
b.If using PuTTY, be sure to select the SSH protocol.
c.When prompted, enter the username and then password provided to you.

Passwords

If this is your first time logging in, you will be prompted to enter a new password.

Please create a 6-8 character password, using at least two numbers or symbols other than lowercase letters), that is known only to you.

NOTE: As is commonplace on UNIX/Linux systems, when you enter your password, nothing will be echoed. On Windows-based systems you may be used to seeing “*” appear as you type in a password. On UNIX you will see nothing.

MOTD

UNIX systems, like web sites, or bulletin boards, or any other resource that is utilized by several people, is ultimately a form of community. And, like any community, events take place which affect the members of that community.

In a city, when construction takes place, appropriate notices often appear in the local newspapers, radio broadcasts, or televised news. When there's an office picnic or staff meeting, one often sees an official memo or flier on the bulletin board.

On a UNIX system, there is also important information that must be relayed to users. Sometimes we must take the system down for maintenance or reboots, or to let users know about certain new features. For this reason, UNIX systems have what is known as the “Message of the Day” (or MOTD). Upon successful login to a UNIX system, the system will display the MOTD to you before your initial prompt appears.

The text you see displayed to you consists of the contents of the /etc/motd file.

*PLEASE take the time to read any information presented in the MOTD display.*

The Command Prompt

After all the login information has been displayed you will be presented with the command prompt. It should look something like:

lab46:~$ 

This prompt is broken into three parts. The first part- “lab46” is the hostname of the system. Following that is a colon to separate the hostname from your current directory.

The “~” (tilde) is a representation of your home directory. Your home directory is, of course, the default place you start out everytime you log into the system. All of your files are located here. Each user has their own unique home directory.

Finally is the “$” symbol which represents the end of your prompt. (In some cases it may be the only visible entity of your prompt). Historically, regular users will have either a “$” or a “%”, depending on your shell. The superuser (also known as root) would have a “#”.

Whenever this prompt is displayed it means that the system is available to accept input from you.

Location

As stated above, your default prompt will show you are in directory “~”. This symbol actually expands out into a real directory on the system, as seen with the pwd command.

2. Do the following at the prompt:
a.Run the pwd utility.
b.What happens?

In many cases, you can freely substitute “~” and its actual representation.

Navigation

Having methods of labelling (location) and organizing data is very important in a filesystem (just as it is with a filing cabinet). However, what good is it if you don't have effective ways of retrieving that data?

Navigation plays an important role, allowing you to move around the filesystem, just as you would drawers of a filing cabinet, taking you to the desired destination where you can view data, or store new data.

Because UNIX/Linux systems (like many other systems) use a directory-based system (sometimes directories are referred to as “folders”), we describe navigation in terms of changing one's current directory. The “cd” command, which stands for change directory, is our key to getting around the system.

3. Do the following, and if you get any errors, read the note below:
a.Every account on Lab46 has a src subdirectory for writing programs. Change to that directory now by entering “cd src” at the prompt (without the quotes, of course).
b.Record the current appearance of your prompt. Type pwd again. How has it changed?
c.Now return to the previous directory by typing “cd ..”. This drops you down one level in the directory tree. You should now be back at the base (or root) of your home directory.
d.What do you think will happen if you issue a “cd ..” again? Take a guess and then try it. Were you correct?

NOTE: When you issue a “cd ..”, be sure that you put a space between the “cd” and the “..”

If you see a “command not found” error message when using “cd ..”, make sure you've inserted that space, otherwise the system will try to interpret the entire string as a command (and “cd..” doesn't exist as a command on the system).

Shortcut

No matter where your travels take you, there is often no place like home.

All Dorothy needed to get home was to click her heels together 3 times, and repeat “there's no place like home”.

Luckily, UNIX makes use of similiar magical feats, and it is much easier to find your way home at the end of a journey across the filesystem.

When lost, homesick for your home directory, or in general need to get back to your own data, simply type “cd” and hit enter (without the quotes) at the prompt, and you will automatically be whisked back to your home directory, safe and sound.

Listing

One of the most important functions you'll want to employ when dealing with files and directories is the ability to view what is there. What better way to figure out what to do with the data if you can't figure out its current state.

In UNIX/Linux, to list your current directory we use “ls”. Whenever you have a question regarding what files may be present, or named, or anything, it is quick and easy to type “ls” and hit enter.

Think of “ls” as a set of eyes into the filesystem. Use it whenever you need or want to.

So remember- to list, just use “ls”.

Creating Directories

To better organize your files, you may wish to create additional directories. This is accomplished via the mkdir command. The common invocation will be of the form: mkdir newdirectory

To list files in your current directory, we use the “ls” command. Type it now, and view the current available files and directories.

For example, create a new directory named temp:

lab46:~$ mkdir temp

Type “ls”, and take notice to the line pertaining to temp.

To remove an empty directory, the rmdir utility can be used.

4. In the base of your home directory, do the following:
a.Check the files in your home directory. Do you have a bin directory?
b.If not, create your own bin directory. How did you do this?
c.Remove the temp directory you created in the above example. How did you do this?

NOTE: /bin and bin are *not* the same thing. You want to create your own bin directory.

Who is On?

Because Linux, like UNIX, is a multi-user multi-tasking operating system, many users can be logged in at the same time. Your account can also be logged in more than once.

5. Do the following:
a.Run the “who” utility from the command prompt.
b.What happens? Explain the results.

What you will see, if you are lucky, is a list of users (including yourself) that are currently logged into the system.

You will also see other information associated with each user. For instance, under the MESG column, users will have either a “+” or a “-”. This is the flag (or setting) that determines whether or not that user is allowing message requests (you can send quick messages and chat with users).

To determine the current state of your setting, use the mesg command. It will tell you if it is “y” (a “+”) or “n” (a “-”).

This will allow you to toggle your ability to be messaged while logged in (note- turning messages off has no effect on your e-mail).

6. Play with the mesg utility:
a.Turn off messages: mesg n
b.List the users currently logged in with the who utility. Is there any change?
c.How would you turn your messages back on? Does it work?

Your use of mesg can vary. Some programs will automatically disable messages for you when you use them (such as alpine), while others will not.

Check Your Mail

You may have noticed a message when you logged in that said “You have new mail.” This of course means that you have received one or more new messages in your inbox that are available to be read.

There are several mail user agents (MUAs) available, as you are probably already familiar. On Lab46, a popular program to use for mail is alpine.

7. Do the following:
a.Start alpine from the command prompt.
b.Check your e-mail.
c.Send an e-mail to yourself.

If this is your first time running it, you will get a few banner screens. One will ask you to participate in an alpine census, asking if you want to send the alpine project an e-mail to “count me”.

Along the bottom of the screen will be listed (often in two rows), the commands available for you to use. All available commands will be displayed in reverse video, then followed by a brief description of their action. Some commands will consist of a single letter. Others will be prefixed with a caret symbol (^). Traditionally, the ^ represents a control character (which is obtained by holding down the CTRL key and then pressing the desired key on your keyboard).

A common example of this is the CTRL-C sequence, (which is created by holding down the CTRL key on your keyboard and also pressing the c key) that attempts to kill (or interrupt) your current action.

Once you get past all the banner screens, you will be presented with the mail menu. In many cases, if you have a capable terminal program (such as PuTTY, MacSSH, or any SSH client), you can also use the cursor keys.

In most cases, you will only really use two of the options on a regular basis.

The most popular will undoubtedly be the “I” option, representing the “MESSAGE INDEX”. By hitting “I” or moving the cursor to that option and hitting enter, you will be taken to your INBOX, and it will list all the messages currently in your inbox.

I will leave the rest of it up to you, as there are commands available on the bottom of the screen, as well as the fact you are probably somewhat experienced with the basic operation of e-mail.

HINT: Make sure you check out and cycle through the “OTHER CMDS” available to you to figure out how to do things like “Reply”, “Compose”, go to the “Main Menu”, and of course “Quit Alpine”.

The other popular option on the main menu is COMPOSE. This of course lets you write an e-mail to someone. To do this you will need to know things like the recipient's e-mail address, and of course to provide an appropriate subject as well as a body of the message.

The available commands are once again available to you at the bottom of the screen. I will expect you to figure out how to use these on your own.

HINT: ^X and ^C will probably be good things to know.

To practice, try sending an e-mail to yourself.

8. Subscribe yourself to the class mailing list:
a.Go to the mailing list URL: http://lab46.corning-cc.edu/mailman/listinfo/unix
b.Locate the “Subscribing to UNIX” section of this page, and enter your *Lab46 e-mail address* in the appropriate field.
c.Choose an appropriate password to use with the list.
d.Once you've entered your Lab46 e-mail address, chosen and verified your password, click the Subscribe button.

NOTE: Your Lab46 e-mail address consists of your Lab46 username, as follows: lab46username@lab46.corning-cc.edu

Once you've done this, go and check your e-mail on Lab46. You should receive a notice from the mailing list software with directions on how to confirm your subscription.

9. Send a test e-mail to the class mailing list unix@lab46.corning-cc.edu:
a.Choose a relevant Subject: line for your e-mail, such as “Testing”.
b.In the body of the message indicate your intentions: “testing, please ignore.”
c.Check to make sure you received your post to the class list. As others subscribe you will see similar posts to the list.

UNIX Philosophy

UNIX has traditionally followed a philosophy, that many still swear by and prefer. The philosophy, although simple, has profound design impacts that influence how the system performs and operates.

Although your book may list several more, the three classic tenets of UNIX philosophy are as follows:

  • Everything is a file.
  • Small is beautiful.
  • Do one thing, and do that one thing extremely well.

Terminology

root user / superuser: a supervisor account often used by the System Administrator. This account is not limited by protections or restrictions as are set in place on regular user accounts.

base (or root) of home directory: the start of a subtree in the filesystem. In this case, the start of the tree of files you own.

blocks: units of data that are represented on the filesystem. Typically, it is common to see 512- or 1024- byte blocks on most storage mediums. (CD-ROMs are commonly an exception, using 2048-byte blocks, as are some exotic hardware configurations).

kilobytes: units of 1024 bytes, often represented by KB (or kB). Note in recent times it seems a new standard is emerging that promotes metric measurements, and you'll see 1000 bytes often be referred to as a kilobyte. The traditional 1024 bytes is referred to by some as KiB. I recognize the existance of KiB vs. KB, although I will often refer to kilobytes (kB) as units of 1024 byte units of information.

multi-user: the UNIX system is multi-user. This means that it can handle commands from more than one user at the same time. (A UNIX/Linux system can have multiple users logged in at once, each performing their own actions.)

multi-tasking: the UNIX system is multi-tasking. This means it can handle multiple commands/processes at the same time. This makes sense that if it can have multiple users on at the same time that it can handle multiple commands at the same time. Note that this also means that each user can have more than one program running at a given instance.

MUA: an acronym for “Mail User Agent”. In other words- an e-mail client, such as pine, Mozilla Messenger, Mozilla Thunderbird, etc. Basically any program that allows you to send/receive electronic mail.

mailing list: a collection of e-mail addresses pooled together for the purpose of creating a forum to discuss a topic or range of topics, as well as have a centralized communication medium for relaying important announcements.

post/posting: a message sent to the mailing list is often referred to as a “post”. When you send a message to a mailing list, you are “posting” a message to the list, as it is viewable by all subscribers.

command-line: the string of commands, arguments, options, and shell manipulation features that are typed in immediately following the prompt.

Logging Out

When you are done using the system for the time being, and wish to end your session, don't click the X in the top-right! This may have unintended effects, leaving your account logged in while you're technically no longer present. (Think mind without a body).

This would not only be undesirable for you, it is generally considered impolite as it may result in the system administrator (or you) having to do extra work later.

For those running Windows machines, you properly shutdown your computer when you're done, right? (Or at least log out your user). Same case here.

So, when you are done with your session, be sure to log out properly! This can be done in a couple ways:

  • The “logout” command, OR…
  • the “exit” command can be used.
  • Alternatively (and my personal favorite): if you prefer slightly less typing (with a few extra features; the usual fare: with laziness, comes more power) you can also use the CTRL-D key sequence to end your session.

Conclusions

This assignment has activities which you should tend to. As a result you should be proficient logging onto Lab46 and utilizing the concepts in this lab. Also- you should document/summarize knowledge learned on your Opus.

As always, the class mailing list and class IRC channel are available for assistance, but not answers.

haas/fall2019/unix/labs/lab0.txt · Last modified: 2014/01/17 07:14 by 127.0.0.1