Tuesday, September 15, 2015

How to unset environmental variable

For example, you set DJANGO=true environmental variable with command:
export DJANGO=true
To unset it run this command:
unset DJANGO

Sunday, September 13, 2015

How to display all available package versions in Ubuntu

To display all available package versions use next command:
apt-cache madison
For example:
vagrant@vagrant:~$ apt-cache madison redis-server
redis-server | 2:3.0.2-3~bpo8+1 | http://http.debian.net/debian/ jessie-backports/main amd64 Packages
redis-server | 2:2.8.17-1+deb8u1 | http://security.debian.org/ jessie/updates/main amd64 Packages
redis-server | 2:2.8.17-1 | http://http.debian.net/debian/ jessie/main amd64 Packages
     redis | 2:2.8.17-1 | http://http.debian.net/debian/ jessie/main Sources
     redis | 2:2.8.17-1+deb8u1 | http://security.debian.org/ jessie/updates/main Sources

Friday, May 22, 2015

How to configure dnsmasq to forward all requests to specific address

For example you have a virtual machine, which you use for local development, and you want all requests to the sitesupport.net (name of the website that you are developing) forwarded to the virtual machine. We will use dnsmasq to achieve it.

Install dnsmasq:
sudo yum install dnsmasq

Start it with command:
sudo service dnsmasq start

Check if it was started without any errors:
sudo service dnsmasq status

If there is an error that dnsmasq failed to start because port 53 is already in use, you can check what process listening this post with command:
sudo netstat -tulpn | grep :53

If the process is dnsmasq itself it probably means that you have libvirt installed that has its own dnsmasq copy. To resolve that conflict we need to configure dnsmasq. Configuration file we are going to store in /etc/dnsmasq.d/vm.conf. By default dnsmasq uses file /etc/dnsmasq.conf for configuration. If you open that file, you will be able to see lots of examples and configuration descriptions. Lets left this file intact (almost) and allow dnsmasq to extent configuration with files from dnsmasq.d directory by adding (uncommenting) line:
# Include all files in a directory which end in .conf

Now create file /etc/dnsmasq.d/vm.conf with the following content:

The first line determines what interface dnsmasq will be listening. To check all available interfaces use command ifconfig.

Basicly you need to listen to localhost or You can probably do it with:

The last line of the configuration file says that all requests to sitesupport.net (including subdomains, like super.sitesupport.net) will be redirected to (that's my virtual machine).

Also you need to add to the file /etc/dhcp/dhclient.conf (or create the file if it does not exist):
prepend domain-name-servers;

You also need to restart your system. Instead of restarting the system you may try to restart following services:
sudo service dnsmasq restart
sudo service NetworkManager restart

To check that everything works correctly, use command:
ping sitesupport.net

The output should show that the request was redirected to

Thursday, May 21, 2015

vagrant: How to automatically update Guest Additions

To autmatically update Guest Additions on your vagrant machine you need to install vagrant-vbguest plugin. From the folder with Vagrantfile run the command:
vagrant plugin install vagrant-vbguest

Next time you start it with vagrant up, Guest Additions will be updated

Wednesday, May 20, 2015

fedora 21: How to add and preserve DNS server

Normally NetworkManager handels all DNS configuration. Every time when new network connection was established (?) it regenerates file /etc/resolv.conf which contains DNS server data, so editing this file is useless.

To add DNS server on top of the DNS servers list from your connections you need to create or edit file /etc/dhcp/dhclient.conf and add the following line:
prepend domain-name-servers;

Where is address of DNS server.

After applying changes you need to reboot or restart NetworkManager service:
sudo service NetworkManager restart

Tuesday, May 19, 2015

fedora 21: How to mount remote filesystem via SSH

If you use vagrant for development you might need an access to the filesystem of the virtual machine. There is a way to mount a folder from your virtual machine to your local machine so you will be able to open and edit with your favourite code editor.

First step is to install fuse-sshfs package:
sudo yum install fuse-sshfs

Then you can mount folder from the virtual machine with command:
sshfs -o idmap=user vagrant@ /home/jsn/vagrant/vm

The first path is the path inside the virtual machine and the second one is for local machine.

Wednesday, April 29, 2015

fedora: How to automatically shutdown your system

The easiest way to shutdown your system is to use shutdown command:
sudo shutdown

It will start shutdown process immediaetely.

To shutdown your system in specific time use this command:
sudo shutdown 11:50

And to shutdown your system in 2 hours (120 mins) use this command:
sudo shutdown +120