guy labs guy labs

PostgreSQL – CET FATAL: could not create shared memory segment

Infrastructure, Linux
/by
Lately I updated to the latest PostgreSQL from the Ubuntu repositories and then I got the error "CET FATAL: could not create shared memory segment". As the following error message states, the  value of the kernel is too less or the shared memory propery of PostgreSQL is too high. The complete error message looked like this: My solution was to increase the  kernel parameter as I have a lot of memory left on my server. To see the current value of your  parameter execute the following command : And to check the size of the shared memory of your PostgreSQL instance open up the file   and search for the parameter  . To increase the  parameter of your system you need to edit the   file and add the following at the end of the file: That would increase the  value to 100 mega bytes (104857600 bytes). Next you need to reload the sysctl file with the following command: After that you should be able to restart the PostgreSQL server without any problems. Cheers and have a nice...

How to install fish shell in Ubuntu 13.04

Linux
/by
I used the fish shell for some time now and I'm really happy with it. The highlighting, the command completion etc. are great. Today I want to show you how to install it and use it as default shell in Ubuntu. Ok let's start by installing the fish package from the Ubuntu repository with the following command: If you want the newest version you can go to the developer website and download the newest .deb file for Ubuntu. Next we need to set fish as the default shell. Execute the following command, log out and login again and when you now open a shell it should show the fish shell. It's worth read the documentation about the fish shell because it's very powerful and has a lot of useful features you surely dreamed of. ...

How to install ownCloud 5 manually on Ubuntu 13.04 with Apache 2

Linux
/by
Today we want to install ownCloud such that we can host everything at home and it is under your control. You can check the features at https://owncloud.org Ok first step is to download the ownCloud distrubution to your server and extract it in your web directory. (Normally inside /var/www) You need to have an Apache HTTPD running. Now you need to install some php dependencies which are needed by ownCloud. To do this execute the following commands: Next you need to ensure that 'AllowOverride' is set to 'All' in the 'Directory /var/www' section of your virtual host file. This is usually in '/etc/apache2/sites-enabled/000-default'. Update 23.11.2013: If you have Apache version 2.4.3 or later (default in Ubuntu 13.10) installed you need to add the following to the /var/www section of your virtual hosts file (which now ends with the .conf extension): Next we need to enable some Apache 2 mods with the following commands: Now open the browser and connect to your server and add '/owncloud' to the URL. Follow the installation instructions and select a database. I use PostgreSQL but you can also use MySQL or SQLite (file based database). But for larger installations you should use PostgreSQL or MySQL. After the installation is finished, you can test your ownCloud instance. If you need more documentation or need support goto http://doc.owncloud.org Thats all on how to install ownCloud on your own...

Mount FTP directory with TLS and backup files in Ubuntu 13.04

