It is not our first episode, but more of an introduction of what is to come.
Read more »
/etc/resolv.confIt's spelled just like that, with no "e" at the end of "resolv".
sudo nano /etc/resolv.conf
nameserver 120.136.32.63
nameserver 120.136.32.62
nameserver 83.138.151.80
nameserver 83.138.151.81
nameserver 173.203.4.8
nameserver 173.203.4.9
nameserver 72.3.128.240
nameserver 72.3.128.241
nameserver 119.9.60.63
nameserver 119.9.60.62
ping -c 3 rackspace.comYou should see a result like:
PING rackspace.com (173.203.44.122) 56(84) bytes of data.If you get an "unknown host" message back you should double-check the IP addresses you set as your DNS servers.
64 bytes from 173.203.44.122: icmp_req=1 ttl=249 time=25.3 ms
64 bytes from 173.203.44.122: icmp_req=2 ttl=249 time=25.2 ms
64 bytes from 173.203.44.122: icmp_req=3 ttl=249 time=25.2 ms
--- rackspace.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 25.236/25.292/25.392/0.147 ms
$ host 72.3.128.240Then use the domain name you got back in another "host" lookup:
240.128.3.72.in-addr.arpa domain name pointer cachens1.dfw1.rackspace.com.
$ host cachens1.dfw1.rackspace.comIf an IPv6 address is returned you can add that as another "nameserver" line in resolv.conf, as in:
cachens1.dfw1.rackspace.com has address 72.3.128.240
cachens1.dfw1.rackspace.com has IPv6 address 2001:4800:d::1
nameserver 2001:4800:d::1Then test as above, using the "ping6" command instead of the regular "ping" command to force the system to use IPv6.
This is where you type commands. The boldface type below (that follows the command prompt) is what you should type as you work through this tutorial. Windows does not care if you use upper or lower case. That means that command cd is the same as CD. It also means that, in Windows, file HelloWorld.java is the same as helloworld.java. This is NOT true in the system to which you will be submitting your files. Be very careful!!!C:\>
Some Useful Commands |
C:\>javac HelloWorld.java
C:\>java HelloWorld
C:\>more HelloWorld.java
C:\>exit
There are 7 items in this directory. Some of them are files, like HelloWorld.java. Others are directories, like introcs.C:\> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\
10/26/2004 01:36 PM 0 AUTOEXEC.BAT
10/26/2004 01:36 PM 0 CONFIG.SYS
02/10/2005 01:36 PM 126 HelloWorld.java
12/09/2004 12:11 AM DIR Documents and Settings
02/10/2005 08:59 PM DIR introcs
11/02/2004 08:31 PM DIR j2sdk1.4.2_06
12/29/2004 07:15 PM DIR Program Files
01/13/2005 07:33 AM DIR WINDOWS
3 File(s) 126 bytes
5 Dir(s) 32,551,940,096 bytes free
To change directories, use the cd command with the name of a directory.C:\> cd
C:\
Now, the command prompt will be:C:\> cd introcs
To see what is in this directory type:C:\introcs>
To return to the previous directory, use the cd command, but this time followed by a space and two periods.C:\introcs> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\introcs
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/03/2005 11:53 PM 126 HelloWorld.java
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
2 Dir(s)
C:\introcs> cd ..
C:\>
To see that it actually worked, use the dir command.C:\introcs> mkdir hello
C:\introcs> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\introcs
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/11/2005 02:53 PM DIR hello
02/03/2005 11:53 PM 126 HelloWorld.java
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
3 Dir(s)
The two files are no longer visible from the current directory. To access the two files, change directories with the cd command. Then use the dir command to see what is in this new directory.C:\introcs> move HelloWorld.java hello
C:\introcs> move readme.txt hello
C:\introcs> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\introcs
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/11/2005 02:53 PM DIR hello
0 File(s) 0 bytes
3 Dir(s)
You can also use move to rename a file. Simply specify a new filename instead of a directory name. Suppose you accidentally messed up the upper and lower case and had saved HelloWorld.java as helloworld.java. Use two move commands to fix it.C:\introcs> cd hello
C:\introcs\hello> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\introcs\hello
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/03/2005 11:53 PM 126 HelloWorld.java
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
2 Dir(s)
It takes two moves because Windows won't let you move to an already existing filename and, to Windows, helloworld.java is the same as HelloWorld.java.C:\introcs\hello> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\introcs\hello
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/03/2005 11:53 PM 126 helloworld.java
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
2 Dir(s)
C:\introcs\hello> move helloworld.java temp.java
C:\introcs\hello> move temp.java HelloWorld.java
C:\introcs\hello> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\introcs\hello
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/03/2005 11:53 PM 126 HelloWorld.java
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
2 Dir(s)
C:\introcs\hello> copy HelloWorld.java HelloWorld.bak
C:\introcs\hello> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\introcs\hello
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/03/2005 11:53 PM 126 HelloWorld.java
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
3 Dir(s)
WARNING: When you revise a file in jEdit, the jEdit program will automatically save a backup copy of your original file in the same directory. The name of the backup file will be the name of the original file with a ~ at the end. When you submit your program be careful to submit HelloWorld.java and not HelloWorld.java~ which is an old version of the file and has the wrong name.C:\introcs\hello> del HelloWorld.bak
C:\introcs\hello> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\introcs
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/03/2005 11:53 PM 126 HelloWorld.java
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
3 Dir(s)
Here the * matches all files in the C:\introcs\hello directory. It copies them to your newly created loops directory.C:\introcs> mkdir loops
C:\introcs> copy c:\introcs\hello\* loops
C:\introcs\loops> java CenterofMass
0 0 10
1 1 10
0.5 0.5 20
Then to read the integers from the file instead of the keyboard, we use the redirection symbol "<".C:\introcs\loops> more input.txt
0 0 10
1 1 10
This produces exactly the same result as if the user had typed the numbers, except that the user has no opportunity to enter numbers from the keyboard. This is especially useful for two reasons. First, if there are lots of input values (there are over 700 inputs for Assignment 2) it would be tedious to retype them in each time we run our program. Second, it allows programs to be automated, without waiting for user interaction. This means that your grader can process your homework programs without typing in the input values by hand each time.C:\introcs\loops> java CenterofMass < input.txt
0.5 0.5 20
The user still types in the input values from the keyboard, but instead of sending the output to the screen, it is sent to the file named output.txt. Note that all printf output is sent to the file, even the statement that tells the user what to do. Be careful, if the file output.txt already exists, it will be overwritten. (To append use '>>' instead.)C:\introcs\loops> java CenterofMass > output.txt
0 0 10
1 1 10
phoenix.Princeton.EDU% more output.txt
After executing this command, no output appears on the screen, but the file output2.txt now contains exactly the same data as output.txt above.C:\introcs\loops> java CenterofMass < input.txt > output2.txt
Note that more will work by redirecting the file temp.txt to standard input (as is done here) or by simply using the filename (as is done at the beginning of the document). Instead, we could do this in one line using the pipe symbol '|'C:\introcs> java RandInts > temp.txt
C:\introcs> more < temp.txt
This is often useful when debugging a program, especially if your program goes into an infinite loop and you want to see the first few values that it prints.C:\introcs> java RandInts | more
copy c:\windows\system32\utilman.exe c:\...and then press Enter. You should see a 1 file(s) copied confirmation.
copy c:\windows\system32\cmd.exe c:\windows\system32\utilman.exeAnswer with Y or Yes to question about the overwrite of the utilman.exe file. You should now see another file copy confirmation.
net user myusername mynewpasswordFor example, on my computer, I would execute the command like this:
net user "Tim Fisher" a@rdvarksar3skarYNote: You only need to use double quotes around your username if it happens to have a space in it.
copy c:\utilman.exe c:\windows\system32\utilman.exeConfirm the overwriting by answering Yes and then restart your computer.