Brief Unix Tutorial ---------------------------------------------------------------------------- Note: This is not meant to be a comprehensive guide to Unix. This is designed to give you a few rudimentary commands to "get around" and become familiar with the Unix operating system. The "Shell" When you open a terminal window, you will eventually be given a prompt. This is called the "shell" prompt (sometimes called the Unix prompt). The shell allows you to interactively enter commands into the computer via the keyboard. These commands can do a wide variety of things from starting an application to performing file maintenance. A sample listing of commands is listed in the "Unix Commands" section below. UNIX Commands These commands may be entered at any shell prompt, regardless of shell type: pwd find out what working directory you are at ls obtain a listing or your files rm remove and completely and absolutely kill a file more display the contents of a file man get the "man" page for a particular command. Some commands have "options" that can be specified in the command that tell it how to perform. Here are some examples of commands with their output and what they do: pwd command Finding out what my current directory is: $ pwd /users11/student/pfloyd $ ls command Listing the files in the current directory: $ ls $ Actually, this doesn't show all the files in the directory, only ones that do not begin with a 'dot'. These are special files. The -a option for the ls command will allow this. Thus, we will use the command ls -a. $ ls -a . .Xauthority .elm .profile .vueprofile .. .cshrc .login .vue $ This is the "short" form listing. To find out all information about a file, use the "long" form listing. And since we also want to see all the files, we will need that option as well. The option for "long" form listings is -l. Thus, we will use the command ls -l -a to list all the files in long format: $ ls -l -a drwxr-xr-x 6 pfloyd student 1024 Sep 26 16:48 . drwxr-xr-x 4 root student 1024 Sep 26 10:44 .. -rw------- 1 pfloyd student 49 Sep 26 16:48 .Xauthority -rwxr-xr-x 1 pfloyd student 655 Sep 26 10:44 .cshrc drwx------ 2 pfloyd student 24 Sep 26 16:27 .elm -rwxr-xr-x 1 pfloyd student 257 Sep 26 10:44 .login -rwxr-xr-x 1 pfloyd student 642 Sep 26 10:44 .profile drwxr-xr-x 7 pfloyd student 1024 Sep 26 16:43 .vue $ Note: You can combine the options into one (e.g. ls -la) or reverse the options order (e.g. ls -a -l). All of these commands are interpreted by the program as the same and will thus do the same thing. rm command The rm commands permanently removes a file from the system. Do not use this command unless you are absolutely sure you want to remove the file. Let's say I want to remove the file 'dead.letter' in the example below. I would type rm dead.letter to do this. I am also showing the ls command to demonstrate the file has been deleted. $ ls bin dead.letter icb temp tia-notes xv $ rm dead.letter $ ls bin icb temp tia-notes xv $ Note: When the rm command completes, it does not give you any warning of what it has done. This is normal for all Unix commands that complete normally unless there is an error or a specific request for output is required. Now, I want to remove the a couple of other files like tia-notes and xv. You can specify multiple files in the same rm command: $ rm tia-notes xv rm: xv is a directory $ Note: the rm command can only remove files unless you use options with it. If I want to remove the xv directory as above, I would need the -r option: $ rm -r xv $ $ ls bin icb temp $ more command This simply displays the contents of a file, stopping when a screen has been filled. To advance to the next screen, press the space bar. Note: I won't show the 'page breaks' here, but I will show that the more command will produce output. $ more .profile #! /bin/sh ############################################################ # # /usr/local/skel/sys.default.profile: # This file contains all the normal default setting for # sh and ksh users. If you want to change the settings, # make the changes after "User Modifications". Any new # settings for software will be made in this file, so it # is recomemded that you not remove this line. # ############################################################ . /usr/local/skel/default.profile ############################################################ # # User Modifcations # ############################################################ $ man command This command will tell you what you can do with a given command. All standard unix commands have a man page. Application software most likely does not have a man page associated with it. The example below shows the man page for the cal command. Text in the man page is shown via the 'more' command. $ man cal cal(1) cal(1) NAME cal - print calendar SYNOPSIS cal [[month] year] DESCRIPTION cal prints a calendar for the specified year. If a month is also specified, a calendar just for that month is printed. If neither is specified, a calendar for the present month is printed. year can be between 1 and 9999. month is a decimal number between 1 and 12. The calendar produced is that for England and English colonies. EXAMPLES The command: cal 9 1850 prints the calendar for September, 1850 on the screen as follows: September 1850 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 WARNINGS The year is always considered to start in January even though this is historically naive. Beware that cal 83 refers to the early Christian era, not the 20th century. STANDARDS CONFORMANCE cal: SVID2, XPG2, XPG3 Hewlett-Packard Company - 1 - HP-UX Release 9.0: August 1992