Linux
/by
This howto shows you how we can download FTP files over TLS and backup them automatically. I have several Wordpress websites which are running on remote servers where I just have FTP access. I installed a Wordpress plugin (http://wordpress.org/plugins/backwpup/) which makes daily backups and now I want to store them on my server at home. First we need to install curlftpfs by executing the following command: Next we need to test if the FTP mount works with curlftpfs. To test this execute the following command: If your username or password contains special characters you need to convert them. For example you need to convert an @ to %40. You can use this converter: http://www.w3schools.com/tags/ref_urlencode.asp If you get the following error: You need to download the server certificate with the following command: and add it to the options of curlftpfs: Now the mount should work and if you browse into the /mnt directory you should see the files which are in the specified directory on your FTP server. Update 06.03.2014: After a comment on this post about how to hide the password from the process list I add the following addition from the FAQ of the curlFtpFS project website: You can put the user and password in a .netrc file in the home directory of the user that executes CurlFtpFS. It can have 600 permission. It's still clear text but at least is not accessible by all. The format is: Ok now it's time to create a simple backup script which copies the backups to a local folder...

Install ClamAV antivirus in Ubuntu Server and Client

Linux
/by
In this how to we will install ClamAV antivirus on an Ubuntu client and a server. First we will install it on the client with the following command: This will install ClamAV and the GUI frontend ClamTK. You can configure daily scans and virus definition updates inside this tool. To install ClamAV on an Ubuntu server we start by installing ClamAV and the daemon by executing the following commands: Next we need to reconfigure the ClamAV base package, update the virus definitions and start the daemon. Execute the following commands: Next we need to create a shell script which scans a specific directory and sends an email if a virus is found. Place that shell script inside the user home of the root user or somewhere else. I placed it inside /home/clamav. Ok now create a file with the command 'sudo vi clamav-scan.sh' and enter the following content: Next we need to make the file executable with the following command: After that we add this file as a cronjob which executes every night at 3am: Substitute the {PATH-TO-SCRIPT} placeholder with the path where the clamav-scan.sh script is stored. Next we infect the folder you want to scan with the EICAR test virus. For that create a text file and add the following content to it: Store it and then run the created clamav-scan.sh to see if the virus is found and the mail is sent. After everything worked as it should, delete the test virus text file. But be aware: The clamav-scan.sh script identifies the viruses and doesn't delete them, that has to be done manually. Ok...

Create a software RAID1 with mdadm on an active Ubuntu 13.04 till 16.10 hard drive

Linux
/by
Today we want to create a RAID1 array with an active Ubuntu 13.04 till 16.10 hard drive. I installed my server without a RAID array on a single hard drive. And now, after spending a lot of hours configuring it, I want to create a RAID1 array to have a security if one of the hard drives fail. Create a simple RAID1 array is easy with mdadm, but creating it with a hard drive that has data on it isn't that simple. I created the following howto with the help of this older blog post about the same problem: http://feeding.cloud.geek.nz/posts/setting-up-raid-on-existing Use this article with caution because this is the solution for my machine and I don't know if it works on other machines, but I gave my best to test everything in a virtual machine and on my server with the UEFI boot mechanism. Also create a backup of your hard disk first: Create a CloneZilla disk image Ok let's start and we first need to install the following packages: If you havent already installed postfix, set the option 'no configuration' for the postfix installation dialog. First attach your new hard drive (best to have one with the same size or bigger) and then execute the following commands to copy the partitions of /dev/sda to the second drive (in my case /dev/sdb): If you have a GPT partition table you need to install gdisk and copy the partition table with the following commands: The first command here copies the partition table from /dev/sda to...

How to resize a VirtualBox hard drive in Ubuntu 13.04

Linux
/by
Lately at work I needed to install Microsoft SQL Server on my Windows 7 virtual machine, and it was just to big for the free space left on my virtual hard drive. So I searched a way to resize it without spending too much time. You just need to open a terminal, browse to your .vdi virtual drive and then execute the following command: Inside the example command I resize the Windows-7-SP1-64-Bit.vdi virtual drive to a complete size of 30 GB (30'000 MB). Don't forget to format the free space or resize the partition with gparted or any other partitioning tool. I hope this helps someone  :wink: Have a nice...

Install BIND 9 in Ubuntu 13.04

Linux
/by
  Hi, today I want to show you how to install BIND 9 in Ubuntu 13.04. I have installed it on my own server at home, such that I am able to use the DNS names for my applications which I use from the outside. For example git.guylabs.ch etc. It also boosts the performance if you have an internal DNS server, because now the request doesn't need to be resolved on a public DNS name server anymore. Ok lets get started. First of all we need to install the necessary package by executing the following command: Next we need to add forwarder DNS name servers which are used when the internal name server cannot resolve the DNS name requested. For that open up the file /etc/bind/named.conf.options as root and add or uncomment the two name server IP addresses to the forwarders block. (Here we use the public DNS name server IP's from Google) After that we need to add the local name server and the search domains to the static local interface. To do this open up the file /etc/network/interfaces as root and add the following two properties to the static defined interface. (It's good to have the DNS server configured with a static IP address. If you don't know how to do this, please read this article) Next we need to define the zones for our local domain. For that open up the /etc/bind/named.conf.local as root and add the following two code blocks and adapt it for your environment. (In this example we use the network 192.168.1.0. And the...

Configure a static IP in Ubuntu 13.04

Linux
/by
    Today we want to configure Ubuntu to use a static IP address instead of a dynamic one (from a DHCP server). 1. To do this we first need to switch from the default dhcp mode to the static mode. Open up the /etc/network/interfaces file and remove everything and add the following: Ok lets go through the properties we set here: The first two lines configure the loopback interface. These are default and shouldn't be touched, unless you have a specific purpose. The next two lines configure the eth0, the default wire connected interface. As you see it configures this it as static interface. The properties we set till the dns properties should be self-explanatory. The last the properties are about the DNS server. If you have a locally installed one you can configure it here with the dns-search and the dns-domain property. If you don't have one you can use the ones from Google, namely 8.8.8.8,8.8.4.4 Save the file and exit the editor. 2. Ok now we need to delete the old config which generates the resolv.conf file and we need to remove the DHCP client. Please execute the following commands: 3. Ok no it's time to restart the network interface with the following command: This command executes the two packed command in order, such that we don't get disconnected while executing a ifdown and then we can't start it with the ifup. (In case you are connected via SSH) You can check the result by opening the nohup.out file in the folder where you ran the previous command. 4. Now we...

Monitor S.M.A.R.T. with smartmontools in Ubuntu 13.04

Linux
/by
    Today we want to install and configure smartmontools to monitor the S.M.A.R.T. attributes. Additionally we want to be notified by email if a warning or an error occurred. Install and check hard drives Ok let's start by installing smartmontools with the following command: After that we want to check the hard drives with the following command: Replace the /dev/sda with the hard drive you want to check. If smartctl doesn't succeed you need to add the type of the hard drive interface to the command. To do this add the -d {TYPE} argument to the previous command and subsitute the {TYPE} with ata, scsi or sat (for sata). This command outputs some information about your hard drive. Next we want to enable additional features by executing the following command: This enables the S.M.A.R.T. support (-s on), the offline data collection (-o on) and the autosave of device vendor-specific attributes (-S on). You will find more information about the arguments in the man pages of smartctl. After that we can check the overall health of the hard drive by executing the following command: If the test result isn't PASSED you should backup your data now and exchange the hard drive. We also want to check if your hard drive supports the self checks. To do this execute the following command: Now check the ouput where it says "Offline data collection capabilities" and one of the values should be "Self-test supported". Then your hard drive supports the self tests. What you also see in the output is how long the short...