You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Can't get standard unix commands working

When I try

echo test > /User/user/Desktop/test.txt 


I just get the result:

zsh: no such file or directory: /User/user/Desktop/test.txt


Expected result is a text file on the Desktop containing the text "text".


MacBook Pro 16″, macOS 14.7

Posted on Dec 20, 2024 6:09 AM

Reply
8 replies

Dec 20, 2024 8:08 AM in response to G45User

It looks like this could be user error:


echo test > /User/user/Desktop/test.txt 


should instead be


echo test > /Users/user/Desktop/test.txt 


where of course "user" should be replaced by the actual username (matching the name of the account home folder).


Alternatively, the same could be achieved, more easily, like this:


echo test > ~/Desktop/test.txt 


because the tilde character is a standard Unix shortcut for the user home folder.


Dec 20, 2024 8:50 AM in response to G45User

You need to give the Terminal app access to the Desktop in the Files & Folders section of the Privacy & Security System Settings. The same also goes for the Documents & Downloads folders if you plan on accessing them. Most times macOS will prompt you to give permission for the Terminal, but sometimes it may not.

Can't get standard unix commands working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.