Ok, so I've got a problem with VSCode where every time I try to save a file it asks me for sudo permission and it's really annoying and I can't make folders or files directly in the IDE. Can please someone help me?
Screenshot from VSCode
The running instance of VS Code doesn't seem to have write permission to the file you wish to save.
Since the file is in the directory of user uteu3, first make sure that it is user uteu3 that has started VS Code (it probably is, if uteu3 is the user logged into the system).
make sure uteu3 is the owner of the file and change the permissions by opening a terminal and executing:
sudo chown uteu3 filename && sudo chmod 664 filename
(Replace filename with actual path+name to the file.)
If this doesn't solve the problem, please execute the following two lines in a terminal and provide the output:
ps aux | grep visual-studio-code
stat -f '%A %a %N' filename
Since you indicate that this happens repeatedly also with other files, maybe several of the file permissions in your home directory are problematic. In that case, consider trying to fix them all. See for example: Need to fix file permissions in a user's home directory
.
I need to set the permissions of just 3 specific folders (on my Mac) to 777
I went to CMND+i (get info) but the folder permissions seemed to be Read and Write - but this didn't seem to fix it.
I am trying to work out how to do this, because I am using MAMP on my Mac to try and run a localhost server to test a website. Reason; I am trying to run the script of a PHP website. It is asking me to change the permissions of certain folders in order to proceed with the 'install'.
I think the closest match to a possible answer is here:
Java: Create a new dir with 777 permissions on Mac
But, this appears to be Java. I assume that I need to be able to do this via either MAMP or Terminal. If anyone could please advise me which program/tool to use and what to type in, I'd be very grateful.
Thanks
I know how to do it in a terminal, to create "/some/directory/some/where" you can use -
# EDIT: 777 not 077.
mkdir -p /some/directory/some/where && chmod 777 /some/directory/some/where
I have a serious problem. Every time I edit my source code, I have to do a chown username:groupname for my htdocs folder. Now if I have to publish my files and have them executed on the webserver, I have to do a chown www:www for things to work right. I have tried to change my username,groupname in httpd.conf to my login in Mac OS but ownership still gets set incorrectly. I just want to be able to edit my source code and then not have to worry about changing the permissions.
What do I do?
Probably the easiest is to set the sticky bit of the enclosing directory and make www the group of it. So for example if you want to edit files in /Library/WebServer/Documents you would prepare it with
sudo chgrp www /Library/WebServer/Documents
sudo chmod g+s /Library/WebServer/Documents
Then all files you edit (or technically create) in Documents will have www group as well, so as long as your umask is reasonable (e.g. 0022) they will be readable by the web server and you can edit them as you please.
I hope you can help get to the bottom of this. This is whats happened:
We duplicated our live Magento site (for example we'll call it domain1.com) to a development server (for this example I'll call this domain2.com)
Did a find/replace for the domain1.com to domain2.com in both the database and files
Deleted all var/cache and var/session files
Reindexed all indexes via SSH
Emptied browser cache
Checked all file permissions
Disabled the .htaccess incase this was causing a redirect
But it's still redirecting to the live server (domain1.com)??
Any ideas what may be triggering this?
Cheers,
Dave
Solved the issue...hopefully this helps some other people.
When the site was duplicated we edited the "local.xml" file with the new details but kept the old one and renamed it "localnew.xml"
It seems Magento was still picking up these details as so was redirecting to the old site.
Deleting the "localnew.xml" (or whatever you called it eg. localxxx.xml) fixed all our issues!
I'm working in a local Centos 6.4 running in a VM at the moment to test various things.
My production Magento site is in that folder: /var/www/html/magento
and the staging site is there: /var/www/html/staging/magento
I had the same issue than you, did everything I could come up with, triple checked the urls in the database, cleared the cache, checked the .htaccess file, rebooted multiple times.
The one thing that fixed the issue has been to set back the permissions properly:
cd /var/www/html/staging/magento
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chown -R sysadmin:apache .
chmod -R 777 media app/etc var var/.htaccess
Just open your DB and open the table "core_config_data"
then edit the values for the path web/secure/base_url & web/unsecure/base_url
I'm sharing a git repository with a colleague, and because git does not propagate the full panoply of Unix file permissions, we have a "hook" that runs on update which sets the 'other' permissions as they need to be set. The problem? The hook uses chmod, and it turns out that when my colleague commits a file, he owns it, so I can't run chmod on it, and vice versa. The directories are all group writable, sticky, so I believe that either of us has the right to remove any file and replace it with one of the same name, same contents, but different ownership. Presumably then we could chmod it. But this seems like an awfully big hammer, and I'm a bit leery of screwing it up. So, two questions:
Can anybody think of another way to do it?
If not, what's the best design for a bulletproof shell script that implements "make this file belong to me"? No cross-filesystem moves, etc etc...
For those who may not have realized, write permission does not confer permission to chmod:
% ls -l value.c
-rw-rw---- 1 agallant ta105 133 Feb 10 13:37 value.c
% [ -w value.c ] && echo writeable
writeable
% chmod o+r value.c
chmod: changing permissions of `value.c': Operation not permitted
We are both in the ta105 group.
Notes:
We're using git not only to coordinate changes but to publish the repo as a course web site. Publishing the web site is the primary purpose of the repo. The permissions script runs at every update using a git hook, and it ensures that students do not have permission to read solutions that have not yet been unveiled.
Please do not suggest that I have the wrong umask. Not all files in the repo should have the same permissions, and whatever umask is chosen, permissions on some files will need to be changed. Not to mention that it would be discourteous for me to impose my umask preferences on my colleagues.
UPDATE: I've just learned that in our environment, root is quashed to nobody on all machines we have access to, so that a solution which relies on root privileges won't work.
There is at least one Unix in which I've seen a way to give someone chmod and chown permissions on all files owned by a particular group. This is sometimes called "group superuser" or something similar.
The only Unix I'm positive I've seen this on was the version of Unix that the Encore Multimax ran.
I've searched a bit, and while I remember a few vague references to an ability of this sort in Linux, I have been unable to find them. So this may not be an option. Luckily, it can be simulated, albeit the simulation is a bit dangerous.
The way to simulate this is to make a very specific suid program that will do the chmod as root after checking that you are a member of the same group as owns the file, and your username is listed as having that permission in a special /etc/chmod_group file that must be owned by root and readable and writeable only by root.
The most straightforward way to do this is to make your partner and you members of a new group (let's say "devel"), and have that as the group of the file. That way it can be owned by either of you, and as long as the group is right, you can both work with it.
If that doesn't work with you, "sudo" can be configured such that only those two users can run a chmod command on files in that specific directory as root with no password.
If you set your umask correctly, the files could be created with the correct permissions in the first place:
$ umask 0022
$ touch foo
$ ls -l foo
-rw-r--r-- 1 sarnold sarnold 0 2011-02-20 21:17 foo
$ rm foo
$ umask 0002
$ touch foo
$ ls -l foo
-rw-rw-r-- 1 sarnold sarnold 0 2011-02-20 21:17 foo
I'm taking a step back. Let me know if I'm violating some restriction in your system I haven't read.
From your question, I assume you're trying to share a git repository using file:// URLs and relying on the UNIX filesystem permissions to take care of authorisation etc. Why don't you consider another way to share your repositories that doesn't involve this hassle?
I can think of two ways.
You can create bare repository on either of your machines, add that as a remote to your working repos and use it to collaborate. Serving it can be done using the inbuilt git daemon command. Detais are here. This will however not give you any access control.
You can install gitosis locally and use that to serve your repository. This allows a simple access control system so that you can restrict/allow certain users.
There was a related question that came up a while ago that might be relevant. git daemon worked for him - Administrating a git repo without root permissions
I also found something on server fault that might be relevant to your problem - https://serverfault.com/questions/21126/git-daemon-and-access-control-for-multiple-repos
Probably not the most elegant way, but it seems to work
$ umask 0002
$ mv value.c value.c.tmp
$ cat value.c.tmp > value.c
$ rm value.c.tmp
one could argue that it could be made bulletproof, but then someone brings along a RPG...
If both of you need to chmod, I can not think of another way - if it is OK that YOU can chmod but no the other guy, you can chmod 6770 . or chmod g+s,u+s . in the directory (e.g. set SUID and GUID bits) so the one that owns the directory will always be the owner of the files. Unfortunately some (if not most), namely EXT2/3/4 ignore the SUID bit.
Of course, setting the umask to 0002 will solve the problem by not making it mandatory.
Assuming that your publishing hook actually deploy files, rather than just setting permissions in the working copy, you could deploy to a temporary location then use rsync to ensure that the file contents and permissions are correct.
Slightly nicer, but requiring some infrastructure which I'm guessing isn't in place, would be to ensure that the deploy script only runs under one user. You could do this using sudo, if your sysadmins allow, or by setting up a git server service, like gerrit, or even by having a cron job run every five minutes which checks for updates and deploys if necessary.
This might work:
touch $name.tmp
chmod 660 $name.tmp
cp $name $name.tmp
if cmp $name $name.tmp 2>/dev/null; then
rm $name && \
cp $name.tmp $name && \
rm $name.tmp
fi
It's just a variation of your original idea
Ok, a mixture of things that build on previous answers:
you can set the umask of a folder if you mount it at fstab. If you could agree with people to work on that mount, you could enforce g+w
If you set the group-id bit of that folder (g+s) all files will belong to the group the folder belongs to, so the group ownership of the file propagates
Is that doable? Of course enforcing that mount point is no easy task. Any better ideas around that one anyone?