L. J. Jaeckel
◄ Home
CMPSC 210 — Linux System Administration
February 23 – April 21, 2011
Mid-Term and FINAL EXAM: Debian Linux VM Log
( host name: debian5vm )
Quick links to some highlights in this log:
(Note:
Final Exam work
begins on 17 April, 2011)
Overview of the Mid-Term assignment:
- Download pre-installed Debian VM zip file 210debian5Mid.zip,
unzip, and run it.
As pre-installed, system comes with:
- Network with NAT configuration
- Two pre-installed users:
- root (password: vmware12)
- stu1 (password: Yosemite7)
- NO graphical user interface. (Actually, Openbox is
there and startx starts it, but that
barely counts.)
- Add a second virtual disk drive of 2 GB:
- 1 GB data partition, and make a mount point for it.
- 1 GB swap partition
- Create script /root/bin/mount_midterm1 to mount that
and enable the swap space
- Create script /root/bin/umount_midterm1 to unmount that
and turn off the swap space
- And let's assume, although the assignment doesn't say so,
that we should add at least the data partition to
/etc/fstab so it will auto-mount.
- Install kde
- Add user jeremy with password Yosemite7
- Enable remote display to port 5911 (on the VM)
- Install and configure sshd
- Log in as jeremy from any convenient ssh
client (ssh or putty).
- For BONUS brownie points:
- Install LAMP (Linux/Apache/MySQL/PHP)
- Configure that to support user web sites
( e.g., localhost/~jeremy )
- Put a simple web page there.
Note, I am NOT necessarily going to do these steps in the order
listed here. Rather, I will do them mostly in easiest-to-hardest
order (which means, basically, the tasks I am most familiar with
first, least familiar with last).
2011-02-23
- BEGIN working on this assignment.
Back to top
- Download 210debian5Mid.zip, twice, to:
- master2:\XMIT\CS210\210debian5Mid.zip
- frazzle:/home/jay/Downloads/210debian5Mid.zip
(By comparing those, or their checksums, I can verify that
I got a good download.)
- Done. Downloads took about 1hr 40m each.
- File size = 1,006,006,296
- MD5 sum both: 7e24 3a07 71bd 926e b9ad 83ad 2f24 db4b
- unzip -t (test zip file integrity) shows zip file is okay.
- unzip -v shows that unzipped data will fill about 2.1 GB
- Host machine (Ubuntu frazzle) has about 3.6 GB
disk space available.
- Unzipped to /home/jay/vmware/210debian5 (alongside the
other Linux VM's there).
The vmx file is: debian5For210.vmx
- Begin vmware and look at this VM (but don't start it running
yet). Observe the existing configuration.
Some points of interest:
- Memory: 1024 MB (1GB). Need to reduce this
to 512 MB because my entire host box only
has 1 GB. Done.
- Disk 1: SCSI 0:0 Maximum 14 GB. Currently 2.0 GB.
Multiple files, not pre-allocated.
- Network configuration: NAT
- Remote display: Port 5955, NOT enabled. This,
I presume, needs to be changed as per
assignment.
- Enough for tonight. Note, machine has NOT actually been
booted yet.
2011-02-24
- Debian 5 Linux Mid-Term VM (debian5vm) started
for the first time.
Back to top
- Some observations:
- Kernel 2.6.26-2-680
- VMWare tools already installed.
- Host name is debian5vm — I see no
need to change that for purposes of this assignment.
- Boots up to plain-text login screen. (We don't need
no steenkin' GUI!)
- Login as stu1 (password Yosemite7).
- Begin doing some initial observations on the condition
of this system.
- df -h — Some information seen:
- /dev/sda1 Total: 2.3G Used: 1.4G (61%) Avail: 867M Mounted on: /
- /dev/sda6 Total: 5.3G Used: 139M ( 3%) Avail: 4.9G Mounted on: /home
- A glance at /etc/fstab shows, in addition, /dev/sda5 as swap.
- fdisk -l shows:
- /dev/sda1 (Type 83, Linux)
- /dev/sda2 (Type 5, extended)
- /dev/sda5 (Type 82, swap)
- /dev/sda6 (Type 83, Linux)
- Some preliminary tests of network function (some done as
root, as needed):
- /sbin/ifconfig shows:
- eth0 IP address: 172.16.111.129 Mask: 255.255.255.0
(Is vmware itself acting as DHCP server to provide
these things?)
- lo IP address: 127.0.0.1
- ping localhost — Works! (127.0.0.1)
- ping debian5vm — Works! (debian5vm.localdomain 127.0.1.1)
- ping frazzle (That's the host box) — Works! (frazzle.localdomain 192.168.0.6) &ndash But seems very slow!
- ping www.yahoo.com — Works! (98.137.149.56)
- tracert frazzle — Shows first hop through
172.16.111.2 &ndash Is that vmware itself acting as
a gateway or router?
- Installing kde:
Back to top
- Begin by studying instructions at a whole bunch of web sites:
Needless to say, they're all different, in particular as to
just what modules you should apt-get. The main differences
seem to involve just which modules, or combination packages
to install, and what assumptions they make about what
you already have installed vs. what you have to get now.
- My choices:
- I want to install the minimum stuff that I
can, and not the whole billion-gigabyte collection
of kde programs.
- I want to have kde not start automatically,
and not have a GUI login screen. Instead,
login with a plain-old plain-text screen and then
manually start kde if you choose to do so
with startx.
- I think apt-get kde-core is the thing I
should try first. This appears to get kde along
with the basic programs one should have.
- Observation: Basic X-Window system is already present and
startx starts it! This brings up a bare-bones
Openbox GUI with basically nothing much there. (But it
does have a terminal emulator at least. Hey,
that's all I need!)
- apt-get kde-core (run as root). Estimated download: 78MB
(I assume that means compressed, before uncompressing.)
- Got 132 files in about 7 minutes.
- When prompted for choice of display manager, choose
kdm (The other choice is xdm.)
- Entire installation procedure took about 15 minutes.
- df -h — Now shows:
- /dev/sda1 Total: 2.3G Used: 1.7G (74%) Avail: 580M Mounted on: /
- That's 287M more disk space (+13%) full.
- startx still runs Openbox, not kde. To configure that:
- In home directory (NOT running as root now, stu1 in this case), create new
file named .xinitrc
- In that file, put these lines:
#!/bin/sh
exec startkde
- Now run startx and it brings up kde.
- The first time you run kde, it walks you through a
basic preferences wizard, which has mostly obvious
defaults, which I mostly chose.
- For "System behavior" I stuck with the default, KDE.
- I UNCHECKED almost all of the eye-candy choices,
checking only:
- Large desktop icons
- Desktop wallpaper
- Desktop style: I chose KDE Classic
- /etc/inittab is configured to boot into runlevel 2.
I am leaving this as-is, NOT changing to boot into runlevel 5.
- This completes the basic kde installation. Additional
work to be done later, as needed.
Some observations:
- Konqueror can access shared folder smb://frazzle/xmit-frazzle
from the host machine.
- And CAN browse to external web sites like www.yahoo.com —
but it seems very slow.
- Some additional observations:
- ssh is present and it works.
- ssh jaeckell@csrh1.yosemite.edu — Works!
- ssh doggie@sdf.org — Works!
- Adding new user jeremy:
Back to top
- First, work on the files in /etc/skel to get them the
way I want for every new user. When adding a new user,
these files are copied into the new user's home directory.
- Edit /etc/skel/.bashrc —
- Modify prompt string PS1 to be:
PS1='\n${debian_chroot):+($debian_chroot)}[$SHLVL]?$?? \u@\h: $PWD \$ '
- For xterm windows, modify PS1 some more to put
more information in the window title bar:
PS1='\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: ${PWD}\a\]'"$PS1"
- These prompt strings aren't all that different from
what they already were. I added \n at the beginning
so each prompt begins with a blank line to separate
it from whatever came before. [$SHLVL] displays the
shell level (bash shell only, apparently). ?$??
displays the exit status from the previous command.
(I got this idea from the default freeshell prompt.)
Changed \w to $PWD or ${PWD} to display the
current directory in full, whereas \w always wants
to abbreviate the home directory as just ~
Example: [1]?0? stu1@debian5vm /home/stu1 $
- Also add these aliases:
# My favorite ll alias:
alias ll="ls -al"
# Three ways to play safe with Unix/Linux:
alias rm="rm -v -i"
alias cp="cp -v -i"
alias mv="mv -v -i"
# ... and also:
alias rmdir="rmdir -v"
- Add same changes to ~stu1/.bashrc and test. — Done.
- Add same changes to ~root/.bashrc and test. — Done.
- Copy ~stu1/.xinitrc to /etc/skel/.xinitrc so all new users
will get that too. — Done.
- Now, ready to start adding new users.
- Note that the utilities adduser(8) and useradd(8)
both exist. (How confusing is that?) The manual pages
suggest clearly that adduser is the easier,
user-friendlier one.
- Run (as root user):
adduser --shell /bin/bash --ingroup users jeremy
(It prompts for full user name, etc., and password.)
Added: User UID 1001, Group: users, Home directory: /home/jeremy
- Observe that directory /home/jeremy exists now, and all
the files from /etc/skel are there too, including revised
.bashrc and also .xinitrc
- Logout of root, log in as jeremy (password Yosemite7) and
check everything. Look at the command prompt, and check
that all those aliases are defined.
- Run startx to start kde. Run through first-time
preferences wizard. See everything mostly just like
with stu1.
- Enough for tonight. Shutdown.
- Details still to do: &emsp [Update: These things done, 27 Feb. 2011]
- I notice that user stu1, as installed, belongs
to a whole bunch of other groups too. (See
/etc/group file.) Consider adding jeremy to
some or all of those too.
- Modify root's command prompt in /root/.bashrc
to appear in red, or black on red background.
- All the remaining assigned tasks.
2011-02-27
- Only have about 2GB free disk space on the host machine.
Therefore, backed up the .vmdk from the GeeWhiz2 VM
(the Windows Server 2008 machine from CMPSC 289 last
semester) and deleted that, recovering 12GB space. That
should last for this semester. Have about 14GB now!
- Debian 5 Linux Mid-Term VM (debian5vm) started.
Back to top
We immediately notice something different:
It started kdm automatically, thus bringing up a GUI
login screen! Last I saw it on Feb 24, it was booting up
with a plain-text login screen, then you had to run startx
to go GUI. What has changed since then? Did I do something
to cause this?
- Upon re-reading the above log entries, on second
thought, it looks like I never tried re-booting. I just
may have logged out and logged in a bunch of times,
but never re-booted. So re-booting gets kdm
activated, although I thought I didn't install
kdm. Anyway, if you want a plain console
login, there's a menu option for that.
- Begin today with some loose ends left over from Feb. 24:
- Edit /root/.bashrc — Make the super-user command
prompt appear white on red background, and include
the text "(SUPER-USER!)"
- Edit /etc/group — Manually add user jeremy
to all the same groups that the pre-configured user
stu1 is in (except the stu1 group):
dialout, cdrom, floppy, audio, video, plugdev
- Shutdown to begin preparations for creating a second virtual disk.
- Create a second Virtual Disk:
A somewhat brief summary is logged here.
For a complete annotated transcript, look here.
- Run the VMware Add Hardware wizard (with the VM itself
NOT running). A few salient details:
- Disk type: SCSI, NOT Independent.
- Capacity 2.0 GB, split into multiple files.
- Disk file: debian-disk2.vmdk (not the default name).
- Boot up the Virtual Machine. Log in (as jeremy),
and do most or all of the following steps as super-user:
- Create and mount the new file system:
- fdisk -l — Shows that new disk /dev/sdb is
visible but has no partition table yet.
- fdisk /dev/sdb — Create two partitions
(type 82 swap and type 83 data) and write the
partition table.
- fdisk -l (again) — Now shows that /dev/sdb
has the two partitions just created.
- mkfs.ext3 /dev/sdb2 — Create ext3 data filesystem
on the second partition.
- Create mount point directory /mnt/sdb2
- mount /dev/sdb2 /mnt/sdb2 — And verify that
it works!
- Edit /etc/fstab to define new partition there
and auto-mount it on boot:
/dev/sdb2 /mnt/sdb2 ext3 defaults 0 2
- Re-boot and make sure everything is still there,
and see that it auto-mounts properly.
- Still to-do:
- Test the swap partition with mkswap, swapon, and swapoff.
- Experiment with creating a swap file with dd and mkswap.
- Write the assigned shell scripts to mount and unmount these.
- Played with Konqueror a little bit, browsing to various
web sites, decided I don't care that much for it. Various
things don't seem to work quite right. THEREFORE . . .
- Installed iceweasel. — The command for
this is: apt-get install iceweasel
done as super-user. (This also automatically adds iceweasel to
the KDE start-menu, if you dig deep enough to find it.)
Played with this enough to conclude that it works, and
configured a bunch of my preferred settings (most significantly,
Javascript is disabled, and cookies and most
everything else are deleted at exit.) This is done by and
for user jeremy.
- Shutdown.
2011-02-28
- 14:30 Made zip back-up of entire VM and verified.
Back to top
- 14:40 Change network configuration in the VM from NAT
to bridged so I can test sshd (and later, web server) from
other machines across the local LAN. (Remember to set it
back to NAT later.)
- 14:50 Debian 5 Linux Mid-Term VM (debian5vm) started.
(I noticed that it auto-fsck'd /dev/sdb2 during boot.)
- Installing sshd:
For a complete annotated transcript, look here.
- 14:51 /sbin/ifconfig shows IP address is 192.168.0.4 today.
Remote client can ping this machine by IP number, but not by host name.
- 15:15 Install sshd, running: apt-get install openssh-server
(as super-user). Took about 2 minutes.
Other installation options are:
- apt-get install ssh — Installs OpenSSH server and client.
- apt-get install openssh-server — Install server only.
- apt-get install openssh-client — Install client only.
I am installing server only because, as observed earlier, the
ssh client is already here.
This install procedure not only installs, but also starts sshd running.
Use ps aux | grep sshd to see if sshd is running.
- 15:32 Tested logging into this VM via ssh clients:
- ssh localhost — Works! Logs in (again) as jeremy
- ssh stu1@localhost — Works! Logs in as user stu1
- Log in to jeremy@192.168.0.4 from Windows XP machine using PuTTY — Works!
- 15:34 Shutdown and re-boot to be sure that sshd will start on boot.
- Yes, it does. ssh stu1@localhost still works.
- 15:40 Shutdown.
- Don't forget to reset net card to NAT.
- Some additional remarks:
- Server sshd configuration file /etc/ssh/sshd_config in installed now.
It appears to come with good settings as installed, since I didn't
have to do anything with it.
- To start or stop the service manually: /etc/init.d/ssh [start|stop]
- Installing LAMP (Linux / Apache / MySQL / PHP ) —
Part 1: LAP but not M (yet)
Back to top
(Well, the L is already installed, of course.)
- As with the kde install, begin by studying various web sites. These seem good:
- 18:34 Booting Debian 5 Linux Mid-Term VM (debian5vm);
logging in as jeremy; start Konsole; running as
super-user (root).
- 18:39 Run: apt-get update as recommended to do first by many of
the above sites. Took about 30 seconds.
- 18:42 Begin apache2/php5 installation with:
- apt-get install apache2 php5 libapache2-mod-php5 apache2-doc
- Estimated 42.7 MB disk space required.
- Suggests also installing ca-certificates
- 18:47 Done — ps aux | grep apache shows six apache2 forks running now.
- 18:50 Edit /var/www/index.html to make it just a little bit more distinctive.
- 18:53 Fire up iceweasel and see if I can browse to http://localhost/ — It works!
- 18:58 Now fire up another physical box on this LAN and see if
I can get to this page from there as http://192.168.0.4 — That works too!
Note, however, that I can only get there by IP address and not by host name.
- 19:02 Created PHP test file /var/www/testphp.php containing:
#testphp.php
<?php phpinfo(); ?>
Attempt to browse to there doesn't work.
- 19:04 Restart apache2 server with: /etc/init.d/apache2 restart
and try again. Now it works.
- 19:26 Copied my Mid-Term web log files (such as they are at present) to
/var/www: midterm-debian.html, disk2trans.html, and sshdtrans.html
- 19:30 Browsing to those &mdash Works too!
- 19:10 Now, configuring to support user web sites (in public_html
sub-directory under users' home directories):
-
Add files userdir.conf and userdir.load from /etc/apache2/mods-available
to /etc/apache2/mods-enabled.
This is customarily done by creating symbolic links in
/etc/apache2/mods-enabled pointing to the files in
/etc/apache2/mods-available
cd /etc/apache2/mods-enabled
ln -s ../mods-available/userdir.conf
ln -s ../mods-available/userdir.load
- Re-start apache2 server with: /etc/init.d/apache2 restart again.
- 19:19 Exit super-user. Running as plain old jeremy now.
- 19:20 Create simple starter web site as ~jeremy
mkdir public_html
cd public_html
Create simple stub web page file there called index.html
Browse to that as http://localhost/~jeremy &mdash Works!
- 19:23 Browse there from XP box too, as http://192.168.0.4/~jeremy
&mdash That works too!
- 19:49 Moved the Mid-Term log files (mentioned above) to
/home/jeremy/public_html and updated index.html to include a link
to midterm-debian.html (which in turn contains links to the other
two files). Browse those and verify that it all works.
- 19:51 That's about enough for tonight. Tomorrow, MySQL!!!
- 19:55 Re-boot, and test things enough to verify that everything
still comes up working.
- 19:57 That's affirmative, captain!
- 19:59 Shutdown.
- 20:05 In VM configuration settings, enabled remote
display to port 5911, per assigned specs. No password.
(That's all? Is there anything more we're supposed to do with this?)
- 20:15 Backed up VM to zip file again and verified.
I will continue to embellish this little private web site
from time to time, adding PHP and MySQL demos for example, without
necessarily logging every last little detail here. Check out
http://localhost/~jeremy yourself to see the latest goodies there.
2011-03-01
- 18:24 Debian 5 Linux Mid-Term VM (debian5vm) started.
Back to top
It appears to fsck all filesystems on every boot.
- 18:37 Left-over item from yesterday: apt-get install ca-certificates
(as root). Took about 30 seconds.
- 18:40 Begin installing MySQL
- 18:42 apt-get install mysql-server mysql-client php5-mysql
- Estimated 106 MB disk space will be used.
- It's installing various MySQL 5.0 modules: mysql-client-5.0,
mysql-server-5.0 and a bunch of perl related stuff.
- Installation procedure prompts for MySQL "root" administrative
password.
- MySQL root password: vmware12
- Note, the MySQL root account is NOT related to the Linux
root super-user account
- 18:49 Done. That was quick. Installation also says it
started mysqld server.
- ps aux | grep sql shows /usr/bin/mysqld running, along
with a few other related-looking things
- Data directory is /var/lib/mysql
- It also installed /usr/bin/mysql, the user command-line front-end.
- To start mysql (the user CLI interface) as root: mysql -u root -p
(It prompts for the password, which is vmware12).
(I don't think you need to be running as Linux root user to get
into the MySQL root account this way. Any user can do this if
you know the MySQL root password.)
- Commands (in mysql, as MySQL root user) to create some user accounts:
- create user 'jeremy'@'localhost' identified by 'Yosemite7';
- create user 'jeremy'@'debian5vm' identified by 'Yosemite7';
- create user 'jeremy'@'127.0.0.1' identified by 'Yosemite7';
- create user 'stu1'@'localhost' identified by 'Yosemite7';
- create user 'stu1'@'debian5vm' identified by 'Yosemite7';
- create user 'stu1'@'127.0.0.1' identified by 'Yosemite7';
I think the @'hostname' part of the command indicates the name of
a machine from which the user may log in to the server, so you can
allow a user to get in only from specific machines. I also think
you could put * here, as in 'jeremy'@'*' to allow
the user to log in from ANYWHERE, but I'm not sure of that.
The "identified by" part is the password for that user.
- To view all the MySQL users:
- use mysql;
- select user, host, password from user;
- To exit from mysql, type \quit or just \q
- 19:05 Exit super-user, back to being just jeremy.
- 19:05 Begin playing with mysql a little bit, as user jeremy.
- To start mysql: mysql -p then enter password when prompted.
- mysql> create database test; — Succeeded (creates new database named "test").
- mysql> show databases; — Shows list of databases, now including "test".
- mysql> \q or \quit — Quit.
- 19:10 - 20:35 Playing around with the local ~jeremy web site.
Check it out at http://localhost/~jeremy !!!
- 20:38 Shutdown.
- 20:50 Made zip back-up of the entire VM and verified.
- 23:38 Debian 5 Linux Mid-Term VM (debian5vm) started again.
Back to top
- 23:38 Installing some of the CGI scripts and related stuff from
CMPSC 206 last semester,
and miscellaneous other stuff that may be of interest.
- Installed:
- pwlookup.cgi — Lets you enter user login name or UID, displays /etc/passwd information.
- lsvartmp.cgi — Lists files in /var/tmp
- psef.cgi — Runs ps ef and displays that.
- uptime.cgi — Displays last five uptime results.
- webwrapper.sh — "Middleware" for any number of these scripts.
- uptimezz.sh — Back-end for uptime.cgi
The .cgi files go into /usr/lib/cgi-bin and can be accessed via the
URL http://localhost/cgi-bin/whatever.cgi
The .sh files go into /usr/local/bin (not where I would prefer them,
but it's in apache's search path).
- Tested all of those. They work! Did some minor further
development — Mostly cosmetic improvements for better demo show.
- Update jeremy's home page at http://localhost/~jeremy to include links
to run those. Check them out!
- Installed into /usr/local/bin ( with sources into /usr/local/src ):
- parg — Prints its arguments
- Prints each argument on a separate line, numbered. Helpful to
see exactly what arguments a program is receiving.
Compare, for example:
- parg `date`
- parg " `date` "
- parg \`date\`
- cksm — Computes a checksum for a file
- Uses a simple algorithm I invented. Displays file size
and a four-decimal-digit checksum. Some history: Circa 1986,
I used the sum(1) program to verify that files transferred
from one machine to another across the in-house LAN were
intact &mdash Only to be mortified to discover that the
Sys V and BSD versions were different (and neither was
documented anywhere I could find). That's why, like any
REAL Unix administrator, I wrote my own.
It gives the SAME check-sum on Sys V and BSD, and
I even have a compatible DOS version. I have used these
for 24 years now, to this very day, and you can too.
- 2011-03-02 01:20 — Shutdown.
- 2011-03-02 02:00 Made zip back-up of the entire VM and verified.
Current status as of 02 March 2011, 12:30:
- EVERYTHING assigned for this Mid-Term project is done, EXCEPT:
- mount-midterm1 and umount-midterm1 scripts to work with the second
disk swap and data partitions.
- Some additional work I envision doing:
- Create a MySQL database (perhaps the same class roster we earlier
did with SQLite).
- Create a simple HTML/PHP/MySQL demo using that, and add a link
to same on the main ~jeremy home page.
- Perhaps a web-based front end for those mount and un-mount
scripts also.
2011-03-02
- 15:00 Debian 5 Linux Mid-Term VM (debian5vm) submitted to Prof. Dale Phillips
Back to top
- However, I still plan to do at least a little additional
work on this project
(as noted just above) and then submit it again.
- 23:06 Debian 5 Linux Mid-Term VM (debian5vm) started.
- Installed findip script into ~jeremy/bin and
/usr/local/bin to get the IP address.
The salient line is:
/sbin/ifconfig eth0 | grep 'inet addr:' | tr -s ' ' ':' | cut -d: -f4
- Modified .bashrc in ~root, ~jeremy, ~stu1, and /etc/skel
to use findip to set MYIP environment variable:
MYIP=`findip`
export MYIP
- 23:59 Shutdown
2011-03-03
- 13:50 Debian 5 Linux Mid-Term VM (debian5vm) started.
Back to top
- 14:20 Created MySQL database "classdb" with a table called "users",
containing the class roster.
(This is basically the same database that
we earlier created elsewhere using SQLite.)
Here, I've added fields
for the students' freeshell URL's and e-mail addresses.
Wrote SQL script mkusers.sql to create this db and fill in all the data.
Look here for a transcript of
the whole process, including a list of the mkusers.sql script
(also including additional steps I did manually to grant jeremy the
necessary MySQL privileges to do this).
- 14:26 Shutdown.
- 20:35 Debian 5 Linux Mid-Term VM (debian5vm) started again.
- Imported new files for this web site (and did some minor cosmetic edits as needed):
- midterm-debian.html — This log page, up through the 14:26 entry just above
- mkusers-trans.html — Transcript of session showing creation of MySQL database
- classdb_simple.php — PHP script to display data from that database
- [Update 2011-03-05: File revised and renamed roster210.php now.]
- class_1php.html — HTML-formatted viewable listing of that PHP script
- [Update 2011-03-05: File revised and renamed roster210_php_list.html now.]
- Viewed / tested all of these new files, especially the PHP script. They work!
- classdb_simple.php reads all the records in the classdb database and displays
them in a neat tabular layout. The data includes the URLs to the students'
freeshell web sites. These are CLICKABLE links that you can go to!
- Try them yourself! —
- Run it! (only works if you
are actually on this Mid-Term Debian VM machine)
- View PHP script
- [Update, 2011-03-05: Revised and renamed these files (see
log entry of 2011-03-05 just below), and updated the
above links to point to the new files.]
- 21:33 Shutdown.
2011-03-05
- Note – Renamed classdb_simple.php → roster210.php
along with some minor cosmetic changes.
- Installed new web page roster210_php_list.html with
viewable listing of that. (This replaces class_1php.html)
- Updated file names and links in 2011-03-03 entries above.
- (Note, there is no mention here [yet] of this VM being
booted today. That's because I'm doing these changes "off-line"
on another machine, to be imported into this VM later.)
- 03:06 Debian 5 Linux Mid-Term VM (debian5vm) started.
Back to top
- 03:30 Imported the above-mentioned files.
- 03:40 Minor updates to those files, as needed
for this machine (user=jeremy, password=Yosemite7,
which isn't a secret on this machine).
- 03:46 Updating this log with these entries.
Also updating main web page, index.html
- 04:10 Format and enable /dev/sdb1 as second swap partition:
See complete transcript
Here is a brief overview of the steps (all done as super-user):
- Before starting: fdisk -l /dev/sdb,
df, swapon -s, just to
check the status of things. No evidence that /dev/sdb1 is already being used
as a swap area (as there shouldn't be).
- Prepare the partition as a swap area: mkswap /dev/sdb1
- Enable swapping on the partition: swapon /dev/sbd1
- Added this line to /etc/fstab: /dev/sdb1 none swap sw 0 0
- 04:25 Rebooting system: shutdown -r now to see
if the swap partition will be automatically enabled upon booting.
- 04:28 System rebooted. swapon -s
shows that /dev/sdb1 is still enabled for swapping.
- 05:16 Updating this log. Created stub HTML file for the
above-mentioned transcript, until I get it all done and formatted
nicely (watch for it RSN)
- 05:20 Enough for tonight. Shutdown.
2011-03-06
- 00:45 Debian 5 Linux Mid-Term VM (debian5vm) started.
Back to top
- Uploaded and installed:
- 01:20 Shutdown.
- 22:04 Debian 5 Linux Mid-Term VM (debian5vm) started (again).
Back to top
- Write, test, and install shell scripts:
mount_midterm1 and umount_midterm1 in /root/bin
- Import mm1 (prototype script written on frazzle)
- All of the following steps done as root user in /root directory
- mkdir bin — Create /root/bin directory
- chmod 750 bin
- mount_midterm1 and umount_midterm1
finished, tested, and installed into /root/bin
- Edit /root/.bashrc to add /root/bin to PATH if not already there.
The added lines in .bashrc are:
# 06 Mar 2011: Add /root/bin to PATH if not already there:
echo $PATH | tr ':' '\n' | grep ^/root/bin$ > /dev/null
if [ $? != 0 ]
then
PATH=$PATH:/root/bin
fi
- See listing of these scripts, which includes some usage notes.
- 23:02 Shutdown.
This completes all assigned tasks (and then some) for this CMPSC 210 Mid-Term Project.
Back to top
2011-04-17
Begin FINAL EXAM project, starting with this VM where we
left off above.
Back to top
We begin with a brief review of some
details of current machine status, that might be relevant
for the Final Exam project:
- sshd is already installed (may be used with rsync
and perhaps VNC stuff).
- rsync is not already installed. Will need to do that.
- Apache web server, PHP, and MySQL are already installed
(including a PHP/MySQL demo web page.)
- Log in as user jeremy with password Yosemite7 –
This user has more goodies set up than the original
user stu1.
- Iceweasel is installed, and user jeremy has
an icon on the desktop to start it. Check out the
home page at http://localhost/~jeremy
(If you're reading this on the Debian Final Exam
machine, then you've probably already figured that out.)
- If you need to be super-user, the password is vmware12
Overview of the Final Exam assignment:
- Create new user jay with full user name Jay Jaeckel.
- But note, the class instructor should still log in
as jeremy when reviewing this project, because
all this student's work was done there, so that is
where everything is.
- Write shell script to run dmesg(1) and capture
the last 20 lines to a file.
- Set up a crontab entry to run the above on a regular schedule.
- Set up a web page to display the same.
- And for bonus brownie points, figure out how to make
the page auto-refresh every few seconds.
- Install rsync and write a script to use that to
copy web directory from sdf freeshell account to this VM.
- And for still more brownie points, learn how to
set up a security key and use this to automate
the process with another crontab entry, so that
it can be automated without the need to manually
enter the freeshell account password.
- Mentioned in lecture (9 March 2011): Install VNC server and client
and get those running. Test both in-bound and out-bound
VNC connections between this and another machine.
Begin doing Final Exam assignment:
- Set Network Adapter to be BRIDGED rather than NAT.
Back to top
- Remember to change this back to NAT later!
- 02:45 Debian 5 Linux FINAL EXAM VM (debian5vm) started.
- 02:52 Installed run-dmesg.php into /home/jeremy/public_html
- Run it now.
(Note: Only works on debian5vm Final Exam machine.)
- Displays last 20 dmesg(1) lines.
- Auto-refreshes every 5 seconds.
- URL is http://(hostname or IP address)/~jeremy/run-dmesg.php
- 03:16 Also created and installed
run-dmesg-php.html, web
page showing source-code listing of run-dmesg.php script.
- 03:31 Enough for now. Shutdown.
- [Update: 22 Apr 2011: All of the dmesg-related files and more
re-written and re-installed, some of them with slightly
different names, and the above text and links updated.
Go to 22 Apr 2011 for all the latest.]
2011-04-21
- 00:25 Debian 5 Linux FINAL EXAM VM (debian5vm) started.
Back to top
- 00:43 Begin working on the project to update ~jeremy web site
using rsync, to be incorporated into a script to be run via cron.
- Much of this work follows the very clearly written instructions at
http://troy.jdmz.net/rsync/index.html
which focuses on using rsync with an public/private authentication key so that it can
be run automatically without manual user intervention (specifically, without the
user having to be there to enter the remote login password).
- Begin by testing this command manually:
rsync -arvz -e ssh jaeckell@csrh1.yosemite.edu:/home/jaeckell/Dogweb /home/jeremy/Testweb
Result: rsync command not found. (Oops.)
- apt-get install rsync
- Re-ran above command. Now it works – although it put the files in the wrong place.
- With some experimentation, we find that this does the right thing:
rsync -arvz -e ssh jaeckell@csrh1.yosemite.edu:/home/jaeckell/Dogweb/ /home/jeremy/Testweb
(Can you spot the difference in this command?)
At this point, however, it still requires a manually entered password.
- 01:05 Before going any farther with the key authentication, first see if we
can get a simple cron task to run —
ANY simple cron task. Like:
* * * * * /bin/date > /home/jeremy/date.log
(We are paranoid about this after having been utterly unsuccessful in getting any
such thing to run on either sdf or csrh1 machines.)
Result: Here in debian5vm it works. So there!
- 01:24 Now begin working on the key authentication.
- 01:36 Test logging into csrh1 manually, with:
ssh -i cron/debian5vm-rsync-key jaeckell@csrh1.yosemite.edu
Result: It works! No password required.
- 01:44 Next, try running rsync manually that way, with:
rsync -arvz -e "ssh -i cron/debian5vm-rsync-key" jaeckell@csrh1.yosemite.edu:/home/jaeckell/Dogweb/ /home/jeremy/Testweb
Result: That works too!
- 01:44 Write shell script bin/getdog.sh to update local ~jeremy
web site from csrh1, using the above technique. The overall procedure is:
- Assume that the latest files from doggie.freeshell.org have been downloaded
to csrh1:/home/jaeckell/Dogweb directory.
(See discussion and transcript of that here.)
- Run rsync as described above to download any modified files from there
to the local machine, into /home/jeremy/Testweb directory.
- Then copy all the files from there to /home/jeremy/public_html directory.
- Some running commentary on these steps is written to stdout
- The plan is to run this periodically as a cron task, capturing the output
to a log file in ~jeremy/public_html, so that you can look at the most
recent output right here on-line.
- 02:20 After some experimentation, I am going to settle on running it
five times per hour as a cron task, with this private crontab entry:
# Download web site updated from jaeckell@csrh1.yosemite.edu
# Run five times every hour.
# The output goes to a log file in the web site directory too.
3,15,27,39,51 * * * * /home/jeremy/bin/getdog.sh > /home/jeremy/public_html/getdog.log 2>&1
View a listing of the script getdog.sh here
View the latest download log here (on debian5vm
machine only).
- 03:00 Shutdown.
- Work still to be done on this:
- Revise getdog.sh script to write its output as properly formatted HTML file.
- Revise crontab entry to capture that to getdog-log.html instead of getdog.log
- Revise the above links to point to that.
- [21 Apr 2011 22:30 Update: These steps are all done now.]
2011-04-21 (continued)
- 08:58 Debian 5 Linux FINAL EXAM VM (debian5vm) started (again).
Back to top
- 09:10 Create new user jay — Substantially the same as
adding new user jeremy ( Feb. 24, 2011, above )
- adduser --shell /bin/bash --ingroup users jay
- UID = 1002
- Manually edit /etc/group — Add to groups: dialout,
cdrom, floppy, audio, video, plugdev
- 09:55 Log in as jay. Configure some of the
basics for this user, largely according to my personal
preferences, similarly to user jeremy but not as
extensively.
- For purposes of reviewing this Final
Exam project, the course instructor should log in
as jeremy rather than jay.
All of the development work was done there, so there
is much more to see there. For example:
- This web site is at ~jeremy.
- Iceweasel there configured to open with ~jeremy as home page.
- More desk-top icons and launchers in panel.
- crontab with periodic rsync of web site is there.
- 10:25 Shutdown.
- 16:05 Debian 5 Linux FINAL EXAM VM (debian5vm) started (again).
Back to top
- 16:20 Begin installing a few other useful goodies
from my home Linux machine that I have found useful:
- apt-get install sshfs –
(Also installs fuse-utils and libfuse2.)
- With some experimentation, discovered:
- /dev/fuse has permissions 660, needed to change
this to 666 so I could mount remote directories.
- (Later observation:) Every time machine reboots,
/dev/fuse gets set back to 660, and I have to
chmod it to 666 again.
- /usr/bin/fusermount has permissions 754 (plus setuid root),
which must be changed to 755 (still with setuid root)
so I could un-mount remote directories.
- Installed some shell scripts from home Linux machine into ~jeremy/bin:
- csrh1 — ssh into jaeckell@csrh1.yosemite.edu
- sdf — ssh into doggie@sdf.org
- mount-csrh1 — sshfs mount jaeckell@csrh1.yosemite.edu home directory on local ~jeremy/csrh1
- mount-sdf — sshfs mount doggie@sdf.org home directory on local ~jeremy/sdf
- Edited these scripts as needed, changing username "jay"
to "jeremy"
- Some additional notes:
- Use: mount-csrh1 -u
and mount-sdf -u
to un-mount.
- These all require passwords to be entered manually
for the remote logins. They don't use the key
authentication like the rsync script does.
- On my home Linux box (Ubuntu with GNOME), remote
mounting puts an icon onto my desktop but here
(Debian with KDE) it does not. (Go figure.)
- 18:15 Shutdown.
2011-04-22
- 16:00 Debian 5 Linux FINAL EXAM VM (debian5vm) started.
Back to top
- 16:16 Re-wrote and improved run-dmesg.sh and run-dmesg.php
(note the slightly changed name) and related files:
- Installed new script run-dmesg.sh into ~jeremy/bin
— It now writes its output to stdout instead of to
a specific file in /var/tmp, and has an option -h to
produce a complete HTML web page as its output. The
plan will be to run it as a cron task with the -h
option and direct the output straight to the web
directory. Ran this manually to produce the initial
web page, ~jeremy/dmesg-log.html
- Installed/updated web pages on sdf machine, then
downloaded them (via csrh1) to debian5vm:
- run-dmesg-sh-list.html
– (Viewable list of run-dmesg.sh script)
– View listing now
- run-dmesg.php
– Fancier script to run dmesg on demand (in real
time, not via cron) every five seconds.
– Run it now.
- run-dmesg-php-list.html
– (Viewable list of run-dmesg.php)
– View listing now
- 16:30 Create cron entry to run run-dmesg.sh once every minute,
writing a full web page (-h option) directly to web directory:
* * * * * /home/jeremy/bin/run-dmesg.sh -h > /home/jeremy/public_html/dmesg-log.html
- 16:44 Shutdown.
Note that the above dmesg stuff is UN-interesting, since
new messages rarely appear after the machine is finished
booting. Thus, you can watch those web pages refresh themselves
all day, and nothing much visibly happens.
Therefore, I've written some analagous scripts (one shell script
to be run as a periodic cron task, and one PHP script to run
on-demand) to display messages from the Apache2 log files &ndash
both the access.log file and error.log file. The following
items describe these:
- 21:50 Debian 5 Linux FINAL EXAM VM (debian5vm) started (again).
Back to top
- 21:58 Wrote and installed run-weblog.sh shell script and run-weblog.php PHP script.
- Installed new script run-weblog.sh into ~jeremy/bin
— Like run-dmesg.sh, it writes its output to stdout,
and has an option -h to produce a complete HTML web page
as its output. This too will be run as a cron task with
the -h option, with the output directed straight to the web
directory. Ran this manually to produce the initial
web page, ~jeremy/web-log.html
- Installed/updated web pages on sdf machine, then
downloaded them (via csrh1) to debian5vm:
- run-weblog-sh-list.html
– (Viewable list of run-weblog.sh script)
– View listing now
- run-weblog.php
– Fancier script to do the same on demand (in real
time, not via cron) every five seconds.
– Run it now.
- run-weblog-php-list.html
– (Viewable list of run-weblog.php)
– View listing now
- 22:05 Some observations: The run-weblog.php script could not read
the web log files due to permission restrictions. Had to
make these changes (running as root):
- chmod 755 /var/log/apache2 — (was 750)
- chmod 644 /var/log/apache2/access.log and error.log — (were 640)
- I wonder what will happen when time time comes for
those log files to get rotated. Will new ones be
created with the original permissions?
- 22:17 Create cron entry to run run-weblog.sh once every two minutes,
writing a full web page (-h option) directly to web directory:
*/2 * * * * /home/jeremy/bin/run-weblog.sh -h > /home/jeremy/public_html/web-log.html
- 22:22 Shutdown.
2011-04-24
2011-04-25
This completes all assigned tasks (and then some) for this
CMPSC 210 FINAL EXAM Project.
Back to top
All that remains to be done is:
— Set the VMware network card adapter back to NAT
— Zip up the entire VM
— Turn it in!