bookmark_borderDump / save a PostgreSQL output

PostgreSQL is one of the most used open source database solutions besides MariaDB / MySQL. Even though they have some similarities, PostgreSQL is based on a object-relational database management system while MariaDB and MySQL are relational database management systems.
This article is about how to save a PostgreSQL output. While you can use the command mysqldump to dump your MariaDB or MySQL database, saving an output with PostgreSQL is a little bit different and doesn’t require an extra tool.

Switch to the database

First and foremost we have to change / go to the database. In Linux you also have to be the PostgreSQL system user in order to work with the database. To change the user just use sudo:

user@machine:~$ sudo -u postgres /bin/bash

You are now the user postgres. You can see this at the beginning of your command line. Instead of your username you can now see postgres@ at the beginning of the line. As next we use the psql command to switch into the actual database we want to dump:

postgres@machine:~$ psql database
psql (9.3.14)
Type "help" for help.

You are now connected to the database. Don’t forget to replace database with the desired database you want to connect to.

Save a PostgreSQL output

To finally save an output you can use normal SQL statements which are returning your desired value and wrap this command within a COPY statement. The following example saves the output of an PostgreSQL statement in the file output.txt which will be located in /tmp:

database=# COPY (select firstname, lastname from user_table) TO '/tmp/output.txt';

Save a PostgreSQL output as CSV

You can also define in which format the output should be saved. You can save the output as a CSV file so that you will be able to easily work with the output within LibreOffice or MS Office for example. The following example saves the same output as in the example above, but uses CSV with semicolons as a format:

database=# COPY (select firstname, lastname from user_table) TO '/tmp/ouput.csv' (format csv, delimiter ';');

Exit database / psql command

To exit the database access and therefore the running psql command, simply enter \q to quit.

Final words

As you can see, saving / dumping PostgreSQL output directly into a text file even as a CSV file is a great feature. No extra tools needed. But PostgreSQL comes with much more than just dumping output to test and CSV files. Even the COPY command can be modified with a lot of other different settings. A good book about PostgreSQL is PostgreSQL: Up and running by Regina Obe and Leo Hsu. It covers a lot of other things besides dumping output from PostgreSQL as well.

bookmark_borderLPIC-1: Some information about the exam

Just before 2016 ended I participated in the LPIC Level 1 certification. This post is something like a „overview“ of my thoughts and experiences. I want to give you some answers which you might have and some recommendations how to prepare yourself and which tools you can use to learn and get yourself ready for the LPIC-1 exam.

About LPIC-1

Before I start, I should explain in a few sentences what LPIC-1 actually is.
LPIC-1 stands for Linux Professional Institute Certification Level 1. The Level 1 certification is also known as Linux Server Professional Certification. If you want, you can go on with Level 2 and even a Level 3 certification after you succeded with Level 1. Level 2 has it’s main focus on networking while Level 3 is more security focused. The questions and the definition of the certification itself are defined by the Linux Professional Institute which is a organization in Canada and was funded in 1999.
The Level 1, which I have succeeded in, is spitted up into two exams. 101 and 102. 101 is mainly about System architecture, the installation of Linux as well as package management (RPM and DEB!), Unix commands, partitioning and directory / files structures.
102 is about scripting, SQL, Desktops, networking basics, system services and security. All exams are mainly multiple choice. Sometimes you have to fill in a missing word by your own but you can excpect round about 90% of the questions to be multiple choice.
To have a fully and valid LPIC-1certification you need both exams 101 and 102. After this the LPI will send you your official certificate which says that you are a official tested Linux Server Professional now 🙂

Why LPIC-1 anyway?

This is a question which has come to my mind several times. I asked myself continuously do I really need a certificate which says „You are good with Linux!“? I mean I know that I’m not that bad in what I’m doing, so why do I need a organization for that? Let me sum this up with some bullet points here:

  • Employers: Here in Europe the demand for those kind of certificates is huge. Almost every free job has a requirement for this or at least there is some hint like „LPIC certification desired“. So this certificate raises your chances here.
  • Your market value: This sound stupid I know, but this is really something you have to keep in mind. A certificate like this (or any other product specific certificate like CCNA from Cisco and so on) raises your market value. You have better arguments when it comes to salary negotiations and (as the bullet point before states this) a lot of employers are interested more into people who have such a certificate.
  • Give yourself a present: This sounds even more ridiculous than increasing your market value but for me it has felt great after the monitor says „You succeed with LPIC-1“. I feel vindicated when an „official establishment“ says to me that you’re good even in them eyes. Well, I know a lot of people don’t need this, but for me it is a good feeling.
  • Learning things you might would have skipped: Oh yes! This is definitly a true thing. I would never ever learned things like at or how to use sed if I haven’t had made this certificate. Sure you can ask yourself „do I really need to learn that old stuff at?“. And yes this question is more than just appropriate, but for me this knowledge is even today worth knowing.
  • Ask your actually employer to take over the costs: For me this was another major reason. My actually employer wants us employees to get trained and certificated over time. We can choose from a wide range of possible certifications and trainings. The costs for this are taken over for 100%. You should also think about to ask your employer to take over the costs or at least a piece of them. You can always argue that this will help the company as well.

