Linux tips and tricks

How do I change the hostname of my RPi?

You need to do 3 things:

  1. sudo nano vi /etc/hostname. You’ll find the existing hostname in this file. Update the hostname as desitred, then save and exit.
  2. sudo nano /etc/hosts. Look for any occurrence of the old hostname in here. Update them, then save and exit.
  3. sudo reboot

This technique is derived from the website of Simon the Pi Man.


Changing the root of WordPress website

When I first installed WordPress natively, my home page appeared at http://[website name]/wordpress.  I wanted it to be at http://[website name].

Here’s what I had to do to fix it:

root@n36l:/opt/wordpress-4.5.1-0/apps/wordpress# ./bnconfig --appurl /
root@n36l:/opt/wordpress-4.5.1-0/apps/wordpress# ./bnconfig --disable_banner 1
root@n36l:/opt/wordpress-4.5.1-0# /opt/wordpress-4.5.1-0/ctlscript.sh restart apache
Syntax OK
/opt/wordpress-4.5.1-0/apache2/scripts/ctl.sh : httpd stopped
Syntax OK
/opt/wordpress-4.5.1-0/apache2/scripts/ctl.sh : httpd started at port 80
root@n36l:/opt/wordpress-4.5.1-0#

Restarting my native install of Bitnami WordPress

To restart the entire stack:

malcolm@n36l:~$ sudo -s
[sudo] password for malcolm:
root@n36l:~# cd /opt/wordpress-4.5.1-0/
root@n36l:/opt/wordpress-4.5.1-0# ./ctlscript.sh restart
Syntax OK
/opt/wordpress-4.5.1-0/apache2/scripts/ctl.sh : httpd stopped
/opt/wordpress-4.5.1-0/mysql/scripts/ctl.sh : mysql stopped
2016-05-08T23:05:00.445332Z mysqld_safe Logging to '/opt/wordpress-4.5.1-0/mysql/data/mysqld.log'.
2016-05-08T23:05:00.530074Z mysqld_safe Starting mysqld.bin daemon with databases from /opt/wordpress-4.5.1-0/mysql/data
/opt/wordpress-4.5.1-0/mysql/scripts/ctl.sh : mysql  started at port 3306
Syntax OK
/opt/wordpress-4.5.1-0/apache2/scripts/ctl.sh : httpd started at port 80
root@n36l:/opt/wordpress-4.5.1-0#

Finding and searching files

To find files in the entire filesystem:

malcolm@n36l:~$ locate -i process.txt

To find text in files in the current directory recursively:

malcolm@n36l:~$ grep -Iri 'mscp'

(I = ignore binary files, r = recursive search, i = case insensitive)

Setting up a shared folder for Ubuntu under VirtualBox

On my X1 Carbon I am running Ubuntu 14.04 Desktop 32-Bit under VirtualBox.

I wanted to re-establish a shared folder (on the host machine) that can be accessed from within Ubuntu. I did have this working on my HP8440 (where I first created this VirtualBox .VDI file), but since I’ve created the new virtual machine on the X1 Carbon, I need to re-establish the shared folder.

I am using this webpage for guidance -> How to Access Folders on Your Host Machine from an Ubuntu Virtual Machine in VirtualBox

I know that my Ubuntu image already has “VirtualBox Guest Additions” loaded, as I received a message inviting me to update it, which I didn’t do.

The process is as follows:

  • Shutdown the virtual machine.
  • In Virtual Box, with your Guest virtual machines selected in the left panel, click on “Settings” for your virtual machine.
  • Select “Shared Folders” in the left panel.
  • In the right margin, click on “+” to add a shared folder.
  • In the dialogue box that appears:
    • In “Folder Path”, navigate to the name of the folder of the host machine that you want to share
    • The “Folder Name” box will auto-populate with the lowest-level directory that appears in the Folder Path box. No need to change this
    • Tick the “Auto-mount” check box
  • Click “OK” to close the Shared Folders dialogue box.
  • Start your Guest Machine.
  • Look at the /media directory (ie “ls -l /media”). You should see a directory there that starts with “sf_” with the Folder Name from above at the end *eg “sf_ubuntu_shared_folder”). Try to access it. You probably won’t be able to, because you need to deal with a permissions issue. You can see from the “ls -l” command that the group name for this folder is “vboxsf. You need to add your username to that group.
  • You can check which groups you are a member of by using the command “id [username]”.
  • To add yourself to the vboxsf group, use the command “sudo adduser [username] vboxsf”.
  • You should now be able to access (from inside the Guest Machine) the files in your shared folder (which is on the Host Machine).

Changing Ubuntu 14.04 to console login

I used this technique to modify Ubuntu (running under VirtualBox on my X1 Carbon laptop).

The technique worked fine, but what I didn’t count on is that it stops xterm from being able to startup, and so breaks the integration between SIMH and SerialDisk.