`pwd’: No such file or directory – getcwd (Errno::ENOENT)

When you rename a subdirectory under the directory where your Linux or MacOS terminal is open you may get the error message

/opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/cookbook_download.rb:45:in `pwd’: No such file or directory – getcwd (Errno::ENOENT)

You need to refresh the directory cache of the terminal.

  1. Go one level higher
    cd ..
  2. Go back to the directory


Migrate a WordPress web site to DreamHost

DreamHost is one of the recommended WordPress hosting providers. The DreamHost website has an extensive knowledge base, but the necessary steps to move your live site from another provider are scattered over multiple pages at https://help.dreamhost.com/hc/en-us/articles/214693178-How-to-manually-migrate-WordPress-to-DreamHost.

These steps will guide you through the streamlined migration process.

At your old provider

Create a site and database backup of your site at the old provider and save them on your workstation.

At DreamHost

Create an account at DreamHost.

If you arrive at the DreamHost site from https://www.cnet.com/web-hosting/ you get 50% discount on your initial hosting plan terms. The price will increase to the regular amount when you renew your hosting contract after 1 or 3 years.

It can take DreamHost an hour to activate your account. You can log into the control panel, but you have to wait for the account activation to be able to set up your site.

Create a fully hosted site

  1. In the DreamHost Panel select DOMAINS, Manage Domains and click the Add hosting to a Domain / Sub-Domain button
  2. Enter the name of your domain, select Remove WWW:… , and make a note of the Web username and Web server name.  When you will upload the site, make sure you use the newly created Web username and Web server (+.dreamhost.com) with the SFTP protocol. (FTP will be disabled for that user). When you save your changes, the new username and password will display on the screen. Click the Fully host this domain button.

  3. DreamHost creates a directory for the new user in the home directory on the web server and a subdirectory for the website.

Temporary domain name

If you want to keep your existing domain name at the original location until the new site goes live at DreamHost,  create a free temporary subdomain, MYDOMAIN.dreamhosters.com

  1. Return to the Manage Domains page and click the Add Hosting to a Domain / Sub-Domain button again,
  2. Scroll down to the Mirrored section. Enter a sub-domain name using dreamhosters.com, select your site from the drop-down, and click the Mirror this domain button.
  3. Open a web browser and navigate to MYDOMAIN.dreamhosters.com. You should see this page:

Create a MySQL database

  1. On the left side select GOODIES and MySQL Databases
  2. If you use the temporary domain name, you need to use it for the database hostname too. If you move an existing WordPress site, for the easier configuration, you can keep the same database name, username, and password that you had at the old site.
  3. Update the wp-config.php file on your workstation with the new values. Even if you keep the database name, username, and password values, the DB_HOST will be different, because the site is now at a different provider.
    define('DB_HOST', 'mysql.MY_DOMAIN_NAME.dreamhosters.com');

Import data into your database

  1. On the left side select GOODIES, MySQL Databases, and in the middle select phpMyAdmin next to the database name
  2. Make sure the SQL script on your workstation starts with the database selection command. If the instruction is missing, add the line:

    For some reason, the MySQL Workbench cannot interpret the encoding of the SQL file, use a better text editor to edit the file, otherwise international characters in the data will be corrupted.

    The Microsoft SQL Server Management Studio is perfect for this purpose.

  3. On the Import tab click the Choose File button to select the database backup SQL file on your workstation and click the Go button

Update the site URL in the database to match the temporary website address

On the phpMyAdmin web page

  1. Select the Browse tab, on the left side select your WordPress database, and in the database click the wp_options table.
  2. Click the Edit link in the siteurl row. This will automatically open the Insert tab,
  3. Update the siteurl value in the wp_options table and click the Go button,

Upload the WordPress site files to the new web server

Use an FTP client to upload the files to the site. The site host user only has SFTP rights, so make sure you configure your FTP client accordingly. Use the web address, username, and password that you used, when you set up the fully hosted website above.

To rebalance the load between their web servers, DreamHost time-to-time moves websites from one server to the other. Use the subdomain we created above, to access the FTP directory, as it will always point to the correct web server.

  1. If you use FileZilla, create a new site for the web user, and select the SFTP protocol,
  2. Make sure you update the wp-config.php file with the new database connection values, and upload it to DreamHost,

Test your new site

The home page of the new site should be accessible at the MYDOMAIN.dreamhosters.com address we created above.

When you click on any of the post titles, you may get the following error message

Not Found

The requested URL /archives/… was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Update the permalinks

The WordPress database still contains the absolute locations of your HTML files and images. To refresh the permalinks of your site

  1. Log into your WordPress site,
  2. On the left side select Settings, Permalinks, and click the Save Changes button.
  3. After a few seconds the site should start to work.

