Results 1 to 7 of 7

Thread: Terminal: Permission Denied (cat)

  1. #1
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Terminal: Permission Denied (cat)

    I don't think the cat command needs any privileges, but I gave it some anyways. This still isn't working, I'm attempting to merge files.

    I've tried:
    Code:
    sudo cat surnames >> names
    cat surnames >> names
    My output is:
    Code:
    bash: names: Permission Denied
    If I use the sudo prefix, this shouldn't happen right?

  2. #2
    Join Date
    Oct 2009
    Location
    127.0.0.1
    Beans
    181
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Terminal: Permission Denied (cat)

    My first thought is that "cat" is not where your permission issues lie - it's in the file called "names". Test this by just running
    Code:
     cat surnames
    and see if you get what you expect. If so, then the issue is that you can't append the results of "cat surnames" to the "names" file. In the directory where the file is located, you can do
    Code:
     ls -l
    to list all the permissions of the files there. If you do not have access to the file, you can
    Code:
     chmod +x
    to give execute permissions, and chmod +r / +w for reading and writing, respectively.
    http://ubuntuforums.org/showthread.php?t=283131- How to fstab
    Ubuntu User #29490

  3. #3
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Terminal: Permission Denied (cat)

    Post the output of:

    Code:
    pwd
    and
    Code:
    ls -l
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  4. #4
    Join Date
    Jun 2009
    Location
    0000:0400
    Beans
    Hidden!

    Re: Terminal: Permission Denied (cat)

    You're applying the elevated permissions to the read part of the command, and not the write part. If you want to be able to write in this manner, you have 2 options:

    Code:
    sudo bash -c 'cat file1 >> file2'
    or
    Code:
    cat file1 | sudo tee -a file2
    Both will accomplish the same goal.

  5. #5
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Terminal: Permission Denied (cat)

    falconindy, that worked great thanks
    However, so I understand well, what does "bash -c" and "tee" do?

    Thanks to the other who helped too!

  6. #6
    Join Date
    Nov 2005
    Location
    NEK Vermont
    Beans
    Hidden!
    Distro
    Ubuntu UNR

    Re: Terminal: Permission Denied (cat)

    man pages are very helpful.
    Code:
    man tee
    man bash
    Tells you basically tee redirects output in two directions...to the screen and to a file. bash -c reads from standard input or file and the -c option causes commands to be read from the string, namely to append the output file in this case.

  7. #7
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Terminal: Permission Denied (cat)

    Many thanks to all of you

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •