To check the current date and time, use the date command.
Alternatively a clock can be displayed. Run the xclock program by typing the command xclock.
Try and type something in the terminal window while the clock is displayed. The commands are ignored for the moment as the terminal (shell) is tied up running the current command - the clock. Close the clock. The commands typed in while the clock was running are now executed, and the terminal window will now accept commands.
This time run the clock in the background by placing an ampersand (&) after the command (e.g. xclock&). This runs xclock as a background process, and doesn't tie up the terminal window. Try typing some commands to confirm this.
Similarly when you use applications such as nedit, firefox etc, type the command then an ampersand, so that they run in the background. e.g. nedit& or nedit filename& or firefox&
Note: you can always open multiple Terminal windows as well, for example you might want to work in different directories at once etc.
Change directory to the directory containing HelloToMe.java from the last tutorial.
Running nedit in the background, open HelloToMe.java.
Obtaining a printout is the same as for the PC labs. You student card is needed to pay for the printout. If you send something to the printer and decide not to print it, it doesn't matter, it will disappear from the print queue in time.
From within nedit print the file to the printer itlab3.
Exit nedit.
Printing the file HelloToMe.java to the printer itlab3 using a2ps, specifying 1 page per sheet and portrait page layout.
As you are already logged in to a UNIX workstation you can remote login to another UNIX computer using ssh (ssh is a secure remote login program unlike rlogin). Pick a UNIX workstation to remotely log into that already has someone logged into it e.g. ask the person next to you what indy they are using (the indy name is specified at the top of the terminal window) or check the map on the notice board at the front of the classroom (if available). e.g. to remote login to indyc, type
ssh indyf
or
ssh indyf.bendigo.latrobe.edu.au
Then type in your username and password.
Check who else is using the workstation.
The who command shows information on the users using the system. Try it. It should look something like:
tim ttyq0 May 4 22:43 (whitfort.bendigo.latrobe.edu.au:0.0) afsmith ttyq2 May 7 13:15 (:0.0)
Description
tim Username ttyq0 Terminal line May 4 22:43 Date and time logged in (whitfort.bendigo.latrobe.edu.au:0.0) The computer user is logged in from.
In the above example the user afsmith is sitting at the Unix workstation.
For more information on what users are doing on the system you have logged into, use the w command. Try it. It should look something like:
1:59pm up 6 days, 23:01, 2 users, load average: 0.02, 0.04, 0.00 User tty from login@ idle JCPU PCPU what tim q0 whitfort.bendi Sun10pm 3:38 w afsmith q3 :0.0 1:15pm 1 22 nedit Page1.html
Description
The first line describes statistics on the system e.g. the current time is
1:59pm, the system has been up (on) for 6 days, it has 2 users etc.
The first 4 columns are similar to those described in who. The idle
column shows the time (as minutes, or hours:minutes) since there was any user
input, the JCPU column shows the total CPU time (as seconds, or
minutes:seconds) of all jobs run by the user, PCPU column shows the CPU
time (as seconds, or minutes:seconds) taken by the current job, and the what
column shows what the users are doing e.g. what they are running.
Log off the remote workstation
Type the following commands
history
pwd
du -s
Re-execute the pwd command. By specifying ! and how many commands ago it was.
Check if you have any start-up files, first use ls -a check if you have a .login file, and a .cshrc file..
If the files exist, view them.
We will make a few adjustments to your .login file
Make the following changes to your .cshrc file
If you haven't already done so run your .login file so that the umask command within is applied to new files. See the lecture for more information on permissions.
Change the protection on all of your files so that only you can access them
Any new files created in directories that you want to be public will need to have their permissions changed explicitly, as the default permissions now stop group or other access. For example if you create a new web page in public_html called myholidays.html, then you need to provide group and other read access e.g. chmod go+r myholidays.html.
All users have an entry in the password file. The password file can be viewed, but the passwords are encrypted or not shown.
Change directory to: /etc.
Do a long format listing for the file passwd. e.g. ls -l passwd.
Everyone has read access to the file.
Use less to view the file passwd.
There are would normally be many thousands of entries in the file (username and passwords are now held at Bundoora). Trying to locate an entry can be difficult.
grep can be used to find text within a file or files.
Use grep to find your "ice" in the passwd file, its format is: grep "stringtofind" filename
Use grep to find occurrences of "unix" in /Users/tjwhitfort/Public/lect17.txt
Output from a command can be redirected to a file. For example to save the output from a ls command, use > and specify the file the output is to go to. e.g.
ls > myfilelist
Try the above command. View the contents of the file.
The output from one command can be used as input to another command (piped). The pipe symbol (|) is placed between the commands.
In the following example the output of the ls command is used as input to the less command. Try it.
ls /etc/passwd | less
The following command finds occurrences of "z" in the passwd file and sends the output to less so that it can be viewed a screen at a time. The output from grep is treated as input to less. Try it.
grep "z" /etc/passwd | less
Write a command to find all occurrences of "smith" in the password file.
The following command makes displays a sorted copy of the passwd file, sorting on its first field (username), displaying the output a screen at a time. Try it.
sort -k1 /etc/passwd | less
Script records everything output to your shell window to a file. If a file name is not specified, the file typescript is used. Script is useful for keeping a record of program runs, output of commands etc. To end recording (exit script) press Ctrl+D.
Format
script [-a ] [filename]
Options
-a Append to the end of the file
Example running script and typing the commands ls -1 and who. Use Crl+D to end script.
indyk> script Script started, file is typescript indyk> ls -l drwx------ 2 tim itstaff 9 May 4 20:24 ProgEnv -rw-r--r-- 1 tim itstaff 77 Apr 30 10:00 geelong.txt drwxr-xr-x 5 tim 1234 4096 Apr 30 10:14 public_html indyk> who tim ttyq0 May 4 22:43 (whitfort.bendigo.latrobe.edu.au:0.0) afsmith ttyq2 May 7 13:15 (:0.0) <Crtl+D>Script done, file is typescript
View the contents of the typescript file
indyk> less typescript indyk> script Script started on Wed May 7 11:32:08 2003 indyk> ls -l drwx------ 2 tim itstaff 9 May 4 20:24 ProgEnv -rw-r--r-- 1 tim itstaff 77 Apr 30 10:00 geelong.txt drwxr-xr-x 5 tim 1234 4096 Apr 30 10:14 public_html indyk> who tim ttyq0 May 4 22:43 (whitfort.bendigo.latrobe.edu.au:0.0) afsmith ttyq2 May 7 13:15 (:0.0) script done on Wed May 7 11:32:21 2003
Run script, recording the session to the file tut19script.txt. Try a few commands. End script (Ctrl+D). View the file tut19script.txt.