Point your domain name to the new site

When you have successfully tested your new site, you can point your domain name to the DreamHost webserver. The DreamHost knowledge base will help you at https://help.dreamhost.com/hc/en-us/articles/215412347-Updating-your-DNS-after-your-WordPress-site-has-been-migrated-to-DreamHost

IMPORTANT: If you use your domain name to connect to Office 365 or other services, do not switch to the DreamHost name servers. Use “Option #2 — Pointing your A records” on the DreamHost knowledge base page above, to set the IP address of your website in the DNS record.

Configure WordPress to use the final domain name

To be able to test our site with the temporary subdomain we have updated the database. Now it is time to change the value back.

  1. Open the MySQL management utility
  2. Select the Browse tab, on the left side select your WordPress database, and in the database click the wp_options table.
  3. Click the Edit link in the siteurl row. This will automatically open the Insert tab,
  4. Update the siteurl value in the wp_options table and click the Go button,

Test your site with your domain name

The home page of your WordPress site should load without error. If you get the error again:

Not Found

The requested URL /archives/… was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Update the permalinks again. See Update permalinks above

Ubuntu gets stuck in a login loop

When I rebooted my Ubuntu machine it started to repeatedly ask for the password.

When I entered the correct password, the screen went black and asked for the password again.

The problem was an error in the ~/.profile file.

To log into the Ubuntu terminal

  1. Press the Ctrl-Alt-F3 key combination
  2. Enter the username
  3. Enter the password
  4. Open the ~/.profile file with
    /bin/nano ~/.profile

Make sure the

  • The syntax is correct, all open braces are closed,
  • All PATH= statements have :$PATH at the end.

DevOps Engineering part 1. (Ubuntu) – Install the DevOps development tools on Ubuntu

DevOps Software installation on Ubuntu

There are multiple ways to install software on Ubuntu

  • Install a .deb package from the local drive with dpkg
  • Install the software from the internet with apt

Show hidden files

To be able to see hidden files in Files

  1. Start Files,
  2. In the Edit menu select Preferences,
  3. On the Views tab check the Show hidden and backup files,
  4. There is no Save or Ok button, just close the window to save the changes.

Text Editor


  1. Download the .deb installer from https://atom.io/
  2. Start the terminal by pressing CTRL-ALT-T
  3. Navigate to the Downloads directory
    cd ~/Downloads
  4. Install Atom
    sudo dpkg -i atom-amd64.deb
  5. Add an icon to the desktop
    1. Install the Gnome Panel, but do not install the unnecessary packages
      sudo apt-get install --no-install-recommends gnome-panel
    2. If the message is

      You might want to run ‘apt-get -f install’ to correct these:The following packages have unmet dependencies:…

      1. Execute
        apt-get -f install
    3. Create a new launcher on the desktop
      gnome-desktop-item-edit --create-new ~/Desktop
    4. Enter a name and command for the shortcut,
    5. To select an icon, click the image in the upper left corner and select an icon, and click Open,
    6. Unfortunately, Ubuntu does NOT update the icon in the window, click OK to save the shortcut.

To configure Atom see Atom text editor configuration

The preferences menu item in Linux is in the Edit menu of Atom.



  1. Open the Terminal window
  2. Execute
    sudo apt-get install git

Configure Git

To configure Git see Git configuration.

Chef Development Kit

  1. Download the Chef Development Kit from https://downloads.chef.io/chef-dk/
  2. Click the Download button next to your Ubuntu version, and select Save File,
  3. Start the terminal by pressing CTRL-ALT-T
  4. Navigate to the Downloads directory
    cd ~/Downloads
  5. Install the Chef DK. Set the name of the file below for the actual version.
    sudo dpkg -i chefdk_CHEF_DK_VERSION-1_amd64.deb



The default credentials of a Vagrant server are:

  • UserName: vagrant
  • Password: vagrant

Terraform by Hashicorp

 Terraform Installation

  1. Download Terraform from https://www.terraform.io/downloads.html
  2. Click the Linux 64-bit link, and select Save File,
  3. Open the Downloads folder in Files,
  4. Right-click the downloaded ZIP file and select Extract Here to extract the application
  5. Create a version specific directory, terraform_x.x.x for the Terraform application in the /opt/terraform folder
  6. Move the Terraform application into the version specific directory

Add Terraform to the path

  1. In the terminal window execute
    gedit ~/.profile
  2. Add this line to the end of the file


The Amazon Web Services command line interface installation will set up your workstation to launch instances in AWS from Test Kitchen. If you know you will work with AWS, see DevOps Engineering part 3. – Working with AWS for the AWS CLI installation.


