Recently I was searching around looking for a way to create a hidden page on a WordPress site. It is a hosted site, not on wordpress.com. It is on a Linux server to which I have shell access.
Initially I tried using a plugin that I found that hides pages and posts. Plugins, you got to love or hate them. Love then when they work great right out of the box, hate them when they take a long time to troubleshoot.
Rather than waste too much time with the plugin, I went straight to the command line.
It turns out that if you publish a page and then log into the hosting server, make a directory somewhere under your public_html, change directory into it and execute…
wget -x -nH your-page-url-to-hide-here
Set to Draft or Private
…then go back it and make the page a draft or under review, so it “disappears” from the menu structure. It will still work as a “cached” HTML page that has been downloaded to the folder that you have created. It will work, pictures and what not that you have loaded in it will be fully functional.
I have noticed that caching can get in the way. If your server caches pages, wget may not see the page updated when you make changes. A quick remedy is to set the page to draft/pending review or private, delete the hidden page. I usually use rm -rf from the directory above it and then force it to download the “404” page. Then you can publish the page re-run wget and it will force it to get the fresh version. Keep note of the size of the file as a hint that it is getting the right one.
Upcoming: Do this with a CGI Script
In an upcoming post, I will cover how to make a CGI script that will allow you to create a hidden page easily without having to use SSH to login to the server.
wget options used in this example, from the man page
-x
–force-directories
The opposite of -nd—create a hierarchy of directories, even if
one would not have been created otherwise. E.g. wget -x
http://fly.srk.fer.hr/robots.txt will save the downloaded file to
fly.srk.fer.hr/robots.txt.
-nH
–no-host-directories
Disable generation of host-prefixed directories. By default,
invoking Wget with -r http://fly.srk.fer.hr/ will create a
structure of directories beginning with fly.srk.fer.hr/. This
option disables such behavior.
After having occasional dropouts of the Raspberry Pi Wifi ( after I started using it as a bridge) and having to ifup the wlan0 manually, I considered making a script to automate it. But, a little searching online found this elegant solution to the problem.
Easy to follow tutorial on installing Slackware Linux onto a Virtual Machine
I have been interested in trying out Slackware for some time now. The Slackware Linux Essentials ( aka Slackbook) is an excellent review of Slackware and Linux in general. I went through it one winter a few years ago and was impressed as it was a great refresher course on Linux. After a while I tend to forget some of the tricks on the command line that I do not use on a regular basis. Going over a manual like this is a good brush up. Reading the book convinced me that I would have to try out Slackware someday.
Tutorial
I had no trouble following the tutorial and getting Slackware up and running on a VirtualBox VM. The current version 14.2 (February 2018) is similar enough to the 13.0 install in the guide that the few differences are not a problem. The one difference that I noticed is that when the disk is partitioned the option for bootable did not appear for me as it did in the tutorial. I just went ahead and wrote the disk and it was fine. The tool might have some logic built in to decide what to do and does not required you to tell it that it has to be set as bootable anymore.
Hacking /boot/grub/grub.cfg is not usually the first thing that comes to mind. But, I ran into a problem when installing Kali Linux on a plug in USB Hard Drive. I wanted to try to put it on a USB hard drive by using the USB boot stick. All went well with the install. On reboot, guess what, the USB stick and it’s multiple partitions was no longer “parked” on /dev/sdc-sdg and when Kali had installed it thought it was going to be at /dev/sdh. Pulling the USB stick put the USB Hard Drive at /dev/sdc on the next boot! So naturally when grub wanted to boot the machine it drops to a command prompt after it times out trying to find where root is on /dev/sdh which has disappeared. When this happened, I puzzled on it for a few minutes before digging into grub.cfg, it was not my first thought, but it was the only thing that I could think of that could doing this.
When the machine can boot and drops to the basic command line find out what drives it thinks it has by running…
ls /dev/sd[a-z]2
…this will show all the sda2,sdb3 and etc. Usually but not always the 2nd partition is the Linux File System, this is where the /boot directory lives with all of the GRUB files. Using a USB Stick with a live install or the DVD and booting is helpful at this point as you can use sudo fdisk -l to list what drives are available and you will need to use and editor to modify the grub.cfg file.
Hacking grub.cfg
The hack is to reboot the machine either with the USB stick/Live DVD or off of the hard drive resident in the machine and then….
chmod 644 /boot/grub/grub.cfg
…as it is read only…
-r--r--r-- 1 root root 14791 Jan 7 16:29 /boot/grub/grub.cfg
…remember to chmod it back to read only after editing using….
chmod 444 /boot/grub/grub.cfg
Make a backup copy of it first before editing!
Editing grub.cfg
Once you have it in read/write state open it in an editor, emacs or something, even nano would work.
Yes it complains not to edit it, but when you can’t boot at all, because it can’t find where the root is, it’s worth a try!
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
In a terminal window find out where the drive is really mapped using…
sudo fdisk -l
Example of second bootable disk at /dev/sdb…
Disk /dev/sdb: 149 GiB, 160000000000 bytes, 312500000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0007e21b
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 279187455 279185408 133.1G 83 Linux
/dev/sdb2 279189502 312498175 33308674 15.9G 5 Extended
/dev/sdb5 279189504 312498175 33308672 15.9G 82 Linux swap / Solaris
The trick is to make the lines for the drive the OS is on that you are trying to boot and that is failing line up in grub.cfg. In grub.cfg search for lines like this…
set root='hd0,msdos1'
If it says hd0 it better be the sda drive for instance. In my case it showed hd7=sdh and I needed to edit hd7 to hd2. This was done via a search and replace.
Also for good measure and to keep all the commenting straight correct anything by searching around for /dev/sd and make sure all the menuentrys line up with the hd* values in set root. This is just so that you don’t get confused later if set root is changed and the menus don’t line up with reality.
menuentry 'Linux Mint 17.3 Xfce 64-bit, with Linux 3.19.0-32-generic (on /dev/sdb1)
After this correction, it booted fine. Now I will just have to pay attention to what happens with drive mapping in case I plug it into another machine. But, it is just an experiment for now, nothing critical on the drive so no worries!
Another note on Boot Repair
If grub gets totally screwed somehow, boot-repair will fix it.
For instance I once had grub lose it’s brains on an EFI boot drive. The symptom was the error about not finding a bootable medium from the BIOS. Use boot-repair. Boot using a live CD or usb stick with exact same version as you are trying to fix! Run the repair and let it automatically fix it.
Below are the schematics for the 7490 TTL Chip Clock. After 10 years of not doing anything with the clock, I had to spend some time reverse engineering it a bit to understand it’s design. The original hand drawn schematics ( not published on this site ) were a bit off target as I deviated from them. These new ones that are published are accurate. They were hand drawn then scanned and imported into Gimp for cleanup.
Clicking on the images on this page will bring up a full sized version.
Gimp Drawing Cleanup
In Gimp basically the process is to use threshold to clean the “noise” out from the scan. Then cut more noise out using the cut tool and eraser. Then go over the lines with the pencil tool where they are faint. Finally, add text in. Yes, there are some CAD tools that could do this easier but, since I don’t do this kind of thing to often, Gimp works out nicely as I have had a lot of hours on it and can work quickly in it.
Slave Oscillator and Prescaler, dividing from 10MHz to 1kHz on the right hand board
This schematic shows all connections, including power and ground and is laid out to represent the component placement on the board. Looking at the 7490’s the pattern of the circuit is just like the example from How it Works, dividing frequency by 10 every time. The difference between the clock that I built and theirs is that I used a 10MHz source and they used 60Hz line frequency. Therefore I needed to use more divider stages. There is a shortcut, the 74390 chip. It is a BCD dual divider/counter. It could eliminate half of the stages as it divides by 100. I happened to have quite a few 7490s at the time that I built this clock and went with that approach rather than order 74390s. I would recommend using the 74390s though, less stages, less soldering, less power consumption being the benefits.
7490-clock-10Mhz-to-1kHz-schematic
1kHz Divided down to Hours, Minutes and Seconds on the left hand side board of the clock
This schematic DOES NOT show all connections, power and ground are omitted, also no connects on the chips are omitted, plus the 7447 chips are there to show there location but the connections are not shown. Refer to the page that covers the How it Works information on how to connect 7490s to 7447s. It is laid out to represent the component placement on the board. However the board is inverted on the clock and the digit LEDs sit on the bottom of the board but inverted in order to read them.
I decided to use hybrid sleep instead of a suspend. I have been using the code for autoshutdown as both autoshutdown, using the shutdown command and suspending. A server that I have been using for a year now supports suspend and I have used systemctl suspend successfully with it. But, if the power goes out, the next time it is as if it was shut down and gets a fresh boot. The way around that is to use systemctl hybrid sleep which puts the RAM content into swap and then suspends. This way if the power goes out it will just resume from hibernate.
Reboot code
After setting up the machine with hybrid sleep. I realized that the mechine needs a reboot once and a while after unattended updates and thought that it would be nice to automate that process. I looked on line and found a piece of code that will reboot the machine if a reboot is required. This is done via detecting the presence of the reboot-required file. So far testing once today 8/12/2017, OK so far!
Snippit of code added to autosuspend a.k.a autoshutdown code that was covered in the original post on this topic …
# If the reboot-required file is present, restart and l$
if [ -f /var/run/reboot-required ]
then
logit "RESTART REQUIRED"
echo 'Restart required' >> /var/www/html/shutdown.txt
date >> /var/www/html/shutdown.txt
echo "------------------------------------" >> /var/www$
systemctl reboot
fi
# Fall through and hybrid-sleep it!
systemctl hybrid-sleep
# Switched to hybrid-sleep 08122017 systemctl suspend
After a few months of testing ( April – June 2017 ) the 7490 TTL decade counter chip based clock out with the newly added OCXO it was ready to be mounted in a housing.
7490 TTL Clock with OCXO under test
Monitoring it against an accurate timebase ( Linux PC with NTP ) while piled up loosely on a small table in the office, it was running good and steady. No flaky counts, no flaky digits that were not lighting or staying lit when they should not be.
Consolidating Power
After the photo was taken above, the power supplies for the clock were consolidated. Under testing it was powered by 2 wall supplies, 5V for the TTL chips and 12V for the OCXO. For the final version I used a 7805 regulator on the right hand side board to down regulate 12V from a Radio Shack 12V/2.3A power supply to 5V for the TTL chips. I got lucky and spotted the power supply during the last few days that Radio Shack was still in business in April 2017.
Wood Housing
Not having a good set of tools on hand to build a metal housing, a good option was a wooden one. Micheal’s craft store had both the base that the boards were mounted to and the shadowbox. Both were unfinished and reasonably priced, I believe $5 for the board and $12 for the shadowbox in 2017.
7490 TTL Clock Circuit Board Base7490 TTL Clock Shadowbox, cover removed. A bit larger than is needed but, it works fine. The glass cover was removed in preparation for sanding and the application of linseed oil.
The base was drilled out to recess fit 10mm standoffs. Holes were drilled for the M3 screws and then countersunk with a larger bit to accommodate the 10mm standoffs. Once again I made out good at the Radio Shack closeout and got a bunch of standoffs.
Subassembly
7490 TTL Clock Mounted on Base
The clock mounted on the base in a state of readiness to drop into the shadowbox as a subassembly. This trick is a bit that I learned from working in manufacturing in the past. To make things efficient and serviceable it was common to mount boards on sub assemblies and then mount the subassembly into a piece of machinery.
7490 TTL Clock Mounted in Shadowbox
Finally the subassembly gets dropped into the shadowbox and is held in place by four small wood screws that are on the back.
While in the process of working on a digital clock that I built in 2007, I had to take another look at how a 7490 decade counter works in order to remind myself. I rigged one up with some LEDs to count 0 to 9, showing the count in BCD form on the LEDs.
The oscillator used to drive the 7490 counter is one stage of a 7414 Schmitt Trigger inverter. Using a 47 microFarad capacitor and a 15K resistor, this gives a slow enough pulse to watch what is going on at a calculated period of 0.588 seconds. It is basically running the 7414 as a relaxation oscillator, charging and discharging the capacitor through the resistor repeatedly. Being an inverter the output of the 7414 will be high when the input is low and vice versa, so it is always either charging or discharging the capacitor. The waveform, even though I don’t have a scope to put on it, at the capacitor must be a sawtooth I imagine.
Circuit Diagram
7414 and 7490 Diagrams: Click on to enlarge
Video of 7490 Counting
The 7490 is both a divide by 2 and a divide by 5 counter. To get a divide by 10, the divide by 2 at Q0 is fed into input B. Outputs Q0,Q1,Q2 and Q4 are weighted by 1,2,4 and 8 respectively. I have the laid out in descending weight from left to right on the board. All set and reset lines are grounded. It will freely run from 0 to 9 and around and around. These lines could be fed into a 7447 7 segment display driver and that would drive digits like a real clock if desired.
The small LED on the left is connected to the output of the 7414 and blinks at the output frequency of it, the jumbo LEDs count from the output of the 7490 and the tiny LED to the right is just strapped from power to ground with a dropping resistor to show that the board is powered. There are also two capacitors 0.1 and a 0.01 microFarad strapped from power to ground to bypass an high frequency switching that appears on the power rails, always a good idea to bypass, this is a good idea on every chip if possible. This eliminates high frequency noise on the power supply rails. Also grounding unused inputs on the 7414 or any chip that you might use is a good idea to prevent noise and erratic behavior of the circuit.
Powered at 3.5V
3.5VDC
The usual 5V power supply was tied up running the TTL Clock I built while testing it, so for this setup I grabbed a 3.5V supply. The TTL circuits seem to run fine at this voltage, the only thing is that the time constant is probably a bit shorter for the capacitor to charge and discharge.
I finally found the document that I based the 7490 clock that I built off of. Nothing like the process of moving to uncover lost items. The clock that I built had one main variation in that it did not use the 60Hz from the wall as a frequency reference. Instead it used a series of 7490 chips to divide down from 10 MHz to 1Hz to drive the clock portion. I did this with the foresight that at some point I was going to use a good crystal oscillator such as a TCXO, temperature compensated crystal oscillator or an OCXO, oven controlled crystal oscillator. These are readily available in 10MHz versions. Another plus is that WWV out of Fort Collins Colorado transmits on 10MHz using a signal derived from a cesium oscillator so the oscillator can be checked and calibrated ( mostly ) against their signal easily by using a shortwave receiver.
I was able to scan the original document and OCR it back to an electronic copy and published the text with the diagrams on this post. The original scan is at the bottom of this post. I downloaded it in 2007 from the How Stuff Works site. Unfortunately the well written article has disappeared from the Internet entirely or I would have just provided a link to it on this site. It has been put it up here for reference for anyone curious or wanted to build a clock out of 7490’s that use a 60Hz input. If this article reappears on-line, I would just link to it. If someone sees it somewhere, please let me know.
Circuit Diagram
Here‘s a circuit diagram tor the power supply and time base.
power-supply
As we saw in the article on electronic gates,the power supply is the most difficult part.
To create the rest of the clock you will need
At least four 7490 or 74LS90 chips
At least two 7447 or 74LSA7 binary to 7—segment converters
At least 20 resistors for the LEDs in the 7—segment displays ( 300 ohms would be
fine.)
Some normal LEDs
At least two common-anode (CA) 7—segment LED displays (Jameco; part #172088 is
typical)
Breadboard, wire. etc.
7490-pinout
The 7490 is a decade counter. Meaning it is able to count from 0 to 9 cyclically, and
that is its natural mode. That is QA, QB, QC and QD are 4 bits in a binary number, and
these pins cycle through 0 to 9, like this
You can also set the chip up to count up to other maximum numbers and then return to
zero. You “set it up” by changing the wiring of the R01,R02 R91 and R92 iines. If both
R01 AND R02 are 1 ( 5 volts ) an either R91 OR R92 are 0 ( ground ) then the chip will
reset QA, QB, QC and QD to 0. If both R91 and R92 are 1 ( 5 volts ), then the count on
QA, QB, QC and QD goes to 1001 (9). So
To create a divide-by-10 counter, you first connect pin 5 to to +5volts and pin 10
to ground to power the chip. Then you connect pin 12 to pin 1 and ground pins 2,3,6 and
7. Run the input clock signal ( from the timebase or a previous counter ) in on pin 14. The output appears on QA, QB, QC and QD. Use the output on pin 11 to connect to the next stage.
To create a divide-by-6 counter, you first connect pin 5 to to +5volts and pin 10
to ground to power the chip. Then you connect pin 12 to pin 1 and ground pins 6 and
7. Connect pin 2 to pin 9 and pin 3 to pin 8. Run the input clock signal ( from the
timebase or a previous counter ) in on pin 14. The output appears on QA, QB and QC. Use the output on pin 8 to connect to the next stage.
Creating the Second Hand
Knowing all of this, you can easily create the “second hand” of a digital clock. It looks like
this
seconds-count-using-7490
In this diagram, the top two 7490s divide the 60-Hz signal from the power supply down by a factor of 60. The third 7490 takes a 1-Hertz signal as input and divides it by 10. Its four outputs drive normal LEDs in this diagram. The fourth 7490 divides the output of the third by 6, and its three outputs drive normal LEDS as well. What you have at this point is a“second hand“ for your clock, with the output of the second hand appearing in binary. If you would like to create a clock that displays the time in binary, then you are set! Here isa view of a breadboard containing a divide-by-10 counter. a divide-by-6 counter and a set of LEDs to display the output of the counters in binary.
Displaying the Time as Numerals
If you want to display the time as numerals, you need to use the 7447. Here is the pinout
of a 7447, as well as the segment labeling for a 7—segment LED.
7447-pinout
You connect a 7447 to a 7490 like this
Provide +5 volts on pin 16 and ground on pin 8 to power the 7447 chip
Connect QA, QB, QC and QD from a 7490 to pins 7, 1, 2 and 6 of the 7447,
respectively.
Connect 330-ohm resistors to pins 13, 12, 11, 10, 9, 15 and 14 o0 the 7447,and
connect these resistors to the a, b, c, d, e, f and g segments oo the 7-segment
LED
Connect the common anode of the 7-segment LED to +5 volts
You will need to have the pinout for the specific LED display that you use so that you
know how to wire the outputs of the 7447 to the LEDs in the 7~segment device. ( Also,
note that the 7448 is equivalent to the 7447 except that it drives common-cathode
displays. Ground the common cathode of the LED in that case.)
V0u can see that by extending the circuit, we can easily create a complete clock. To
create the “minute hand’ section of the clock, all that you need to do is duplicate the
“second hand” portion. To create the “hour hand“ portion, you are going to want to be
creative. Probably the easiest solution is to create a clock that displays military time
Then you Will want to use an AND gate (or the R inputs or the 7490) to recognize the
binary number 24 and use the recognizer to reset the hour counters to zero.
NOTE: You can dispense with the and gate and simply wire the “2” line QB of the
hours-tens counting 7490 and the “4” line ( QC ) of the hours-ones counting 7490 and
connect BOTH to the same reset line (R1 or R2 )respectively on each of the hours 7490s.
In this manner when a 24 count occurs a reset is applied to both R1 and R2 on both hours
chips simultaneously, resulting in a reset to zero for both.
The final piece you need to create is a setting mechanism. On a breadboard, is is easy
to set the clock – just move the input wires to drive higher frequency signals into the
minute-hand section of the clock. In a real clock, you would use pushbuttons or switches
and gates to do the same thing.
If you happen to take your bedside clock or watch apart, one thing you will notice is that
there are probably not 15 TTL ICs inside. In fact, you may not be able to find a chip at all
in most modern clock or watches, all of the functions of the clock (including the alarm
and any other features) are all integrated into one low-power chip (in a watch, the chip
and display together consume only about a millionth of a watt.) That chip is probably
embedded directly into the circuit board. You might be able to see a blob of black plastic
protecting this chip. That one tiny chip contains all of the components we have discussed
here.
Recently I had a need to calculate seconds out of minutes and seconds. The BASH script below will take two integer arguments separated by a space and return a value in seconds.