BLACK FRIDAY EXTRA SAVINGS EVENT - EXTENDED
START FREE

Need help to resolve error pipeline in Bash

Screen Link:
https://app.dataquest.io/m/391/redirection-and-pipelines/2/redirecting-output-with

Hello,

I try to pass following code to my ubuntu terminal on WSL:

echo "Hello there" > my_first_file

Now I get the following error:

bash: my_first_file: Permission denied

What am I doing wrong?

1 Like

Hi @LuukvanVliet:

which particular directory did you attempt to create the file in WSL? Some folders/directories in WSL restrict you access to create files do my suggestion is to navigate to ~/Desktop to create it.

Do let me know if this is successful.

2 Likes

Thanks, this worked. Since my windows C drive is automatically mounted is used the following path:

cd /mnt/c/users/luukvanvliet/desktop

What if I would have wanted to create the file somewhere else, how do I change permissions?

2 Likes

Hi @LuukvanVliet:

Glad that it worked for you!

You need to bear in mind that the permissions in linux are as follows:

 -                  rwx        rwx          rwx 
[directory]        [owner]    [group]  [other user]

The first character is a hyphen - if the object is a file (and not a folder) otherwise its a d which stands for directory (or a folder).

Check out this similar post I answered. Bash is used for mac and linux so the commands are pretty similar. I would advice you to change the permissions only on the particular file in order to prevent messing up any files in the system.

Hope this helps!

3 Likes

Hi @LuukvanVliet:

I wrote a comprehensive article about permissions here too. Do check it out!

1 Like