Of course this bullet points above are just a quick short overview. Eventually you have other things than are more important to you, or you just want to see your own market value increased, but if you have the time and the money you should definitly consider to get a LPIC-1 certification.

How to pass?

Ok, so I don’t can talk here too much but I can tell you, if you are working with Linux for a decent decade, than grab yourself a good book about LPIC-1, read it from the beginning and I’m pretty sure that you will pass this exams. If you’re are new to Linux or consider yourself a newbie, than you should think about doing a real course with a teacher. There are a lot of coures which are 5 to 10 days long which will let you know everything you need to pass the test. Look around the web.
For the more experienced users the following books are really good rated. Eventually they will help you to pass the test:

  • LPIC 1: Sicher zur erfolgreichen Linux-Zertifizierung
    Well, this is a book in german. If you’re german you should go with that one. It’s from „Rheinwerk Computing“ (formerly known as Galileo Books). I’ve used this one by myself. The test questions are great and the simulator, which comes on a CD, prepares you ideal for the exams.
  • LPIC 1: Study Guide
    You will find this book mentioned all over the internet. It seems that this book helped a lot of people to pass the exams. It’s a litte bit pricy but believe me, you don’t want to pay twice to redo the exams 🙂
  • LPI in a Nutshell
    To be honest I’ve never get really in touch with that book. The critics about it are really good and it’s from O’Reilly which is kinda like a legend when it comes down to professional IT books. So I guess this one is also fine. It’s also cheaper than the Study Guide!

The books will contain stuff which is really old. Sometimes the books are talking about Linux Kernel 2.4 and stuff like Floppy disks and PATA devices. But yes, this is still relevant and you will see such questions in the exam, too. So don’t skip these chapters. Learn them 😉

Other tips?

Some other tips you wanna know? Well let me sum them up:

  • Learning: I know I’ve mentioned that before, but I really want to repeat this one again. Don’t only rely on things like „Braindumps“. Braindumps can be good in addition, but I’ve found so many wrong and terrible braindumps which are just useless. Buy yourself a book and read it for 15-30 minutes each day and do the examples, than you will be well-prepared for the exams.
  • Keep calm: I’ve read a lot of horrier stories about the exams on the internet. Even if it’s true that they aren’t as easy as you might think, a lot of questions can be answered by pure logic. Especially if you are a more experienced Linux user you will be in a good position to answer some questions with the help of the logical method of elimination.
  • Take your time: If you don’t feel ready, wait another month on do more learning / training. You can do the exams by a plenty of constitutions a couple of times a week. So this is not running away from you  …
  • Dextrose: Use dextrose in the exam if you can. It taste really good, is natural and will give your brain the kick which it needs 🙂

In addition to this „basic“ tips I can recommend you the following homepages for preparing yourself:

  • Penguintutor: The Penguintutor is a homepage which concerns with Linux in general, Raspberry Pi and some other Linux specific topics. It also includes a LPIC quiz which you can find on the right hand of the homepage.
  • LPI Academy: The LPI Academy is a german site which contains LPIC questions in german. So this is similar to the Pengiontutor, but it is only for the german speaking people out there.
  • Test Exam 101: This homepages contains a test exam for the LPIC-101 exam. The questions are really looking good so far.
  • Test Exam 102: The same as for the 101 test exam but this time for the LPIC-102 exam 🙂
  • LPI Exam 101 Trainer: This app is really good if you have a smartphone and if you want to learn a little bit on the go. I used it heavily for myself and can just recommend it. The only downside is that this App tries to connect to the internet at every start up. If you don’t have a working internet connection while starting, the App will take some time until it gives up and uses the local cache. Also this App only contains questions for the 101 exam!


The LPIC-1 is definitly worth it. Especially in the United States where the exams are much more cheaper than in Europe. If your employer is paying anyway for the exams than you can just go straight for it. It will help you on the market in the future.
If you have the opportunity to do the exams in English than do it! For example the German translations are not really that good.
If you take your time to learn for the exams (eventually with a good book about LPIC-1) than you will succeed the exam and you can hold the exam in your hand while looking as happy as the good old Tux 🙂
Being that said, happy learning and good luck with your exam. And if you have any questions, let me know. I will help you as much as I can 🙂

Further links