command line fun – the basics

I was meeting with a younger friend to fix his virus laden laptop, it turned out to be quite a mess so we decided it would be more efficient to restore it from the recovery partition. I was a bit surprised to discover that his understanding of the command line was essentially a mystery.

This column will be examining various Linux commands that can be used in scripting or while working on the command line. Wherever possible I will also demonstrate similar functionality for windows batch files.   It is actually possible to do some basic scripting on windows but on a limited scale unless you install some additional product to help out.

Eventually, I am hoping to go beyond a “random” collection of commands and turn them into scripts to actually do useful work.

Basic commands

Linux Windows Description
ls dir This command lists the files in the current working directory
cd cd change directory to either a fully qualified directory name or to a subdirectory within the current directory
rm del delete the filename in the current directory
rmdir rmdir remove either a fully qualified directory name or to a subdirectory within the current directory
clear cls erases the screen and puts the cursor in the upper left hand corner

Linux command options

Command option meaning
ls -l directory listing in long format
ls -lt directory listing in date/time descending order
ls -ltr directory listing in date/time ascending order
ls -lSr directory listing in long format sorted by filesize ascending.
ls -1 directory listing only filenames
ls -1 directory listing only filenames
rm -r removes subdirectories and their containing files
rm -f ignore nonexistent files, never prompt
rmdir removes empty directories

Windows command options

Command option meaning
dir /od directory listing order by date ascending
dir /os directory listing order increasing by size
dir /b directory listing displaying filenames only
dir /oe directory listing sorted by file extension
del /f Force deleting of read-only files
del /s recursively remove directories and their files
Posted in Command line | Tagged , , | Comments Off on command line fun – the basics

WordPress from Scratch – part II

Installing WordPress is really one of the easiest pieces of software I have ever installed. Yet, either through a misunderstanding of mine or perhaps a tiny rough edge.

  • upload problems
  • problems with permalinks

One of the things that you can do to make your blog your own is to have a different header photo. The only limitation is that the size of the image should be below 2 megabytes.

appearance - customize - header image - add new image - upload

However, when trying to upload a new header I uncovered a few permission problems. The file will be saved under the wp-content directory. The uploaded photos will be stored under the uploads directory.

Fixing Uploads

One of the things that was missing on the installation was the uploads directory. In addition there were a few other operating system permissions as well.

mkdir /var/www/html/blog/wp-content/uploads
chmod 777 /var/www/html/blog/
chmod 777 /var/www/html/blog/wp-content
chmod 777 /var/www/html/blog/wp-content/uploads

Once these fixes were done, it was possible to upload the new photo without any problems.

Fixing Permalinks

When actually adding a few posts, I noticed that the permalinks didn’t actually work. I kept receiving the following message.

Oops! That page can’t be found.

I have seen a lot of solutions but it appears to simply go into parmalinks and simply press save with or without changing anything.

dashboard -> settings -> permalink

 

Posted in blogging, Setup From Scratch | Tagged , , | Comments Off on WordPress from Scratch – part II

WordPress from scratch – part I

To install WordPress to your server the following steps need to be performed.

  • download WordPress
  • unpack WordPress
  • create database for WordPress
  • setup WordPress configuration
  • run install script

One of the preconditions is that either mySQL or MariaDB, PHP and Apache web server are already installed on your server.

From a command prompt

It is possible to go to the WordPress with your browser and download the most current version of WordPress.

https://wordpress.org/download/

This isn’t a bad solution if the computer you are browsing the Internet with also happens to be your web server. A better solution would be to have a dedicated server (or virtual server) and to download the software directly to it.

On linux the wget command can be used to retrieve a file if we know where it is located. Those nice folks at WordPress have made this very easy by always having the most current version available under the name latest.tar.gz or latest.zip.

wget http://wordpress.org/latest.tar.gz

The file can be unpacked with the following command.

tar zxvf latest.tar.gz

This will unzip the file into the wordpress subdirectory in the current working directory.  The zip file should be unpacked into the directory of the web server. On Debian this is /var/www/html.

WordPress will be unpacked into the wordpress directory.  This is fine if you want your blog to be prefixed with wordpress.

http://www.example.com/wordpress

If your intend to only run wordpress, you can move the contents to the root directory.

