Sunday, January 19, 2014

mono: Running C#, ASP.NET under Ubuntu

Mono is not monotone at all, it makes Microsoft-centered technologies available on various platforms including Ubuntu. Mine is 12.04.

sudo apt-get install mono-devel mono-gmcs gtk-sharp2 

Compile and execute

Fetch the example files at Console helloword program

gmcs hello.cs
mono hello.exe

Compile and execute gtk program

Source Here

dmcs hello-gtk.cs -pkg:gtk-sharp-2.0
mono hello-gtk.exe

Install ASP server xsp2 and start server

sudo apt-get install mono-xsp2 asp.net-examples
xsp2

When server is on, it gives

Listening on address: 0.0.0.0
Root directory: /home/user
Listening on port: 8080 (non-secure)
Hit Return to stop the server.

Now you can visit your .aspx files under http://localhost:8080/yourfile.aspx

Monday, January 6, 2014

Update to Banshee 2.6

sudo add-apt-repository ppa:banshee-team/ppa
sudo apt-get update
sudo apt-get install banshee

Friday, January 3, 2014

Ubuntu: Burn Fedora ISO to USB Stick

For a complete burning techniques, refer Fedora: How to Create and Use Live USB

Startup disk creator only works for Ubuntu ISOs.

Use Disk Utility to get know of where your usb is mounted. In my case, it is /dev/sdc, and the name of downloaded Fedora iso file is there in the command line.

sudo dd bs=4M if=Fedora-Live-Desktop-x86_64-19-1.iso of=/dev/sdc

Note that dd is in bs mode, which means it write in BYTES at a time.

Aside (From USB img to HD)

dd can also copy iso image from USB to your hard disk:

sudo dd if=/dev/sdb of=usb-image.iso

Saturday, December 14, 2013

Commands on File Compression and Decompression

zip

zip -r foo.zip [directory]
unzip foo.zip

tar

tar -cvf foo.tar [directory]
tar -xvf foo.tar

tar.gz

tar -zcvf foo.tar.gz [directory]
tar -zxvf foo.tar.gz
tar -zxvf foo.tar.gz -C [directory]

.bz2

tar -jcvf foo.tar.bz2 [directory]
tar -xvjpf foo.tar.bz2

Monday, November 18, 2013

Apache2 Notes

Enabling a module

On seeing this error:

.htaccess: Invalid command 'RewriteEngine'

This indicates that rewrite module is not enabled. In Apache 2, both module and sites are handled in the separated folders under /etc/apache2:

mods-available/
mods-enabled/
sites-available/
sites-enabled/

In the *-available folders are the configurations to be used, for instance, here we need to enable rewrite module, we just type

sudo a2enmod rewrite

You see that rewrite.load is in the folder mods-available with the content:

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

You will be notified to restart/reload the Apache service. Do it.

Enabling a website

We write the configurations as foo.com in sites/available:

<VirtualHost 127.0.0.3:80>
        ServerAdmin webmaster@example.com
        ServerName  localhost
        ServerAlias foo.com

        # Indexes + Directory Root.
        DirectoryIndex index.php
        DocumentRoot /var/www/foo


        # Logfiles
        ErrorLog  /var/www/foo/logs/error.log
        CustomLog /var/www/foo/logs/access.log combined
</VirtualHost>

Make sure there is a logs folder

cd /var/www/foo
mkdir logs

And then enable the website

sudo a2ensite foo.com 

Just to notice how to disable the website:

sudo a2dissite foo.com

Most importantly, enact the changes.

sudo service apache2 restart

Troubleshooting: Does PHP have write permission to a folder?

This article only talks about PHP installed alongside Apache under Linux (see here). Since PHP is run through libapache2-mod-php5. it inherits the permissions from Apache. So let's take a look about Apache. By default, it uses www-data user, to check this,

ps -u www-data

If it is so, you might get something similar:

PID TTY          TIME CMD
 1276 ?        00:00:00 php5-fpm
 1277 ?        00:00:00 php5-fpm
 1278 ?        00:00:00 php5-fpm
 1279 ?        00:00:00 php5-fpm
14934 ?        00:00:00 apache2
14935 ?        00:00:00 apache2
14936 ?        00:00:00 apache2
...

Now check user info and its group of www-data

cat /etc/passwd | grep www-data

The following shows up on my machine which says it doesn't belong to the root group or my administrator group.

www-data:x:33:33:www-data:/var/www:/bin/sh

We list the file permissions of the folder img/ to see apache's right:

ls -l | grep img

All right! Since Apache is in other group here, it doesn't have 'w' permission.

drwxrwxr-x 2 admin admin 4096 Nov 12 19:26 img

Then let's give him the permission. Notice that it is dangerous to do this, since in this way every user on the computer will have rights on this folder. Normally, we let the owner of the folder be Apache, and others can only read.

chmod o+w img
References

Sunday, November 17, 2013

MS Windows Terminology Italian - English

La Terminologia principale del MS Windows in correspondenza fra italiano e inglese. The correspondence of MS Windows terminology between Italian and English.

account utente User account
aggiornamento update
arresta il sistema shut down
attendere wait
attivazione o disattivazione activation or disactivation
avviare start
barre degli strumenti Tool bar
caricamento loading
cerca search
collegamenti shortcuts
connessioni di rete Network connection
Disinstalla o modifica programma Uninstall or modify programs
disinstalla uninstall
eseguire execute
gestione attività Task manager
Gestione dispositivi Device Manager
ibernazione hibernate
Immagini Pictures
impostazioni configuration
indrizzi address
manutenzione maintainance
Modalità provvisoria Safe Mode
mostra desktop show desktop
nuova new
Pannello di controllo Control Panel
proprietà property
riavvia il sistema restart
risoluzione problemi Troubleshooting
Sistema e sicurezza System and Security
souni sound
stampante printer
strumento tool

To sort a random file by alphabet,

sort -gk 2 temp