martedì 20 gennaio 2015

Risultato grep in un nuovo file con espressione regolare

il file di origine ha questa struttura:

nome cognome email

Voglio creare un nuovo file con le sole mail


grep -o -E '[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}' users.txt > userc.txt



giovedì 6 febbraio 2014

Scaricare pacchetti deb con lettura da file

cat my_file.txt | while read line; do
        sudo apt-get install -dy $line
done

supponendo che my_file.txt sia una cosa tipo:
nagios3
nagios3-cgi
nagios3-common
nagios3-core
nagios3-dbg
nagios3-doc
nagios-images
nagios-nrpe-plugin
nagios-nrpe-server
nagios-plugins

.....


al termine i pacchetti si troveranno in /var/cache/apt/archives/

lunedì 27 gennaio 2014

Windows e Ubuntu con esportazione grafica

Sono partito da un notebook con Windows 7 sul quale ho installato VMWare player.

Ho creato una VM con Ubuntu 12.04 LTS desktop con due interfacce di rete: una NAT e un'altra solo-host.

Al termine dell'installazione ho disabilitato il server grafico della VM seguendo queste istruzioni:

Change (edit) in /etc/default/grub file:
From:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
To:
GRUB_CMDLINE_LINUX_DEFAULT="text"
Now you must update the grub configs:
sudo update-grub
And its done! After reboot, to start the gui just login and type:
startx


Ho installato sull'host windows Xming Server (http://www.straightrunning.com/XmingNotes/) e putty.

Dopodiche' : putty.exe -X   username@iphost

A questo punto ho lanciato un'applicazione con l'interfaccia grafica (es. firefox &).

That's all.




p.s.
Nella VM se si vuole riavviare la GUI bisogna fare:

sudo service lightdm start







mercoledì 30 ottobre 2013

Abilitare SSH con autenticazione via password

edita il file :
/etc/ssh/sshd_config
 
e metti a:
 
 yes
 
 la voce: PasswordAuthentication 
 
restart the sshd server

sudo /etc/init.d/ssh restart
 

mercoledì 23 ottobre 2013

Fork di un progetto con GIT

http://www.tecnobanana.com/2011/06/github-come-aggiornare-un-fork-dal-repository-ufficiale/

http://git-scm.com/book/en/Distributed-Git-Contributing-to-a-Project


Install Java on Linux Ubuntu

reference: https://help.ubuntu.com/community/Java


Oracle (Sun) Java 6

WARNING: Oracle Java 6 had reached its end of life in November 2012. There is at least one severe known vulnerability in this version, and since Java 6 is neither supported by Canonical nor Oracle, there may be many more! You should really not install this unless you have a specific need to do so. It is recommended that users either migrate to OpenJDK, or install Oracle Java 7.
Oracle (Sun) Java 6 is no longer available to be distributed by Ubuntu, because of license issues.
Deprecated information about the installation of Oracle Java 6:

JDK or JRE

Downloads the Java binary installers from Oracle, builds the .deb packages locally on your computer and then installs them. Packages are compatible with the “official” Ubuntu ones and will upgrade Java 6 that was previously installed from packages.
You can find the script and full usage instructions on github.
(since version 0.2.3 it also works with java 7 using -7 optional parameter).
Another instruction it works for Ubuntu 12.04.

Manual method

  • oracle java 6 jre 32-bit
 $ wget http://download.oracle.com/otn-pub/java/jdk/6u34-b04/jre-6u34-linux-i586.bin
 $ chmod u+x jre-6u34-linux-i586.bin
 $ ./jre-6u34-linux-i586.bin
 $ sudo mkdir -p /usr/lib/jvm
 $ sudo mv jre1.6.0_34 /usr/lib/jvm/
 $ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jre1.6.0_34/bin/java" 1
 $ sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jre1.6.0_34/lib/i386/libnpjp2.so" 1
 $ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jre1.6.0_34/bin/javaws" 1
or
  • oracle java 6 jdk 64-bit
 $ wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin
 $ chmod u+x jdk-6u45-linux-x64.bin
 $ ./jdk-6u45-linux-x64.bin
 $ sudo mv jdk1.6.0_45 /opt
 $ sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.6.0_45/bin/java" 1
 $ sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/jdk1.6.0_45/bin/javac" 1
 $ sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/opt/jdk1.6.0_45/jre/lib/amd64/libnpjp2.so" 1
 $ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/jdk1.6.0_45/bin/javaws" 1
  • IMPORTANT choose the java you installed as default
 $ sudo update-alternatives --config java
 $ sudo update-alternatives --config javac
