-2

I was just going through an online tutorial on psql and came across the following command:

psql -U user -d postgres -f ~/Desktop/pgrouting-workshop/data/sampledata_notopo.sql

I am just wondering what all those parameters -d and -f, I am new to Ubuntu and don't even know what keyword to search for, So that i could get the documentation for those flags.

Can somebody break it down for me?

1
  • Where did you install psql from as it does not appear to have a man page?
    – user364819
    Sep 1, 2015 at 20:26

1 Answer 1

1

As another user pointed out, in Ubuntu (and other Linux distributions), you can typically find man (manual) pages with the man command, e.g.:

    man psql 

which would give you a "man page" on how to use the "psql" command. Alternatively, you can also try the info command, e.g.:

    info man 

which would give you information on the "man" command.

For a brief overview of man vs. info, look here.

The psql command as you are using it can be broken down:

    psql 

(the command itself)

    -U user 

(connect as the user named "user")

    -d postgres 

(to the database named postgres)

    -f ...

(use the filename located at ... as the source for the queries, as opposed to interactively ).

In brief, Linux commands generally take the form:

    command -option(s) arguments . 
2
  • one question ! , i am still not getting the use of the -f flag ! why is it being used ? Sep 2, 2015 at 9:59
  • Per the man page for the psql command: "Use the file filename as the source of commands instead of reading commands interactively". In your circumstance, you are specifying the: -f sampledata_notopo.sql file.
    – marshki
    Sep 2, 2015 at 12:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .