Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Saturday, June 15, 2013

shared folder between virtualbox and host

1. Create a folder on host like this:
    F:\Shared
2.On VirtualBox Manager:
   Settings-Shared Folders-Add shared folder
   Folder Path: select the one you create above
   Folder Name: use the default one
   tick "Auto-mount"  and "Make permanent" and then save it.
3.Open terminal on Ubuntu on VirtualBox:
   sudo mount -t vboxsf Shared zhiguang/Win_Lin/
   # zhiguang/Win_Lin/ is the corresponding folder for Shared, you should create it before running this command

   then once you put files in  F:\Shared, you can share and edit them in zhiguang/Win_Lin/ immediately.
  

"The system is running in low-graphics mode" for Ubuntu on VM VirtualBox

When I installed Ubuntu Desktop 12.04 LTS into VirtualBox, it prompts "The system is running in low-graphics mode". I tried 6 soutions which solved the problem for other people but not me. Although I do not the exactly intrinsic reason, the following command finally served me well:

sudo apt-get update
sudo apt-get upgrade
sudo reboot
I hope it can also help you.

Tuesday, June 11, 2013

Full screen for ubuntu on VM VirtualBox

I have VM VirtualBox on Win 7, and Ubuntu on VM VirtualBox. By default, the ubuntu could not be displayed as fullscreen. But there is way to make it seem as the ubuntu os is directly installed on your PC hardisk.

1. Installing Guest Additions for full screen

   [Device]--->[Install Guest Addtions]

2. After some configure by the machine, you can open the Guest Additions folder which should be on your Desktop in Ubuntu with name like this: VBOXADDITIONS_#

3. Open terminal, and cd into this folder VBOXADDITIONS_# by:

cd  /media
cd  VBOXADDITIONS_#
sudo sh VboxLinuxAdditions.run

4. Restart the ubuntu.
you can see the ubuntu is enlarged filling up the whole VirtualBox. However the VirtualBox window frame still exists, you can implement the real full screen by HOST+F,  which would make  the VirtualBox window frame  disappear. Another  HOST+F will bring the window frame back again. By default in Ubuntu, the HOST key is the Right Ctrl

Thursday, April 4, 2013

tranverse files under one directory using C++ on ubuntu

#include <string>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include </usr/include/i386-linux-gnu/sys/types.h>
#include </usr/include/i386-linux-gnu/sys/stat.h>
#include <dirent.h>
#include <errno.h>
using namespace std;
int main(void)
{
   DIR *dp;
   int n=0;
   int len=0;
   struct dirent *dirp;
   string str0;
   dp=opendir("/home/HSS/topic_modeling/topic_1/");

   while((dirp=readdir(dp))!=NULL)
   {  
      str0=string(dirp->d_name);
      len=str0.size();
      if( len>4)
// for txt files and this will filter out the '.' and '..' file
      {
            // do what you want to do !
      }
   }
return 0;
}

using filezilla for amazon ubuntu server

when you create ubuntu instance on amazon ec2, you will get user name(say, root or ec2-user) and one .pem file
then in your local ubuntu, you can access the server by:
chmod 400 xxx.pem    #make this file publicly visible
ssh -i xxx.pem ec2-user@xxx.xxx.xxx.xxx
# xxx.xxx.xxx.xxx  is the ip address amazon assigned to you
thus you can access the ubuntu server on amazon.
however, for transfering files between local machine and server, we usually use filezilla.
the default internet access directory is  /var/www/html  however, the general user do not have rights to upload files directly to this folder, so we can:
sudo chmod 777  /var/www/html 
thus we can use filezilla to transfer files directly to that folder.
after installing filezilla, we should configure first:
1)open the site manager->new site. then we name it as something you like, and for host, input the ip address, for port:input 22, for protocol: choose SFTP-SSH file...    for logon type: normal   for user: input your user name
2)edit-> settings->connection->SFTP, press: add keyfile. thus select your pem file, and  will convert it to ppk file.
after that, back to step 1), press "connect", then your local machine would connect to your amazon ubuntu server. You can now use mouse to drag files from your local machine to the server and vice versa.

Thursday, February 28, 2013

Using php to send mail on apache (ubuntu)

I have an Ubuntu in Oracle VM VirtualBox, however i did not set it as a server, I just want to implement  sending  email on ubuntu.
Make it short:using sendmail.
installing sendmail on ubuntu


in the file:  /etc/php5/apache2/php.ini
make it like this:  sendmail_path = /usr/sbin/sendmail -t -i
sudo apt-get install sendmail
sudo apt-get install sendmail-cf

then we can use the following code to send mail:






this is only a test, you can change the code according to your demand.
done!