Optionally you can set a JAVA_HOME env variable:
export _JAVA_HOME=/opt/jdk1.6.0_45/

Choosing the default Java to use

If your system has more than one version of Java, configure which one your system uses by entering the following command in a terminal window
sudo update-alternatives --config java
This will present you with a selection that looks similar to the following (the details may differ for you):
There are 2 choices for the alternative java (providing /usr/bin/java).  
Selection Path Priority Status 
———————————————————— 
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode 
1 /usr/lib/jvm/jre1.7.0/jre/bin/java 3 manual mode  

Press enter to keep the current choice[*], or type selection number: 1

IBM Java

IBM provide JRE and SDK binaries for a number of architectures, including PowerPC. These are available via the IBM Downloads Page once you have registered.
There are two types of 'InstallAnywhere' package available to you: the 'Archive/tgz' only extracts the files to your system, whereas the 'Installable' package supposedly also configures your system. You can use either, both require additional configuration with Ubuntu. The 'Installable' package also provides an uninstall option.
To run the downloaded file use the following commands: 
 
chmod a+x ibm-java-ppc-jre-6.0-10.1.bin
sudo ./ibm-java-ppc-jre-6.0-10.1.bin
 
This launches an interactive program that guides you through the installation options. Extract the file to the directory of your choice (for example /usr/lib/jvm/java-6-ibm-powerpc).
Once completed, you then need to tell the system where to find the new java commands. If you only have IBM Java installed then you can define an environment variable to do this. For example, add the following line to your .bashrc file in your home directory. 
 
export PATH=/usr/lib/jvm/java-6-ibm-powerpc/bin:/usr/lib/jvm/java-6-ibm-powerpc/jre/bin:$PATH

If you also have openjdk installed then you'll need to update the java alternatives:
 
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-6-ibm-powerpc/jre/bin/java" 1
sudo update-alternatives --set java /usr/lib/jvm/java-6-ibm-powerpc/jre/bin/java

You'll need to repeat this for every command you need. For the mozilla plugin you can use:
 
sudo update-alternatives --install /usr/lib/mozilla/plugins/mozilla-javaplugin.so mozilla-javaplugin.so /usr/lib/jvm/java-6-ibm-powerpc/jre/lib/ppc/libnpjp2.so 1
sudo update-alternatives  --config mozilla-javaplugin.so

Further guidance can be found in the IBM documentation (including a different way to link the plugin).
If you don't use the mozilla plugin frequently then you can disable it for security. You can do this through the Firefox menus or there are Firefox extensions you can use to automate this.
To control which Java the Konqueror web browser uses, go to your KDE system settings. Select Internet & Network -> Web Browser -> Java & JavaScript, and change the Path to Java executable to either /usr/lib/jvm/java-6-ibm-powerpc/bin/java or java (without any quotes).
Test the installation at the Sun Java test webpage and using the command:
 
java -version

Note, there are old PowerPC deb packages still in medibuntu (keep clicking refresh if you get 403 forbidden). These are probably the easiest way to install, although they are now lacking security updates, plus the latest browser plugin. For these reasons it is strongly advised that you download a newer Service Refresh Fix Pack directly from the IBM Downloads Page.
You may have to install libstdc++5 and libgtk1.2 packages to use old versions of IBM Java. If you installed a 1.4.2 version, and your processor is not a G5, you may have to perform another step to get it to work. For a G3 or G4, use the following command:

 
 sudo sh -c 'echo "JITC_PROCESSOR_TYPE=6" >> /etc/environment'

For a 604e or 603e, instead use:
        sudo sh -c 'echo "JITC_PROCESSOR_TYPE=5" >> /etc/environment'

martedì 22 ottobre 2013

Ricerche ricorsive su Linux

Ricerca di un file

inizia dalla root

find . -name "*.xxx" -print    

da una cartella 
find path_cartella -name "*.xxx" -print    



Ricerca dentro un file

grep "cosaricercare" /directorydovecercare

The following is a modification of the above example that uses the star wildcard (i.e., an asterisk), which represents any character or sequence of characters, to search all text files in the current directory 

grep 'Linux is' *

grep -r .... se la si uole ricorsiva

You can force grep to ignore word case i.e match boo, Boo, BOO and all other combination with the -i option:

$ grep -i "boo" /etc/passwd