We use Packer to create custom AWS AMIs that contain the fundamental configuration and applications that are common in every instance we launch.

Install Packer

  • Add the Packer installation directory to the system path

Configure the Ubuntu virtual machine in VirtualBox

Enable shared folders on the virtual machines

To be able to use shared folders between the host ( your workstation ) and the virtual machine.

  • Start the Ubuntu virtual machine in Virtual Box,
  • Select the virtual machine window on your workstation,
  • In the Devices menu of Virtual Box select Insert Guest Additions CD image…
  • Click the Run button,
  • Enter your admin password and click Authenticate,
  • Select the terminal window and press Enter,

  • Restart the virtual machine for the change to take effect,
  • In Ubuntu
    1. Open a terminal window,
    2. In the upper left corner of the desktop click the Search icon,
    3. Type terminal into the search box,
    4. Select the Terminal icon.
  • In the Terminal window create a directory for the mount point
    mkdir ~/host-share
    sudo chmod 777 ~/host-share
  • Mount the Shared Windows location. Get the Machine Folder name from the virtual machine’s Shared Folders tab in VirtualBox

    (If you shared the root of a Windows C: drive, the name is “C_DRIVE”.)

    sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) MY_MACHINE_FOLDER_NAME ~/host-share

Source: https://help.ubuntu.com/community/VirtualBox/SharedFolders

Make the mounting permanent

  1. Create the folder /opt/scripts
  2. Create a new file in the new folder mount_host_share
    # Mount the Host Share to see the host computer's file system
    echo MY_PASSWORD | sudo -S mount -t vboxsf -o uid=1000,gid=1000 MY_MACHINE_FOLDER_NAME ~/host-share
  3. Make the file executable
    chmod +x /opt/scripts/mount_host_share
  4. On the Ubuntu desktop click the Search icon and type startup, and click the Startup Applications icon
  5. On the Startup Applications Preferences window click Add,
  6. Enter the Name and this Command, and click Save

The shared drive appears in the File manager.

Relax the password requirement

The virtual machine is already protected by the operating system of the host, your workstation, so it is not necessary to enter the password every time you want to switch to the guest machine. To remove the password requirement

  1. Click the System Settings icon in the sidebar,
  2. Uncheck the Waking from suspend and Returning from blank screen checkboxes.

Configure the Windows virtual machine in VirtualBox

Enable shared folders on the virtual machine

To be able to use shared folders between the host ( your workstation ) and the Windows virtual machine.

  • Start the Windows virtual machine in VirtualBox,
  • Select the virtual machine window on your workstation,
  • In the Devices menu of VirtualBox select Insert Guest Additions CD image…
  • In the virtual machine start Windows Explorer,
  • Open the VirtualBox Guest Additions CD,
  • Start VBoxWindowsAdditions.exe,

The shared folders will be available in the virtual machine’s Windows Explorer as the D: drive

VirtualBox installation and configuration on Windows

Download Virtual Box from https://www.virtualbox.org/wiki/Downloads and follow the instructions to install it.

At the time of writing this was the section where the installer files were referenced


Run the downloaded installer file and accept all default values.

The installer starts the Virtual Box application.You can close it, we will use other tools to start it in the future.

To be able to launch 64-bit guest operating systems turn off Hyper-V in Windows Features

  1. In the Windows search box enter Windows Features and select Turn Windows Features on or off,
  2. Uncheck Hyper-V and click OK,
  3. Reboot the computer for the setting to take effect.

Create a virtual machine

To create a new virtual machine

Download the  OS image from the manufacturer’s web site.

  1. Start the VirtualBox application
  2. Click the New icon
  3. Enter a name, select the operating system type and version, and set the memory size,
  4. Set the initial size of the virtual hard disk
  5. Select the virtual machine icon and click the Start button,
  6. Click the Browse icon and select the OS image file in the Downloads directory,
  7. Click the Start button

Configure VirtualBox for each virtual machine


To share the connectivity of the host computer with the virtual machine, mainly if you use VPN

  1. In Virtual box click Settings
  2. Select Network
  3. Attach the network adapter to NAT

Copy and paste

To enable copy and paste between the virtual machine and the host ( your workstation )

  1. On the General tab of the Settings page select the Bidirectional shared clipboard

Shared Folders

Specify the shared folder on your workstation

  1. In the VirtualBox menu select Preferences
  2. On the Shared Folders tab click the + icon
  3. To share the entire system drive, select the C: drive of your workstation

Configure the virtual machine OS

To configure the virtual machine operating system in VirtualBox, see Virtual machine configuration on the VirtualBox page.

Create the AWS credentials file from a Chef Data Bag

