title: Postgres: I'm trying to copy a table to a file it shows "Permission denied"
body: <p>I like to copy a table to a file i  postgresql</p>
  
  <p>I tried this query</p>
  
  <pre><code> COPY demo TO '/home/rck/Desktop/trial.csv'
  </code></pre>
  
  <p>But it shows permission denied</p>
  
  <p>I also tried \copy but it shows syntax error</p>
  
  <pre><code> \COPY demo TO '/home/rck/Desktop/trial.csv'
  </code></pre>
  
  <p>The error is</p>
  
  <p>"<strong>ERROR:  syntax error at or near "\"
  LINE 1: \COPY demo TO '/home/rck/Desktop/trial.csv</strong></p>
  
  <p>I also tried this command in terminal</p>
  
  <pre><code>chmod a+rX /home/rck/ /home/rck/desktop /users/rck/desktop/trial.csv
  </code></pre>
  
  <p>But it still shows the same error.</p>
  
  <p>May I know the solution how to copy a postgres table to a file?</p>
  
  <p>Thanks</p>