Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Console Foundations Environment and Redirection Find and Grep

Ayima Okeeva
Ayima Okeeva
10,149 Points

Permission denied to hello.txt file.

When I want to run grep command, the console returns a message "grep: hello.txt: Permission denied", what am I doing wrong?

4 Answers

Hey Ayima,

This could very well be a permissions/ownership issue. In order to run grep on the file, you must first have permission to read it. Remember a few videos back where we were changing permissions and owners using the chmod and chown commands? Chances are, you may have left hello.txt without the read permission either for your user, group, or other.

If you enter the following command, it should remedy the problem, but I would definitely recommend re-watching the videos on 'permissions' and 'file ownership' to make sure you grasp the concepts.

treehouse ~ $ chmod 666 hello.txt

Good luck!

Chris

Marked as best answer

What's the command that you are typing into the console ?

I'm using:

treehouse ~ $ grep can hello.txt
can                                      
can
Ayima Okeeva
Ayima Okeeva
10,149 Points

I was following the commands from the course Console/Environment and Redirection/Find and Grep.

treehouse ~ $ grep "is" hello.txt grep: hello.txt: Permission denied

treehouse ~ $ grep this hello.txt grep: hello.txt: Permission denied

Many thanks!

Well this is my solution, which is more in the line of hacking it, but as Christopher said, make sure you grasp the permissions and file ownership concepts:

enter : sudo chmod +r hello.txt it will ask you for the treehouse password, you enter 'mike the frog'

and you're good to go. try ls -l to check the permissions and then you can continue on with grep "is" hello.txt