
- used to change the current directory. This command is followed by a space and directory path, or a space and two periods (..). ex-1: >cd directory1/directory2/final >pwd >final this command makes the directory called final the current directory. ex-2: >cd .. >pwd >directory2 this command causes the current directory to be the previous directory. if this command were to be executed when the current directory is "final" then the current directory would become directory2.
ls - used to lists the contents of a directory. This command is often used with several UNIX switches which include: -R , lists the contents of all subdirectories -l , gives a long list of the directory ex-1: > ls > nextDirectory Graphic.JPG oneFile.txt twoFile.txt database.db In this example the first item is a directory itself. The other four are files within the directory. ex-2: > ls -R firstdir/ firstdir/: 2nddir file1 file2 firstdir/2nddir: file1 file2 > This example shows how the -R switch reveals the entire tree of sub directories and there contents as well. ex-3: > ls -l total 2 drwxr-xr-x 2 smith 10132 512 Feb 10 11:56 2nddir -rw-r--r-- 1 smith 10132 0 Feb 10 11:57 file1 -rw-r--r-- 1 smith 10132 0 Feb 10 11:57 file2 > | | | |& nbsp; | | | | | |& nbsp; | | | | | |& nbsp; | name of file file | | | las t modified permissions Owner group size of file &n bsp; of in by tes file The text below the output explains what each peice of information means.
pwd - prints the current directory, its use is very simple. ex-1: > > pwd /csclass/info_sci_ba/smith/public-html/classes/firstdir This command will print out the entire directory path of the current directory.
mkdir - creates a new directory that will become a subdirectory of the current directory. ex-1: > pwd /csclass/info_sci_ba/smith/public-html/classes > ls csc241 > mkdir newdir > ls >csc241 newdir From this example you can see that the current directory is classes and it now contains two subdirectories one called csc241, and the new one called newdir.
rmdir - removes the specified directory provided that it is empty, to remove files from the directory see the rm command. ex-1: >ls >csc241 newdir > rmdir newdir >ls >csc241 The rmdir command does not tell you what has been done it simply returns a prompt. This leaves it up to the user to verify that it has worked, as you can see the ls command lets us see that the directory has been removed.
chmod - this command lets the user set permissions on files and directories, provided that the user is the owner of the files or directories. Chmod is often used to make files accessible to the world wide web. The format of the command in a very simple way is as follows: chmodoperator refers to what users you are setting the mode for, options are: u user's permissions g group's permissions o others' permissions a all permissions (user, group, and other) operator is a + or a - symbol meaning "give" and "take away" permissions respectively. refer to what permissions you want to change they are: r - permission for to read a file or directory w - permission for to write to the file or directory x - permission for to execute (search through) the file or directory In order to address the permissions of a directory, the current directory must be the parent (in the directory tree) of the directory that you want to address. In order to address the permissions of a file you must specify the correct pathname. Chmod does not make much sense out of context so here are a couple of examples. The form, chmod operator ex-1: chmod g-r firstdir This example takes the permission of groups to read the directory called firstdirectory. Groups will no longer be able to see what is in this directory. ex-2: chmod a+rx public-html This example gives permission to all people to read and execute the directory called public-html. This is needed on rocky to make web pages accessible to the World Wide Web. ex-3: chmod ug+rwx privateFile.txt This example give permission for users and groups to read, write, and execute privateFile.txt. This might not be a good idea if the file needs to be kept private. A better set of permissions is set in the following example. ex-4: chmod ugo-rwx privateFile.txt Here we see that chmod will remove permission for users, groups, and other to read, write, or execute privateFile.txt. Even in the case that the directory that contains privateFile.txt is r,w, and x privateFile.txt will not be able to be seen or written to by anyone including the user! Which admittedly makes little sense. ex-5: chmod a-r+x-w firstdir This chmod takes away permission of all to read firstdir. It also gives all permission to execute the directory, and takes away all's permission to write to firstdir. This kind of a setup is useful if you have private files in firstdir and you need users to pass through it in order to read files in one of firstdir subdirectories. all==> prevdir(a+rx-w) ==> firstdir(a-r+x-w) ==> nextdir(a+rx-w) | |   ; | files to private files to read files &nbs p; read
more : more 'file-name' This does the same thing as print, but instead of printing the file to one of the printers it prints the files contents to the screen. ex-1: rocky-gw> more file1.txt this is the contents of a file that is printed to the screen
head : head -'number-of-lines' 'file-name' This command will let you view the first three lines of a file, ex-1: rocky-gw> head -3 firstThree this file is an example to show how the first three lines of a file might look if the head command is used. It should show only the rocky-gw> the user can choose any number of lines to display by changing the value of the 'number-of-lines' switch.
mv : mv 'file-name' 'new-file-name' Or mv 'directory-name' 'new-direstory-name' Using mv it is possible to rename a directory or file. In order to rename a file, the file must be in the current directory, or specified through a pathname. In order to rename a directory the current directory must be below the directory to be changed ex-1: rocky-gw> ls *.txt old-name.txt rocky-gw> mv old-name.txt new-name.txt rocky-gw> ls *.txt new-name.txt rocky-gw>
mesg : mesg -switch This command used without a switch will tell you how the user messages are set. ex-1: rocky-gw> mesg is y rocky-gw>
This tells the user that they are able to receive messages like talk sessions. The two switches used with mesg are -y, and -n. They turn the messages on, then off respectively. ex-2: rocky-gw> mesg -n rocky-gw> mesg is n rocky-gw> This example shows how to turn the messages off which will make it impossible for anyone to send you a message on the system. Keep in mind these are not email messages that we are talking about only messages such as talk, and write are disabled/enabled by mesg.
wc: wc 'file-name' This command will count the number of lines, words, characters of any text file ex-1: rocky-gw> wc word.txt 8 29 133 word.txt rocky-gw> we can see that wc tells us there are 8 lines, 29 words, and 133 characters in word.txt.
spell: spell 'file-name' This works just like a spell checker on a pc word processor, only it is more cryptic, and boring. The misspelled words are printed out below the command in descending order by length. ex-1: rocky-gw> spell word.txt diserttation givven knoe ver rocky-gw> Looks like I'm not such a good speller.
logname: logname Returns the login-name of the current user ex-1: rocky-gw> logname smith rocky-gw> We see here that the current user has the login-name of smith.
users: users This provides a list of the login-names of all users who are currently logged into the system. You might want to know if your friend zukz is using rocky, so you type users. ex-1: rocky-gw> users aaldrich abrantes adame ahensel alencewi amiller4 amodio ansara armstron askew a tri auleta baer balus barber bderby beresfor binnig bkatzman blissert boberst bo uwens breon brindle bzeller canning ccharleb cgerace cgerace chill1 circdesk zukz This is a list of users that are currently logged into rocky. You can now see that zukz is indeed on the system.
Script creates a time-stamped record of your UNIX session. everything that crosses the screen will be added to the file that the user specifies as the script-file. This command is usefull for recording output from a program that prints to the command line in UNIX. ex-1: In this example there is a script of two calendars, one is the month of washington's birthday, and the other is the month of lincoln's birthday. Both calendars were printed out to the command prompt while the script was being run, so they are now both in the script which is time-stamped to show when it was done. Notice that you can see the commands as well as the calendars, that is because everything that passes the screen is included in the file. Don't forget to type exit after you are done so that the script will stop, otherwise your script file will never stop scripting! script calendars.txt Script started on Thu Feb 19 13:28:37 1998 rocky-gw> cal 02 1723 February 1723 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 rocky-gw> cal 02 1809 February 1809 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 rocky-gw> exit script done on Thu Feb 19 13:30:26 1998
You can use login anytime you want to let a new user log into your rocky session. It will stop the current session, and ask for a password. The new session will terminate the old session, so if you want to log back in just type login again.
ex-1: In this example I turn the command 'banner Hi-Bob' into the alias
hi
I do this because I want to do the banner command many times
and it is easier just to type hi.
rocky-gw> alias hi 'banner Hi-Bob'
rocky-gw> hi
# #
######
# # #
# # #### #####
# # #
# # # # #
#
####### # ##### ######
# # #####
# # #
# # # # #
#
# # #
# # # # #
#
# # #
###### #### #####
An alias only lasts as long as the user is logged into the system.
When you log out it will expire.
If you want to change your login password, this is the command to use. It starts a dialog that will prompt you for all that is needed to change your password.
This is the command of commands, it is like a help file for specific commands. This tutorial is a very brief overview of many commands. If you want the whole list of what a command can do use man. If there is no help available, man will let you know. ex-1: Here we will what man knows about banner. rocky-gw> man banner banner(1) User Commands banner(1) NAME banner - make posters SYNOPSIS banner strings AVAILABILITY SUNWesu DESCRIPTION banner prints its arguments (each up to 10 characters long) in large letters on the standard output. SEE ALSO echo(1)
This prints a small calendar to the screen. Cal can do any year, from the birth of christ to the year 2000. ex-1: rocky-gw> cal 02 1732 February 1732 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 Here we see our first president was born on a Tuesday. A good elementary school student would know which one.
Banner draws a message across the screen in a billboard like style. It is often used with the PIPE '|' in order to write the banner to another user. In the example below a | is used to write the banner to another user. ex-1: rocky-gw> banner "hello" | write smith Message from smith on rocky-gw (pts/102) [ Tue Feb 24 09:59:04 ] ... # # ###### # # #### # # # # # # # ###### ##### # # # # # # # # # # # # # # # # # # # # ###### ###### ###### ####
Ftp stands for File Transfer Protocol. Typing ftp into the rocky prompt starts a program that uses ftp to transfer files over the network and the internet. Files are transferred from ftp servers to ftp clients, Rocky has capability to be both an ftp server and an ftp client. The server must be a valid address of a computer that the user can login to, either as an anonymous user or as a user that has an account and a password. below is an example of how to use an anonymous session. ex-1: here we see that rocky is an ftp server. We log in as username anonymous, and give our email address as a password. rocky-gw> ftp rocky.oswego.edu Connected to rocky.oswego.edu. 220 rocky-gw FTP server (UNIX(r) System V Release 4.0) ready. Name (rocky.oswego.edu:kraft): anonymous 331 Guest login ok, send ident as password. Password: 230 Guest login ok, access restrictions apply. ftp> ls 200 PORT command successful. 150 ASCII data connection for /bin/ls (129.3.1.36,63833) (0 bytes). Once in ftp the prompt will turn into an ftp> to get out of the program type 'quit'. To get a file the command is 'get', and to send a file the command is 'send'. Once in ftp type a '?' to get complete list of commands, to get a more detailed listing of a particular command type '?command-name'.
This starts a telnet session with a host computer. Chances are that if you use a pc or a mac to login to Rocky you have already used a telnet program. The telnet program that is on rocky provides the same functions, rocky is the client computer when you use its telnet program. In the example we will login to dopey (another oswego computer) Which makes dopey the host machine. ex-1: rocky-gw> telnet dopey.oswego.edu Trying 129.3.22.26... Connected to dopey.oswego.edu. UNIX(r) System V Release 4.0 (dopey) login: smith Password: asigbecret You are connected to the Instructional Computing Center at SUNY Oswego. Unauthorized use is prohibited and prosecutable. ------------------------------------------------------------------- ------------------------------------------------------------------- You have mail. dopey>To stop a telnet session just type logout like you normally do.
topDirectory(root) / \ child1 child2 / \ \ child1 child2 child1 / \ child1 child2This structure can go on for as long as the computers memory will permit. As we can see there is a top parent which is often called the 'root' directory because this is where the tree grows out from. Directories can have as many children as they need to, or they can have no children at all. A pathname is specified by linking the children in order till the desired directory is reached.
Login - The process of logging onto the UNIX system. First a username is entered then a password.
Switch - An extension of a command that enables options to modify the command. ex: ls -R ,'-R' is a switch that tells ls to list all the files and directories.
Prompt - The text that sits on the command line of the UNIX interface. The default prompt on Rocky looks like this, rocky-gw>.
Multiuser - The UNIX system provides access to many users at one time. These users may be logging in from remote computers via telnet sessions or modems. When you are a user on the system you have certain directories that you can access and others you can not access.