When a process on a server instance needs access to an AWS account, the user who will execute the AWS CLI commands needs to be able to automatically authenticate in AWS.

For automatic AWS authentication, the AWS CLI creates two files in the .aws directory:

  • config and
  • credentials.

The location of this directory depends on the operating system and the type of user.

  • On Linux, the location is ~/.aws ( the user’s home directory )
  • On Windows, it is located at C:\Users\USER_NAME\.aws
  • On Windows, if the file was created by SYSTEM, the location is C:\Windows\System32\config\systemprofile\.aws

Store the AWS key values

To create these files, you need to store the AWS Access Key and Secret Key. The safest place for these values is an encrypted data bag. To automatically generate the AWS files, create a data bag file and name it the same as the “id” in the following structure:

  "MY_PROFiLE_1": {
    "region": "MY_REGION_1",
    "aws_access_key_id": "MY_ACCESSKEY_1",
    "aws_secret_access_key": "MY_SECRET_KEY_1"
  "MY_PROFiLE_2": {
    "region": "MY_REGION_2",
    "aws_access_key_id": "MY_ACCESSKEY_2",
    "aws_secret_access_key": "MY_SECRET_KEY_2"

To create and encrypt the data bag see my post on Chef Data Bags

Create the AWS authentication files

  1. In your Chef recipe, first install the AWS CLI and reboot the server, so the new path entry will be available for the Chef process.
  2. The following Chef code will create the AWS config and credential files. The script
    1. opens and decrypts the data bag,
    2. loads it into a hash table,
    3. iterates through the hash items,
    4. skips the “id” item,
    5. stores the AWS key values in a temporary file,
    6. executes the “aws configure” command to generate the AWS config and credential files.
  # Iterate through the data bag and create the credentials file

  puts "***** Creating the AWS credentials file"

  # Load the encrypted data bag into a hash
  aws_credentials = Chef::EncryptedDataBagItem.load('MY_DATA_BAG_NAME', 'MY_DATA_BAG_ITEM_NAME').to_hash

  # Iterate through the items, skip the "id"
  aws_credentials.each_pair do |key, value|

    # skip the "id"
    next if key == "id"

    # Add the credentials to the .aws/credentials file
    puts "Account #{key}, Region #{value['region']}"

    batch "add_aws_credentials_#{key}" do
      code <<-EOF echo #{value["aws_access_key_id"]}> input.txt
        echo #{value["aws_secret_access_key"]}>> input.txt
        echo #{value["region"]}>> input.txt
        echo.>> input.txt
        aws configure --profile #{key} < input.txt



Bootstrap Chef nodes to connect them to the Chef server

A Chef node is a physical or virtual machine with an operating system that is connected to the Chef server. Once the node has made the connection to the Chef server, the installed Chef Client can execute Chef cookbooks to configure the machine.

Bootstrapping is the process to connect the node the first time to the Chef server, or to attach it again if the node lost the connectivity to the Chef server. To be able to bootstrap a node, your workstation needs to have the Chef Development Kit installed. The kit includes the ‘knife’ command that communicates with the Chef server. Your workstation also has to be able to connect to the Chef server with the YOUR_USERNAME.pem file you store in the .chef directory just above your cookbooks.

Bootstrap a Linux node

To bootstrap a Linux node, open a terminal window on your workstation and execute the command:

knife bootstrap MY_NODE_IP -x MY_USERNAME -P MY_PASSWORD --sudo --node-name THE_NODE_NAME --environment THE_ENVIRONMENT --run-list 'recipe[MY_COOKBOOK1::default],recipe[MY_COOKBOOK2::default]'

Bootstrap a Windows node

knife bootstrap windows winrm MY_NODE_IP -x MY_USERNAME -P MY_PASSWORD --node-name THE_NODE_NAME --environment THE_ENVIRONMENT --run-list 'recipe[MY_COOKBOOK1::default],recipe[MY_COOKBOOK2::default]' -V


  • MY_NODE_IP is the IP address of the node you want to attach to the Chef server,
  • MY_USERNAME and MY_PASSWORD are the credentials to connect to the node.
    If the Windows server is in the Windows domain start the username with the domain name MY_DOMAIN\\MY_USERNAME
    If the Windows server is not in the domain start the username with the IP address MY_NODE_IP\\MY_USERNAME
  • THE_NODE_NAME is the unique name you want the node to use in the Chef server database. If you are bootstrapping a server that lost connectivity to the Chef server or moving the node to another Chef server, find the node name in the node list.
  • THE_ENVIRONMENT is the name of the environment the node will run the cookbook in,
  • The run list is a list of cookbooks and roles. No spaces are allowed in the string.