Author Archives: Berend de Jong

Install sublime text 2 package control

Install sublime text 2 package control to easily download and install plugins for the sublime text editor. First open up the console window: view -> show console.

Then past the following command into the console and press enter:

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')

For Sublime Text 3

import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())

 

 

Restart sublime and show the command pallet with Ctrl+ Shift + P. Type “package contol” and select “install package”. A list of installable packages will show up. Choose your packages for installation.

If you are behind a proxy you should add it to your Sublime settings. Goto Preferences -> Settings User and add the following line (add a ‘,’ to the line above if needed):

"http_proxy": "http://username:password@your.proxy.tld:port"
Share

tar and untar

Create archive

  • -z: Compress archive using gzip program
  • -c: Create archive
  • -v: Verbose i.e display progress while creating archive
  • -f: Archive File name
tar -zcvf archive.tar.gz /home/dir_to_archive

 

Untar archive

  • -x: Extract files
tar -zxvf archive.tar.gz

 

List content of archive

tar -tvf file.tar

 

Share

mount webdav folder

To mount a webdav folder (for example your box.com drive) use the following command:
mount -tdavfs https://www.box.com/dav/ /mnt/box/
Type username and password when asked and voila; your box.com drive is available!

You could also add your username and password to the /etc/davfs2/secrets file and they
will be used by the mount command.

Share

perl locale warning

When execute, for example, the perl command the message below could be shown:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_PAPER = "nl_NL.UTF-8",
LC_ADDRESS = "nl_NL.UTF-8",
LC_MONETARY = "nl_NL.UTF-8",
LC_NUMERIC = "nl_NL.UTF-8",
LC_TELEPHONE = "nl_NL.UTF-8",
LC_IDENTIFICATION = "nl_NL.UTF-8",
LC_MEASUREMENT = "nl_NL.UTF-8",
LC_TIME = "nl_NL.UTF-8",
LC_NAME = "nl_NL.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

To get rid of this message compile the language locale as shown at “LC_NAME=” text. Compile the nl_NL.UTF-8 locale:

If the message persists check that all locale related environment variables have a valid value (ie they are not (unset)).

Valid values for example:
LANGUAGE="en_US:en"
LC_ALL="en_US.UTF-8"
LANG="en_US.UTF-8"

locale-gen nl_NL.UTF-8

perl

Share

Ubuntu Apache + MySQL + WordPress

Install devenv with Ubuntu + Apache + MySQL

Create a new virtual machine and mount your Ubuntu ISO as CDROM drive. Startup the new virtual machine and install Ubuntu with default options.

After Ubuntu installation is complete be sure to add the guest additions to your system (keep your original configuration when asked):

$>apt-get install virtualbox-guest-x11

Ubuntu windows appearing slow? See this url: http://askubuntu.com/questions/207813/why-does-an-ubuntu-12-10-guest-in-virtualbox-run-very-very-slowly/214968#214968

Upgrade and update your system to make sure you have the latest and the greatest software:

$>apt-get update
$>apt-get upgrade

Mandatory components for your development environment

$>apt-get install apache2
$>apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
# Enter root password and press OK (twice)
# Install MySQL system tables:
$>mysql_install_db
# Secure your MySQL installation
$>/usr/bin/mysql_secure_installation
# Enter the root password choosen above
# Choose n (already have a password)
# Enter four times (everything default)
$>apt-get install php5 php5-xdebug libapache2-mod-php5 php5-mcrypt php5-cli php5-curl php5-gd
# Install your favorite editor for quick edits....
$>apt-get install vim

Optional (but useful tools)

WebMin server administration

apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.610_all.deb
dpkg --install webmin_1.610_all.deb

When you want to mount an external CIFS filesystem (for example your NAS) install the CIFS utility package.

$>apt-get install cifs-utils

Mount a cifs remote file system:

$>mkdir /mnt/share
$>mount.cifs //SERVER/share /mnt/share -o user=USER,uid=1000,gid=1000
# Enter your password
# Install netbeans
$>apt-get install netbeans
# Install chromium-browser
Install chrome browser
$>apt-get install chromium-browser
# Install the Gimp
$>sudo apt-get install gimp
# Install VIM
$>sudo apt-get install vim

Setup WordPress installatie

For pretty URL’s to work make sure the rewrite module is enabled in Apache. You can do this with the WebMin tool; in Webmin goto “Servers”, “Apache Webserver”, select the “Global configuration” tab, select “Configure Apache modules”, check the “Rewrite” module.

Changes take effect immediately.

$>cd /var/www/
$>mkdir demo
$>cd demo
$>wget http://wordpress.org/latest.tar.gz
$>tar -xzvf latest.tar.gz
$>mv wordpress www
$>rm latest.tar.gz
$>cd /var/www
$>chown -R www-data:www-data .

Setup the MySQL database

$>mysql -uroot -pXXXXXXX
mysql>create database wp_demo;
mysql>create user 'wp_demo'@'localhost' IDENTIFIED BY 'XXXXXXXXXX';
mysql> grant create,drop,select,insert,update,delete on wp_demo.* to 'wp_demo'@'localhost';
Share

SSH OpenSSH Keys

Generating RSA Keys
The first step involves creating a set of RSA keys for use in authentication.
This should be done on the client.
To create your public and private SSH keys on the command-line:

mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa

Default the private key is stored in a file called id_rsa  and the public key is stored in a file called id_rsa.pub . It is the pub key that you send to other servers!

Transfer Client public key to Host
The key you need to transfer to the host is the public one. If you can log in to a computer over SSH using a password, you can transfer your RSA key by doing the following from your own computer:

ssh-copy-id <username>@<host>

Log in to your host
Log in to your host as usual; you should be prompted for your passphrase. After that the next connection will be made based on your private key.

If the host is configure to only use public key authentication then you have to disable this for a while (or copy the key via another account to the server).

To temporarily disable public key authentication edit your /etc/ssh/sshd_config  file and set the value for passwordauthentication  to yes .

Execute the ssh-copy-id and reset the passwordauthentication value in your sshd_config.

Troubleshooting

When no connection could be made check the ssh log at

/var/log/auth.log

When you encounter something like

Authentication refused: bad ownership or modes for directory /root

Try changing your home folder permissions:

chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Share

Generate password with bash

You can use the following shell function to generate random password.

Edit ~/.bashrc file, enter:

genpasswd() {
	local l=$1
       	[ "$l" == "" ] && l=16
      	tr -dc A-Za-z0-9_ &lt; /dev/urandom | head -c ${l} | xargs
}

Save and close the file. Source ~/.bashrc again, enter:

$ source ~/.bashrc

To generate random password, enter:

$ genpasswd

To generate 8 character long random password, enter:

$ genpasswd 8
Share

Enable proxy for apt-get on Ubuntu

When you are behind a proxy server on your ubuntu machine you have to edit (or create) your apt.conf to define the proxy settings:

Create (or edit) an apt.conf  file at /etc/apt/apt.conf
Add the following line to this file:

Acquire::http::Proxy “http://username:password@proxyhost:port/”;

If you have any special characters in your password you have to use the URL encoding syntax. For example a ! translates to %21.

The next time you use apt-get the proxy settings will be used.

Share