Solved

UNIX Trying to move and copy file but getting a permission denied

Posted on 2014-01-16
9
1,358 Views
Last Modified: 2014-01-17
Hello UNIX Experts,

I am a unix newbie trying to gain more understanding of unix. Right now, I am trying to move and/or copy a Python script from my home directory /Users/FB to /usr/bin but I get a Permission denied error message:

FB-MacBook-Pro:~ FB$ mv add.py /usr/bin/
mv: rename add.py to /usr/bin/add.py: Permission denied

Here are the ls -ld for the /usr/bin:

FB-MacBook-Pro:bin FB$ pwd
/usr/bin
FB-MacBook-Pro:bin FB$ ls -ld
drwxr-xr-x  1077 root  wheel  36618 Dec 29 21:27 .

I have 2 questions:

1) I want to the change the permissions on the /usr/bin to resolve the problem. The question is can I do this?

2) If I can, what command and parameters should I use?

Thank you for your assistance.
0
Comment
Question by:frbonap
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 84

Assisted Solution

by:ozo
ozo earned 100 total points
ID: 39787694
You might change it to drwxrwxrwx
but that could be dangerous since then anyone could put something there, which could trick you into running their code when you think you are running a system program.
But if you are able to run as root in order to change the permissions, why not run as root in order to do the mv?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39787698
That's a bad idea for a number of reasons.  There are a lot of system programs and files in there.  Changing the permissions wrong could crash your system.

Why do you want to do that?  What do you think you will accomplish?
0
 

Author Comment

by:frbonap
ID: 39787734
I want to do this because my script - add.py - is in /User/FB and python is in /usr/bin. Thus, I have not been able to run my script up until now. But, after getting your response, I tried to execute it in a different way and it worked.

Even though, I am now able to execute my script, I want to understand more about permissions. When is it ok to change permissions on a directory if ever?
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
ID: 39787750
I suggest that until you understand a Lot more about how Unix/Linux and Macs are organized, you stick to changing permissions in your own user areas.  I looked in my Mac and if you do "ls -al /usr/bin/py*" you will see that python Isn't really there, those are symbolic links to another directory.  Macs add another layer of complexity on top of what Unix does.

In addition to a MacBook, I also have several Linux machines and I am very careful about changing anything outside my own user area and web directories.  After 10+ years of casual use, I still don't fully understand the Unix/Linux file organization.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 7

Accepted Solution

by:
Peter Loobuyck earned 200 total points
ID: 39787854
You shouldn't change permissions on a Mac. They're there for a reason. just add a sudo prefix in your unix mv command and enter your password. All things will work properly now.
0
 
LVL 61

Assisted Solution

by:gheist
gheist earned 100 total points
ID: 39788958
You have to be root user to make things to bin/, so "sudo -s" first.
0
 
LVL 7

Expert Comment

by:Peter Loobuyck
ID: 39789018
True. Then move your files.
0
 
LVL 61

Expert Comment

by:gheist
ID: 39789043
(also pay attention to long message sudo displays - you can easily kill your system to no good)
0
 

Author Closing Comment

by:frbonap
ID: 39789168
Using the sudo command was what I really needed vs changing directory permissions. Thank you all for being patient with the rookie. The advice is very valuable.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you other experts are anything like me you are always looking into and testing out new features. While I was doing some research one day I ran across an app that I installed on my Mac and used as a security system. Mac OS X: SecureHome uses your …
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now