lunedì 2 ottobre 2017

Linux - How do I configure my static DNS in interfaces?

You need to configure the /etc/network/interfaces file if you want to change your DNS server via the command line.
It should look something like this:
# The loopback network interface  
auto lo  
iface lo inet loopback  

# The primary network interface  
auto eth0 
iface eth0 inet static  
address 192.168.X.X
gateway 192.168.X.X
dns-nameservers X.X.X.X 
If you have more than one DNS server, just add a space between each:
dns-nameservers X.X.X.X Y.Y.Y.Y Z.Z.Z.Z
Just replace the Xs, Ys, and Zs with your own IPs of the DNS servers of choice, and when this is done, run this command to update the settings:
sudo ifdown eth0 && sudo ifup eth0
Hope this helps!

Ubuntu - configurazione della rete

Ubuntu è corredato da una serie d'utilità grafiche per la configurazione dei dispositivi di rete. Questo documento è diretto agli amministratori di server e si focalizza sulla gestione della rete da riga di comando.

Linux command line - Change keyboard layout from English UK to English US

This seems to have changed in recent Ubuntu versions and running sudo apt-get install console-common will try to remove other packages. So, for recent Ubuntu versions, use this instead:
dpkg-reconfigure keyboard-configuration

The simplest way would indeed be as @steeldriver suggested to open a terminal and run this command:
sudo apt-get install console-common
That will install the console-common package and in the process allow you to chose your console layout. If that is already installed, use this to bring up the same wizard and set the layout:
sudo dpkg-reconfigure console-data

Linux - How to permanently configure keyboard

Using the command sudo dpkg-reconfigure keyboard-configuration
will change your keyboard layout just for this session. 
Go for sudo vi /etc/default/keyboard there you can change your keyboard settings. 
Find the line: 
You can change layout and kboptions as well as your model and the kbvariant. 
Keyboard File

Just put in it for Italian Keyboard File on older ubuntu versions you could go for dpkg-reconfigure console-setup and make permanently changes here. 

giovedì 28 settembre 2017

Run a PostgreSQL .sql file using command line arguments

I have some .sql files with thousands of INSERT statements in them and need to run these inserts on my PostgreSQL database in order to add them to a table.
The files are that large that it is impossible to open them and copy the INSERT statements into an editor window and run them there.