The aim of this laboratory is to help you obtain the basic skills to manipulate some the resources you will be using to complete the class project.
You will use the standard windows telnet client to connect to Euro. You can use any of the following methods
telnet
euro.ecom.cmu.edu" in the dialog box.telnet euro.ecom.cmu.edu"This will pop up a telnet window with a login prompt. Type your euro login id and password to log in:
login: <your login id, same as your Andrew id>
Password: <your euro password>
It is recommended that you change your password after your first logon. You might want to choose a password that is easy to remember but at the same time is hard to guess by another person. The password selection guidelines might be helpful.
To change your password use the passwd command:
$ passwd -l
Changing password for <username>.
Old password:
New password:
The password command first ask for the old (current) password and then asks for the new password twice to confirm to prevent mistakes in while typing the new password.
For more information check: http://www.cmu.edu/computing/documentation/unix/Password.html
The shell is a command interpreter that executes commands read from the standard input (console) or from a file. The shell program is executed automatically by the login process after the user has been authenticated. The shell provides the basic interface to run other programs and manage its execution.
Running programs: To run a command or a program, just type the
name of the program in the prompt. For example to get the list of the users
currently working in the computer type "who".
$ who thsieh ttyp0 Jun 25 06:25 (OATMEAL-34.SLIP.ANDREW.CMU.EDU) thsieh ttyp1 Jun 25 08:14 (128.2.76.72) thsieh ttyp2 Jun 25 18:07 (OATMEAL-25.SLIP.ANDREW.CMU.EDU) thsieh ttyp3 Jun 25 20:15 (COCOWHEAT-8.SLIP.ANDREW.CMU.EDU) thsieh ttyp4 Jun 29 17:34 (COCOWHEAT-15.SLIP.ANDREW.CMU.EDU) jclopez ttyp5 Jul 14 03:19 (AVON.CMCL.CS.CMU.EDU)
Foreground execution: When a program is running in the foreground it has control of the terminal (input and output) and it does not return the control to the shell until it finishes the execution. This means that the input generated by the users is processed by the running program and the output generated by the program is sent to the terminal (window). By default the shell executes the programs in the foreground. For example if you execute the FTP (File Transfer Protocol) client, this program reads the commands from the user. After the user exits the ftp program (quit command) the shell prompt is printed again.
$ ftp euro.ecom.cmu.edu Connected to euro.ecom.cmu.edu. 220 euro.ecom.cmu.edu FTP server (Version wu-2.4.2-academ[BETA-13](64) Fri Jun 18 15:18:08 EDT 1999) ready. ftp> quit S:221 Goodbye. $
Background execution: A program running in the background does not have control of the terminal, this means that the background process does not receive the input from the user, however it can send its output to the terminal in most cases. If the program needs input from the user, it is suspended until it is run in the foreground. To run a process in the background put an ampersand symbol at the end of the command line. For example:
$ ftp euro.ecom.cmu.edu &
[1]+ Stopped (tty input) ftp euro.ecom.cmu.edu
Type fg at the shell prompt to bring a background process to the
foreground.
Canceling the execution of foreground processes: In many cases
it is possible to cancel a program typing ctrl+C
Process status: To obtain a report of the running processes use the ps
command.
$ ps PID TTY STAT TIME COMMAND 31791 p5 S 0:00 -sh 32136 p5 R 0:00 ps
To display all the processes in the computer including background other users' and
system's processes use the command ps ax
PID TTY STAT TIME COMMAND 373 2 S 0:00 (mingetty) 376 3 S 0:00 (mingetty) 377 4 S 0:00 (mingetty) 378 5 S 0:00 (mingetty) 379 6 S 0:00 (mingetty) 24452 1 S 0:00 (mingetty) 31791 p5 S 0:00 -sh 32139 p5 R 0:00 ps a 2877 p0 S 0:00 (sh) 3063 p1 S 0:00 (sh) 3139 p1 T 0:00 (emacs) 3874 p2 S 0:00 (sh) 4079 p3 S 0:00 (sh) 10658 p4 S 0:00 (sh)
Killing processes: To terminate the execution of a program in
the background you can use the kill command. You need to provide the
process id (PID).
For example:
$ ps PID TTY STAT TIME COMMAND 31791 p5 S 0:00 -sh 32149 p5 T 0:00 ftp 32150 p5 R 0:00 ps $ $kill 32149
The output of a program can be
redirected to a file using the operator ">". For
example, to save the output of the command ps ax to a file type: ps au
> output.txt
The input of a program can be redirected from a file using the operator "<". For example:
$grep sh < output.txt (Grep is a program that searches the named input files (or standard input if no files are named, or the file name - is given) for lines containing a match to the given pattern
The output of one program can be redirected to be the input of another program using the | (pipe) operator. For example:
$ps au | grep sh
up-arrow or ctrl+P. You
can edit the command line using the left and right arrow keys, DEL and backspaceExercise:
cat program in the backgroundinitThe man command formats and displays the on-line manual pages. For
example, to obtain more information about ps type: man ps
Exercise: What is the ping command for?
The file system is probably the most visible aspect of an operating system. It provides the mechanism for on-line storage of and access to both data an programs. The file system consists of two distinct parts: a collection of files, each storing related data, and a directory structure, which organizes and provides information about all the files in the file system.
A file is a collection of related information that is recorded on secondary storage (disk). It can be data, a paper, a graph, a computer program, a drawing, or anything else you might want to store on a computer.
A directory is a special type of file that can contain other files and directories. A directory within a directory is often called a subdirectory.
The entire system of directories and files is arranged in a tree-like (hierarchical) structure, beginning with the root (the directory from which all other directories stem), and extending into branches and leaves. The root ("/") of the tree is at the top instead of the bottom, and all directories grow down from there.
The directory that you are working in is called your current or working directory.
Pathnames: A path name (also called simply path) is like the address of a file or directory. No two files or directories have the same path. A pathname is a chain of directory names, starting at the root and proceeding down the tree until it stops at a particular file or directory. Each directory name is separated by a slash (/).
Commands to manipulate directories
ls: List the content of the current directory.pwd: Prints the current (or working) directorycd dirname: changes the current directory to the specified directory.mkdir dirname: creates a new directory with the given name.rmdir dirname: removes the specified directory if it is empty.Commands to manipulate files
rm filename: deletes the specifiedcp source destination: copies the source file to the
specified destination.mv source destination: moves the source file to the
destination directory or renames the source file with a new name.Exercise:
lab1 in your home directory.GNU Emacs is popular here and elsewhere because of its portability, extensibility (it's
written in Lisp), and copious features and documentation. To start emacs, type
"emacs filename" at the shell prompt.
To save, type ctrl+X ctrl+S
To exit, type ctrl+X ctrl+C
Exercise: Write a perl program that prints the message "Hello world!" to the standard output.
To run a perl program, type: perl program_name
To turn your script into an "executable" that can be run directly:
#!/usr/local/bin/perlchmod +x scriptname./scriptnameExercise:
[References]
Information on related topics