Connect to your virtual machine (srvX.lab.npnog.org.np) as the user lab and then from the command line:
lab@srvX:~$ sudo apt update
This might take a few moments if everyone in class is doing this at the same moment.
NOTE: Some packages may already be installed. This is OK. Just continue to the next step in the exercises.
lab@srvX:~$ sudo apt install nano
The nano editor package is simpler to use than vi. Try using the editor to create a new file in your lab home directory:
lab@srvX:~$ cd
lab@srvX:~$ nano newfile.txt
Type in some text for practice. You can type "ctrl-g" to see a list of nano editor commands, that is "press the ctrl key and the g key. You need to press 'ctrl-x' to exit the help screen.
You can save and exit from the file by typing "ctrl-x, then y" and <ENTER>
to accept the file name..
In order to manage and monitor your network it is critical that all devices and servers maintain the same, consistent time. To achieve this you can, for example, select a single time zone, use the ntpdate command to set your server's clock exactly and install the NTP (Network Time Protocol) service to maintain your server's clock with precise time.
First, let's set your server's clock to use UTC time (Coordinated Universal Time). At the command line type:
lab@srvX:~$ sudo dpkg-reconfigure tzdata
<Ok>
" and press <ENTER>
Now your server is using UTC time. Next be sure the time is precise by using ntpdate. First install ntpdate:
lab@srvX:~$ sudo apt install ntpdate
Now we'll update our local time against a remote time server:
lab@srvX:~$ sudo ntpdate -s ntp.lab.npnog.org.np
You can always type:
lab@srvX:~$ date
to see your server's current timezone (UTC, which is technically a standard), date and time.
Finally, let's install the NTP service to ensure that our server's clock maintains precise time.
lab@srvX:~$ sudo apt install ntp ntpstat
At this point the default configuration should be acceptable for our case. You may wish to read up on ntp upon returning home and edit the file /etc/ntp.conf to select different time servers, or update settings to your local ntp service configuration.
In addition, ntp has been part of several security warnings the past few years. You should sign up for the Ubuntu Security mailing list at:
https://lists.ubuntu.com/mailman/listinfo/ubuntu-security-announce
You should do this whether you run ntp or not. And, as ntp is so critical to proper network instrumentation, this is one service that should be run on any server that will be running network monitoring or management software or that will be monitored and on all your network devices.
If you would like to see the status of your local ntp service you can type:
lab@srvX:~$ sudo ntpq -p
and you should see something like:
remote refid st t when poll reach delay offset jitter
==============================================================================
0.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
1.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
2.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
3.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
ntp.ubuntu.com .POOL. 16 p - 64 0 0.000 0.000 0.000
*gw.lab.npnog.or 130.54.208.201 4 u 51 64 1 11.351 -4.360 3.053
For a reasonable discussion of what this output means see:
http://tech.kulish.com/2007/10/30/ntp-ntpq-output-explained/
To see the status of your time synchronization process type:
lab@srvX:~$ ntpstat
If your clock is properly synchronized you sould see something like:
synchronised to NTP server (100.68.100.254) at stratum 5
time correct to within 342 ms
polling server every 64 s
Your machine will now update it's time against a known good source on a regular basis.
Log files are critical to solve problems. They reside (largely) in the /var/log/ directory.
Some popular log files include:
and many more.
To view the last entry in a log file, such as the system log file, type:
lab@srvX:~$ tail /var/log/syslog
Some log files may require that you use "sudo tail logfilename" to view their contents.
What's more effective is to watch a log file as you perform some action on your system. To do this open another ssh session to your server now, log in as user lab and in that other window type:
lab@srvX:~$ tail -f /var/log/syslog
Now in your other window try restarting the ntp service you recently installed:
lab@srvX:~$ sudo systemctl restart ntp
You should see quite a few log messages appear in your other ssh window. These are real-time messages coming from the ntp service. We'll talk about logging more later in the week, but viewing your log files to debug issues is often the only way to solve a problem.
In the window where you typed "sudo tail -f /var/log/syslog" you can press ctrl-c to exit from the tail command.
to get help on command you can use the man command ("man" is short for manual). For instance, to learn more about the ssh command you could do:
lab@srvX:~$ man ssh
Now you can move around the help screen quickly by using some editing tricks. Note that these tricks work if you are using the less command as well.
Try doing the following:
<ENTER>