Access shared-folder in Ubuntu host from Ubuntu guest in Virtualbox

This is the scenario that you run Ubuntu as your host operating system and Ubuntu guest in VirtualBox, and that you want to access a specific folder from Ubuntu host.

First you have to make sure that have install Guest Additions. From the VirtualBox’s menu go to Devices → Install Guest Additions… This will mount a virtual CD on your /media/cdrom. Normally this folder’s window will show up. As root run the program VBoxLinuxAdditions.run. When the program completes reboot your VirtualBox.

With Guest Additions installed you may now go ahead and define the shared folder(s). From the VirtualBox’s menu go to Devices → Shared Folders. A dialog will show up. In this dialog you can specify which folder from your Ubuntu host system you want to share with your Ubuntu guest. Press the button with the + symbol to add a new shared folder in the list. You will have to specify a Folder Name for each folder you add. Make sure you memorize that name because you will need it very soon.

When done with you shared folder(s) specification, you may now go ahead and actually mount these folders from Ubuntu. First you have to create a mounpoint, that is, a directory in your Ubuntu guest which will reflect the shared folder from Ubuntu host:

# sudo mkdir /media/host-share

Of course you may choose an alternative path for your mountpoint. With your mountpoint created you can now mount the shared folder, like this:

# sudo mount -t vboxsf folder-name /media/host-share

Where folder-name will be the name you assigned for this folder when you were adding it in the shared folders list.

Source

Tagged , , | Leave a comment

A complete invisibility – anonymity – solution for Ubuntu

Based on some online articles and my previous posts, I created the following script which does the following:

  1. Generates and assigns a random MAC address to my wired card (eth0) and wireless card (wlan0) using the macchanger software described here
  2. Generates and assigns a new hostname to my OS
  3. Applies the new changes in my “/etc/hosts” file
  4. Runs on every startup

IMPORTANT: You MUST have your “127.0.0.1” and “127.0.1.1” entries as the last two lines if you need to run this script EXACTLY as it is. If you don’t want this, you can simply change the “sed” part.

Here is the script:

!/bin/bash

#random_computer_name & random MAC address for both eth0 and wlan0

sudo macchanger -A eth0 #random mac for eth0
sudo macchanger -A wlan0 #random mac for wlan0

sed -i 1,10d /etc/hostname

function randnum
{
number=$[ ( $RANDOM % 15 ) + 8 ]
}

randnum

function randpass
{
newhostname=`
}

randpass

(echo ‘0a’; echo $newhostname; echo ‘.’; echo ‘wq’) | ed -s /etc/hostname

/bin/hostname $newhostname

sed -i ‘$d’ /etc/hosts # deletes the last two lines in /etc/hosts
sed -i ‘$d’ /etc/hosts

echo -e “127.0.0.1    $newhostname localhost\n127.0.1.1    $newhostname” >>/etc/hosts

You can add the above file to your startup following the steps in this link

Appreciate any feedback. Note: I’m already working with this script on my laptop and it’s working fine till now, I just had about 10 seconds idle at the startup screen.

Update: That delay happened only after the first startup and then disappeared

Tagged , , , | Leave a comment

Delete the last line in a text file using sed

sed -i ‘$d’ hobba

-i: to change the file itself, not copy contents to another file or something
$d: delete the last line
hobba: the file name

Tagged , | Leave a comment

Insert a "new line" character in a text file using Bash

echo -e “192.168.100.100\n192.168” >> hobba

 The ‘-e’ option does the magic, as it allows escape characters to be printed

Source

Tagged | Leave a comment

How to delete certain lines of text from a file in Bash using sed

“sed -i 1,+2d file_name”

deletes starting from line ‘1’ and the next ‘2’ lines, i.e. deletes the first 3 lines

Tagged , , | Leave a comment