Linux Programmer | RHCE | RHCSA

Search This Blog

Tuesday, 30 October 2018

How to mount USB drives on VirtualBox


Prerequisites
The VirtualBox extension pack must be installed on the VirtualBox host. 

Configuring USB

Follow the steps below to configure VirtualBox USB.






  1. Add user to vboxusers group.
    VirtualBox access to the host's USB drives is only ranted to users of the vboxusers group. As root on the host, run the following command to add each VirtualBox user (e.g., peter) to the group.
     $ usermod -aG vboxusers peter
    
  2. Power off VM.
    VirtualBox defaults to using USB Controller 1.1 (OHCI). Modern hardware uses USB Controller 2.0(EHCI) and USB Controller 3.0(xHCI). Before you can change the USB controller protocol, the virtual machine must be powered off.
  3. Open VirtualBox Manager, click Settings, and select USB.
  4. Specify USB Controller.
    Select either USB 2.0 (EHCI) Controller or USB 3.0 (xHCI) Controlleraccording to your actual hardware.

    Note that you can add USB Device Filters to define the types of USB drives which will be automatically made visible to the guest OS. Be forewarned that the USB drive, once made visible to the guest OS, will no longer be available to the host. More on the use of device filters in the next section.

Accessing USB drive

Below is the step-by-step procedure to mount and access a flash drive.
  1. Insert the flash drive into your host machine's USB port.
  2. Unmount the flash drive (if it is auto-mounted on your host).
    Making it available to the guest will automatically and instantly unmount it from the host. To avoid any data loss due to pending writes to the drive, it is a good practice to explicitly unmount the drive prior to handing control to the guest.
  3. Power on the system as guest.
  4. Assign USB drive to guest OS.

    Open the virtual system console, and right click the USB drive icon.

    Click to select your USB drive.

    Note that this is a 1-time assignment only. Please see instructions at the end of the section on how to automatically assign this particular USB drive for all subsequent sessions.
  5. Login to system, and mount the drive.
    You can mount a MS-DOS based flash drive by running the following commands as root. Replace /dev/da0s1 with the proper device identifier for your USB drive. (You can find out the exact device ID by first running dmesg to identify the device name, e.g. da0, andfdisk to reveal the disk partition structure, e.g., s1.)
     # mkdir -p  /media/usb
     # mount -t msdosfs  /dev/da0s1  /media/usb
    
    To unmount the drive,
     # umount /media/usb
    
To always automatically assign a particular USB drive to the guest OS, open the VirtualBox Manager, click Settings, and then USB.







Finally, click Add USB device filter (with the + sign) icon, and select the USB drive that is currently inserted in the host.

Reset admin password ubuntu

How to reset administrative password in ubuntu

  1. start machine.
    After the BIOS screen appears, press down the left shift key to enter GRUB. This step can be quite finicky, and you may need to repeat it several times until you get the timing just right.
  2. Select the Advance Option for ubuntu
  3. .
  4. In Grub Version list, scroll down to the top Recovery mode line, and press Enter.
    If the Linux kernel image had been upgraded on the machine before, you would see multiple recover mode lines on the screen. Select the recovery mode line that corresponds to the latest Linux image(that is nearest to the top).
  5. In the Recovery Menu screen click on root 'Drop to root shell prompt'.
  6. Press Enter again.
    If you have set root a password, you would be prompted to enter it at this step. Otherwise, just press Enter to continue.
  7. Remount filesystem.
    After all the hard work, you are now at the root shell prompt. The filesystem at this point is read-only. Remount the file system to add write permission.
    $ mount -o rw,remount /
    
  8. Reset admin user password now.
    Use the passwd command to change the password for the admin user.
    $ passwd <username>
    
    Press Control-D to return to the recovery menu.
  9. Click on resume.
  10. Exit recovery.
    Press OK to exit recovery mode and continue booting.
Here you Go.

Password resetted successfully.

Saturday, 11 August 2018

Change the PDF printer Output directory

Since Ubuntu 7.10, a PDF printer has been installed by default. The behavior of this feature has changed from Ubuntu 7.10, instead of asking for a name and location for the PDF, Ubuntu 8.04 will guess a name for the document and place the file in a folder called PDF in your home directory.

  1. Open the file /etc/cups/cups-pdf.conf as the root user:
    gksu gedit /etc/cups/cups-pdf.conf
    
  2. The lines starting with the “#” character are comments. The first un-commented line, which specifies the output directory, should look something like this:
    Out ${HOME}/PDF
    
  3. Change this line to the path you want your PDFs saved to. This will save them to the current users’s desktop:
    Out ${HOME}/Desktop
    
  4. Save and close the text editor. Now you just need to restart CUPS for the change to take effect.
    sudo /etc/init.d/cups restart
    Changing the output directory dosn’t work in some cases because of apparmor
    
    The default (and therefore allowed by apparmor) place for created pdf's is $(HOME)/PDF. If this directory is not used (or is a symlink, just to add this), that means you've changed the default path in cups-pdf.conf, you'll need to apply this changes in the /etc/apparmor.d/usr.sbin.cupsd file too.
    you'll need to change the lines:
     @{HOME}/PDF/ rw,
     @{HOME}/PDF/* rw,
    @{HOME}/PDF/ rw@{HOME}/PDF/*rw,

    into:
    @{HOME}/Desktop/ rw@{HOME}/Desktop/*rw,
    in the mentioned usr.sbin.cupsd file and restart the apparmor-service.

    sudo /etc/init.d/apparmor restartthen restart the cups service,sudo /etc.init.d/cups restart 
     

Tuesday, 31 July 2018

How to handle more than 10 parameters in shell

Use curly braces to set them off:
echo "${10}"
You can also iterate over the positional parameters like this:
for arg
or
for arg in "$@"
or
while (( $# > 0 ))    # or [ $# -gt 0 ]
do
    echo "$1"
    shift
done

M3 Button not working in Wayland

Mouse M3 button not working in wayland - ubuntu 26.04 1. Check your desktop Run: echo $XDG_SESSION_TYPE echo $XDG_CURRENT_DESKTOP 2. If...