mv wordpress/* .

WordPress stores users, posts, comments, and links in the database.  It is necessary to create a database, user and grant privileges to the database for the user. In order to do that, you need to log into the database as the owner (root).

mysql -u<root user> -p<root password>
create user 'max'@'localhost' identified by 'supersecret' ;
create database fishwrapper ;
grant all privileges on fishwrapper.* to max@localhost;

Before quitting it is best to switch to the database to verify that it is properly created and then exit mysql.

use fishwrapper;
exit

Before WordPress can be installed the configuration file needs to be properly setup. WordPress provides a sample configuration file called wp-config-sample.php. This file needs to be copied to wp-config.php and then changed to contain the database setup for your environment.

The database name, user and password need to be updated to contain the new user and database information. It is possible to leave the host set to localhost.

define('DB_NAME', 'database_name_here');
define('DB_USER', 'username_here');
define('DB_PASSWORD', 'password_here');
define('DB_HOST', 'localhost');

There is one more little section in this file that contains eight keys which are used for cookies. It is not actually necessary to change these phrases but a good idea.

define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');

Not only is it a good idea, it is super simple to get values for these keys. Simply visit the WordPress link below and it will generate the values which can simply be copied and pasted directly into the configuration file.

https://api.wordpress.org/secret-key/1.1/salt/

The final step is just to run the install script from WordPress. From the web browser, simply run the script.

http://www.example.com/wordpress/wp-admin/install.php

The installation script will only ask for a few pieces of information.

site title
db user
db password
email address
allow search engines to search this site checkbox

This final step takes a couple of seconds.  Once this is done the site is available.

Posted in blogging, Setup From Scratch | Tagged , , | Comments Off on WordPress from scratch – part I

Privacy and legal convenience – the impossible goal

My children are still young so I still have quite some say in how certain things are done.  Sometimes I have to make a tough decision and I really don’t want to look like the bad guy.  When this does happen I have a couple options to prevent this from happening.

  • have mama make the decision
  • a quick bait and switch
  • agree but under impossible conditions

The last one works well, right now but as the children get older their reasoning and logic skills are starting to catch onto this – sure you can go swimming as long as you don’t get wet.

I sometimes think that governments or rather politicians think that they are still dealing with children with limited cognitive skills.  Either that or they don’t have the imagination to see how someone might circumvent their plan.  Granted, I usually think this when they talk about adding “back doors” into hardware or software.

I guess it is just too hard for the law makers to realize that indeed the government will be using those back doors for pretty much the purpose they were created, but it just won’t be our government.  Well, them and a few really tech savvy criminals.

The same seems to be true for encryption.  It is fine as long as some official agency or police group can look at the contents of the communications when they want to.  It is really best if they can somehow “read” the communications without anyone knowing it, but it is ok if in a pinch they have a quick chat with the company hosting the service to get the information.

However, they have a tendency to get really worried when this is no longer possible.   It is correct proper encryption may make their job a lot harder.  They will have to catch the bad guys red handed or it will be hard to produce enough of the circumstantial evidence that paints the picture of their intension.

But these types of intrusive changes are usually not very popular and nobody likes to be criticized. To ensure that is not possible to criticize the change it simply needs to be linked  with something that is impossible to defend – like terrorism.  Nobody would like to advance an argument that appears to be supporting terrorists.

Anyway, it sounds like technology companies may not be able to provide solutions so secure that they even they cannot look at the users data if this new Investigatory Powers Bill is passed.  I guess that Apple won’t be able to sell their iphone with end to end encryption, or it won’t really be end to end.

After all, they don’t need to build in a back door, as long as it is possible to ensure that the communication or data can be looked at when ever they really want to.

 

Posted in Soapbox | Tagged , , | Comments Off on Privacy and legal convenience – the impossible goal

Why I don’t really need a professional lawyer

I receive mail from my parents which can contain anything from comics to Wallstreet Journal articles.  This time, dad included an article titled “Why I’m Not Looking to Hire Computer Science Majors” by Daniel Gelernter in the Wallstreet Journal, I decided that this is a completely fresh way to look at jobs and the job hiring process.

His article can be summarized into a number of valid points.

  1. startups have to compete with well funded established players for people
  2. college programs 10 years behind current state of the art
  3. colleges have no courses on current technology (iphone or android development)
  4. his development staff do not IT degrees, rather degrees in a different fields of study, but still get the job done

Just doing a satirical thought experiment, why don’t we try to start up a new law firm. We don’t have any clients at this point just a mission statement.

Commitment to our client to provide the maximum value to our clients locally, internationally and galactically. Commitment to support our community in providing public service. Commitment to our members by offering career opportunities to help them grow and expand.

It is possible to get some seed capital but we really need to get the law firm running is a partner or two. We have decide to specialize in space law as the earth is a finite size and already has quite a bit of competition and after all space is the next great frontier.

We just recently spoke to a summer intern at a large law firm who was recruited at $10,000 per month. Even a simple first year associate can expect to make $100 thousand per year with a $100 thousand signing bonus and $200 thousand in additional incentives. I have even read a story from one of my law journals about how it was not possible to hire one of the top lawyers from the number one law firm in North America for $500k because he was already earning approximately $3 million a year in cash and other incentives.

Considering the state of the current legal programs, I have decided to no longer look for law school graduates. The schools teach civil procedure, constitutional law, contracts criminal law, property law and torts just to get started. Quite a few example cases discussed are from decades ago. Not a single course on space law, alien culture, alien politics or any cutting edge topics.

This ridiculous situation makes it impossible for me to hire any reasonable candidates to our firm. Based on what I have heard from some of my interviewees, there are two different types of law students. The first are going to law school with the hope of getting a well paying job and the second group are the law nerds. The law nerds go to court in their spare time, talk with attorneys and generally live the law. It is my belief that this second group tend to make the best attorneys because of their dedication and general love of the topic.

To make the process better we are going to hire people with a love of the law, who have developed their skills on their own without any studies of these “sub-standard” law programs that are so common. We have hired a few attorneys and neither of them have an actual law degree. They somehow seem to get the job done.

So, considering this particular situation, there is an opportunity for some up and coming institution to train people directly in space law, alien culture and alien politics. It wouldn’t need to be an accredited four year program, and it would be opportunity to increase the number of qualified space attorneys. This would be perfect for small inter-planetary law startups and would provide some competition to the more traditional trained legal professionals and would help to keep prices down. It would be extremely beneficial for us if such a program would exist, it would ensure that there is a larger pool of candidates for us and we wouldn’t have to pay them as much.  It might even convince the colleges to up their game.

Back in the real world.

Despite everything I have said so far I do personally find that people who have a passion for IT and computers are definitely the best developers.  Why?  Because it isn’t just a job but something they love.  People who love their work will probably pay more attention to the details and may work harder – regardless of the profession.  Passion might not be enough to overcome some of the common issues that have been experienced over the years and because of this is covered in the theory in the general curriculum.

The original articles is behind a paywall.  You may find a summary of it with Google.

Posted in Soapbox | Tagged , , | Comments Off on Why I don’t really need a professional lawyer

It’s scary

pumpkins

Last week I called and woke up my parents.  It seems that I miscalculated the time, I was off by an hour.  I have fallen victim to daylights savings time.

Daylight savings time is the practice of advancing the clock by an hour in the summer to effectively move the extra hour of daylight from the morning to the evening.  I suppose the thought process is that people will not need to turn on the lights so early in the evening and thus save some energy.

It is an interesting thought, but it seems a bit unrealistic that people will be sitting at the kitchen table eating their cheerios in the dark.  If I could set my own schedule I would see the savings due to sleeping in and staying up late, but the corporate world isn’t quite ready for that yet.  There have been some studies into the actual energy savings but the savings seem to be inconclusive.

California Energy Commission resource economist Adrienne Kandel and her colleagues discovered that extending daylight time had little to no effect on energy use in the state. The observed drop in energy use of 0.2 percent fell within the statistical margin of error of 1.5 percent.

I find it to be similar to a protest I once heard take place in Germany.  I cannot remember what the goal was but the people taking part were planning on not putting any gas into their car on a certain day.  This was supposed to be a blow to the energy companies.  My argument at the time to a friend was this was not depriving the energy companies of anything, it was just a slight shift of demand.

I guess I am not a big believer in daylights savings time.  However, I recently read an article that implies that this is a conspiracy of big candy.  Well, daylights savings is not the conspiracy but the extra three week shift to ensure that Halloween has early night darkness.

Candy companies wouldn’t lobby congress to extend daylight savings time by a few weeks for their own personal gain. Would they?

 

Posted in Soapbox | Tagged | Comments Off on It’s scary

pipes and monkey wrenches

Perhaps this should have been titled “backup backup backup“. This is a mantra that is often told but not as often followed and failing to do so can affect anyone.

I was almost ready to go live with my site when I asked for some assistance. A friend of mine who is familiar with the services of my host helped me with some of the friendly tools that were available. I had mistakenly installed my site under the default instance directory.

The tool, Plesk control panel from ODIN. The tool can probably do it all, mail server, firewall, backup, databases and statistics just to mention a few of its capabilities.

Well, it is no fault of the tool that the wielder is having problems with it. I started on the bare metal and once I started to control the environment with Plesk the center of reference moved.

My data was not lost, but the locations for the web pages were moved, and wordpress remembers where it was installed.  A quick query of the wp_posts table shows that the posts are there which was what I was concerned with, yet this table also contains any revisions and indeed just like word processing, it is a good idea to save your work often.

I simply extracted my text which now had pipe symbols at various spots in the articles.

There are some simple things that can be done to prevent reliving this situation.

  • wordpress extraction of data
  • database backups

WordPress provides a pair of scripts designed to extract and import setup.

http::/example.com/wp-admin/export.php
http::/example.com/wp-admin/import.php

The names really do say it all.  Simply point your web browser at your site and you can download the extract directly to your computer.

Database backup tools are more of a personal thing.  Either find a comfortable front end for mysql or do a bit on the command line.  For the moment, I have decided for a small script which will dump the database into a dated file.

#!/bin/bash
DBOWN=myadmin
DBPWD=somepass
DB=mydatabase
mysqldump -u$DBOWN -p$DBPWD $DB > dbdump-`date +%Y%m%d`.sql

A real paranoid sysadmin would not put the password into the file and would be prompted for a password.

#!/bin/bash
DBOWN=myadmin
DB=mydatabase
mysqldump -u$DBOWN -p $DB > dbdump-`date +%Y%m%d`.sql

Posted in blogging | Tagged , , | Comments Off on pipes and monkey wrenches

Forbidden

I actually thought it was quite hilarious to have the web server return Forbidden when accessing the root of the domain of “paranoidprofessor.com” … well during setup. But now that I have entabled the domain it was time to get serious.

I had been fooling around with some code to redrect from the root to the blog and it was working during testing but now that I need it, not so much.

The offending code

<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1;url=http://blog.paranoidprofessor.com/index.php">
<script type="text/javascript">
window.location.href = "http://blog.paranoidprofessor.com/index.php"
</script>
<title>Page Redirection</title>
</head>
<body>
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
If you are not redirected automatically, follow the <a href='http://blog.paranoidprofessor.com/index.php'>link to blog</a>
</body>
</html>

Sure, I did have a few differences between this and my test environment but no matter what I did there was no changes at all.

If all else fails, check the logs. Perhaps that should have been my starting point. The Apache error log file tells you exactly what directory it is looking in when it cannot find a file or has an error.

[Thu Oct 29 09:44:15 2015] [error] [client 79.243.88.206] File does not exist: /var/www/vhosts/paranoidprofessor.com/httpdocs/index.html

 

Thanks to the internet for providing assistance
http://stackoverflow.com/questions/5411538/redirect-from-an-html-page

Posted in blogging | Tagged , | Comments Off on Forbidden

Making wine by blowing glass

If I decided to make wine in the same manner as starting this blog, I would have begun by learning how to blow glass.

My skill set is indeed technical as I am software developer by profession, I have started by investigating the possibilities for the infrastructure. A more reasonable start would have been to start with gathering topics, polishing my writing skills or even speaking with other bloggers. The task was made larger by choosing to host everything myself.

  • blogging software
  • server
  • web server
  • additional tools
  • backup and recovery

Choosing WordPress was pretty easy both due to the cost as well as the maturity and configurability of the product. It was possible to start with WordPress and if for any reason it doesn’t satisfy my needs I can go get something else. Besides, depending on whose statistics you believe at least half the bloggers use that platform.

The server was a no brainer due to using Unix at work and Linux at home. The main reason is because of my familiarity, many useful programs and good scripting solutions. Making these first few choices does limit some of my choices later.

Choosing Linux pretty much eliminates using Internet Information Services (IIS) from Microsoft, which pretty much leaves Apache. Tomcat is also a server but is designed for java servlets, leaving Apache as the web server. This is not a consolation prize. Apache server has been a market leader for years.

The additional tools that come into play is the database required for WordPress. There is no other choice other than MySQL at the moment. This last statement is not entirely true. MariaDB is another database that can be used as it was designed to be a drop-in replacement for MySQL. Other databases may be supported in the future but not at the moment

There are various utilities do exist for backup and recovery of MySQL, however, in my opinion simple command line tools that are bundled with MySQL are the best choice. They also provide the opportunity for scripting and automation.

The trials and tribulations as well as the howto’s will all be explained as things get rolling.

Posted in blogging, Soapbox | Tagged | Comments Off on Making wine by blowing glass

Starting a blog

A computer lets you make more mistakes faster than any invention in
human history — with the possible exceptions of handguns and tequila.

— Mitch Ratcliffe

Lets just hope he is wrong.
— DocDock

Posted in blogging, Soapbox | Tagged , | Comments Off on Starting a blog