a first book of c++ unix primer. logging in from the pc's in 301, 302, or 303 if the command...

11
A FIRST BOOK OF C++ UNIX PRIMER

Upload: trevor-barnett

Post on 26-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A FIRST BOOK OF C++ UNIX PRIMER. LOGGING IN From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate

A FIRST BOOK OF C++

UNIX PRIMER

Page 2: A FIRST BOOK OF C++ UNIX PRIMER. LOGGING IN From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate

LOGGING IN

From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate to Start --> Programs --> Accessories --> to Command Prompt. Opening this will start a text window.

At the prompt, type in telnet frodo.cis.ysu.edu. This will connect you to frodo, causing the window to act as a terminal emulator.

Enter your login name and password when prompted.

Logging out To exit Frodo and return to the PC, type logout at the frodo prompt. Do not forget to do this before leaving lab.

A First Book of C++ 4th Edition 2

Page 3: A FIRST BOOK OF C++ UNIX PRIMER. LOGGING IN From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate

CHANGING YOUR PASSWORD

It is recommended that you change your password on a regular basis. To do so, use the Unix command passwd. You will be prompted for both your old password and the new one (twice for confirmation). Remember that you password should be at least 6 characters long, should not be any word in the English language, and should contain at least 1 digit or other non-alphabet character.

A First Book of C++ 4th Edition 3

Page 4: A FIRST BOOK OF C++ UNIX PRIMER. LOGGING IN From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate

UNIX HELP

The man command is useful to get more information about any command in UNIX. For instance, to find out more about the ls command, you would typeman ls

The apropos command can help you find commands related to some keyword. For instance

apropos copy

would list all UNIX commands related to copying (including cp).

A First Book of C++ 4th Edition 4

Page 5: A FIRST BOOK OF C++ UNIX PRIMER. LOGGING IN From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate

FILE MANIPULATION

Listing your files

• ls lists all files in your directory (like dir)

• ls -l show all attributes (such as size, date created, and permissions)

• ls -a list all files (including those that begin with . )

Copying and deleting files

• cp file1 file2 copies file1 into file2

• rm file deletes file

Note that unlike windows, you are not asked for confirmation when a file is deleted!

A First Book of C++ 4th Edition 5

Page 6: A FIRST BOOK OF C++ UNIX PRIMER. LOGGING IN From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate

DIRECTORIES

As in Windows, your Unix files may be organized into directories and subdirectories for the purpose of good organization. The syntax is roughly the same as in DOS (note, however, that UNIX uses the forward slash / instead of the backslash for subdirectories).

Creating directories

mkdir directory

creates a new subdirectory called directory

A First Book of C++ 4th Edition 6

Page 7: A FIRST BOOK OF C++ UNIX PRIMER. LOGGING IN From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate

CHANGING DIRECTORIES

Like DOS, you can navigate through your directories using the cd command.

cd directory takes you to directory (if it is a subdirectory of the current one)

cd .. takes you back up to the directory of which your current directory is a subdirectory

cd returns you to your root directory.

A First Book of C++ 4th Edition 7

Page 8: A FIRST BOOK OF C++ UNIX PRIMER. LOGGING IN From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate

COPY FILES

You can also copy and move files from one directory to another using cp. For example:

cp file directory will make a copy of file in directory directory (as long as directory is a subdirectory of your current location).

cp directory1/file directory2 will copy of file from directory1 into directory directory2.

cp ../file1 file2 Will copy file1 from the directory below the current one, into

A First Book of C++ 4th Edition 8

Page 9: A FIRST BOOK OF C++ UNIX PRIMER. LOGGING IN From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate

PRINTINGTo print out a file, use the following command:

lp -d p30xy filename

where

filename is the file you wish to print,

x is the last digit of the room you are in (either 1, 2, or 3),

y is either a, b, or c.

For example, to print prog1.c to printer a in room 301, you would type:

lp -d p301a prog1.c

A First Book of C++ 4th Edition 9

Page 10: A FIRST BOOK OF C++ UNIX PRIMER. LOGGING IN From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate

FILE PERMISSIONSOne of the important things to understand about a multiuser system like

UNIX is that all files are stored on the same machine, and that you could (theoretically) reach anyone else's directory and files by doing cd .. enough. This makes it important to control the permissions for your files.

This is done in UNIX with the chmod command. It has the basic syntax:

chmod who op ability

where who is some combination of:

u The owner of the file (that is, you).

g The group you belong to (not relevant now, but will be later when you work on group projects).

o All others.

A First Book of C++ 4th Edition 10

Page 11: A FIRST BOOK OF C++ UNIX PRIMER. LOGGING IN From the PC's in 301, 302, or 303 If the Command Prompt icon is not on the desktop or the Start menu, navigate

FILE PERMISSIONS

r These people can read this file.

w These people can write to this file.

x These people can execute this file (or cd into it, if it is a directory).

For example:

chmod o-r fred

means that others can no longer read the file fred.

chmod o+x barney

means that others can now enter the directory barney.

A First Book of C++ 4th Edition 11