Change Folder Permissions with Terminal - permissions

I'm trying to change the permissions of a folder. I want to make a folder, and everything in it restricted to me only; other users can't view it.
The folder, though, contains hundreds of other files in it. Is there a way in Terminal to change the permissions a folder and everything in it? I know this can be accomplished with "Get info" but there's simply too much files inside that folder to manually do that with every file.
I'm running on OS X Mavericks 10.9.5.
Help would be greatly appreciated!

of course there is a way.
You should set the ownership to your user and remove at least the executable flag for the folder. No one will be able to enter the folder via the cd command or the finder, etc.
First change directory to the location where the desired folder is located (its parent folder).
cd path/to/parent/folder
then remove the executable flag for its group (g) and all others (o)
chmod go-x folder
If you also want to make its contents invisible for actions like
ls folder/
then you have to remove the readable flag also.
chmod go-r folder
#micebrain: And there is no need for changing the permissions recursively for all folders and files inside the folder, because you can control the access of opening a folder.
BTW the executable bit (x) - if set - makes files executable and folders openable...

Related

System.IO.Directory.Delete v Git Repository - Unauthorized access

I'm writing a piece of software that maintains files in a Git repository.
One of the executables I've written has one simple purpose: delete everything to do with the software. It is given to the user in a separate, completely unrelated Windows folder.
One of the folders it needs to delete contains a Git repository, i.e. it contains a hidden .git folder
Now here's the problem I'm having. When I'm on the PC itself looking at the file system I can find that folder, click on it, delete it .... and it's gone. Not a problem.
So I try to do the same thing in my assembly by calling System.IO.Directory.Delete on that folder.
Here is what I am finding:
Everything is removed from the folder, but the folder itself is still there
When I try to THEN manually delete the folder from Windows Explorer it gives me some Unauthorised Access message. I cannot delete it.
The only way to actually get rid of it is to then try RENAME the folder in Windows Explorer, at which point I once again get an Unauthorized Access message but wouldn't you know it.... the folder disappears.
What gives!?!? Why does a System.IO.Directory.Delete NOT do exactly the same thing as me going in through Windows Explorer and deleting the folder manually?
I have tried a number of things. For example I tried getting all the files in the directory and setting all their Attributes to Normal, and through all the folders and setting their Attributes to Directory And Not Hidden. Still no joy. I even tried using Process.Start to run a RMDIR folder /S /Q - which runs perfectly from a .bat file - but the same thing happens.
I do have TortoiseGit and all its dependencies installed in case that has anything to do with anything.... and the folder does have the green Tick on it to indicate that its content is all up to date.
So my question is:
Is there any way I can successfully delete a folder containing a Git repository though VB.NET?
I finally got to the bottom of this mysterious mystery.
The culprit is TortoiseGit
When I killed the TGitCache.exe process just before deleting the folder, everything worked perfectly.
Go figure.

Changing directory on mac affects all files in Xcode Project

I simply wish to change the name of a folder that lies in my root project folder.
I have changed the name of a project (say from Proj1 to Proj2).
I now have a folder on my desktop that reads Proj2. Inside is Proj2.xcodeproj and a folder called Proj1 with all of my source files and resources.
I want to change that folder to be consistent and read Proj1, however if I change it every file in my xCode proj becomes red.
Is there a technique to change this folder within xCode such that I can rename the folder and keep all my files intact with the appropriate structure (such as what groups the files are in)?
It's annoying, indeed.
However, there's no way to keep files on the hard drive (SSD, ..) and group names and the project structure in Xcode in sync automatically.
You can re-assign the locations of the files in your red folders manually to fix it.
Wish Xcode would offer a feature like this since we've switched to Xcode from MW CodeWarrior, but..
After you rename the folder, open the project in Xcode and select this folder. You can choose the renamed folder in the File Inspector Pane.

OneDrive Multiple Folders/HardDrives Sync

I have 3 hard drives. I would like to sync specific folders from each drive with MS OneDrive.
One hard-drive cannot hold all the files from all hard drives.
How can I do this with OneDrive?
What I have done in the past is use symlinks to sync everything to OneDrive, and maintain the folder structure I want. For example, when coding, I like to keep my source folders on the root of C:, so that I can easily access it from menus (C:\coding). So what I'll do is create a folder in OneDrive called coding then symlink it to the root of C: using cmd.exe
mklink /d "C:\Link\Location" "C:\Users\USERNAME\OneDrive\Path\To\Source\Folder"
mklink /d "C:\coding" "C:\Users\USERNAME\OneDrive\coding"
Elevated permissions are required to do this.
You can do this with as many folders as necessary. Just remember, the source folder HAS to be in OneDrive. If you have existing folders that you want to sync, move them all to OneDrive and then symlink them to where they originally were located. Example:
mklink /d "C:\Users\USERNAME\Documents" "C:\Users\USERNAME\OneDrive\Documents"
mklink /d "C:\Users\USERNAME\Desktop" "C:\Users\USERNAME\OneDrive\Desktop"
mklink /d "C:\Users\USERNAME\Favorites" "C:\Users\USERNAME\OneDrive\Favorites"
mklink /d "C:\Users\USERNAME\Desktop\Vacation Pics" "C:\Users\USERNAME\OneDrive\Vacation Pics"
mklink /d "C:\Whatever I want" "C:\Users\USERNAME\OneDrive\Whatever I want"
--edit--
There is also the application Link Shell Extension that I have found extremely useful. Full instructions are found at the link, but... It integrates with Windows' Explorer shell and adds an item to the context menu. You can right click a folder to select it as the symlink source, then left click in the directory you want the symlink to be located. I think it does other things as well, but this is all I use it for. FYI, it requires VCRedist 2005 if memory serves, and does not include that dependency bundled.
For now, MS OneDrive client application only supports one folder. You would need to move all your files into that one folder.
You also cannot use Windows Explorer Libraries as the OneDrive folder - since those are NOT really folders.
Directory links are also not supported in some versions of windows. (http://www.howtogeek.com/174765/how-to-sync-any-folder-with-skydrive-on-windows-8.1/)
The Solution
What I used in the end is SyncDriver - does everything you need from any folder:
http://syncdriver.com/
First you set up the one folder where all the online stuff will go. Then you add any folder - from any drive - and it all goes to OneDrive. Simple and easy to use.
You also have options to only sync in specific directions:
OneDrive => local
local => OneDrive
Bi-Directional

Custom `rsync` command to sync my Documents and Dropbox?

This is what I want to achieve:
Dropbox Directory Structure:
Dropbox/
1passwordstuff
Music
documentfolder1
documentfolder2
Documents Structure:
Documents/
documentfolder1
documentfolder2
Then, I want to do all of my work within the Documents folder. So let's say I make some changes to a file in documentfolder1, then I want to call a command like rsync ... and have all of my changes pushed into Dropbox. I've managed to achieve this with rsync -r --ignore-existing Documents Dropbox but there's a problem. Let's say I delete some files in Documents/documentfolder1/somefile then I want those files in my Dropbox folder to also get deleted. I don't know how to do this.
Any help?
Voted to close, since this question isn't programming-related, but I think you want rsync --delete.
Why not simply use the symbolic links?
Create a symbolic link in the dropbox folder to the Documents folder, and everything will get synced, and you still will work in your Documents location.
just go to your dropbox folder and run
ln -s PATH_TO_DOCUMENTS Documents

Need to change permissions for a file/folder

In the diagnostics sections in textpattern, it's giving me the error:
"File directory path is not writable:...html/textpattern/files" (took out beginning of path)
I changed the permissions for the textpattern folder, and the folder named "files", which is in the root folder not in the textpattern folder, but it's still giving the error. Do I need to change permissions for all enclosed items of the textattern folder and not just the folder itself?
Maybe I got you wrong but I suppose you simply have to change the path to the files folder in your admin panel from "…html/textpattern/files" to "…/html/files".
Assuming you're on a *nix system...
It sounds like you want to change the permissions recursively.
A quick fix might be to change the permissions like so:
chmod -R 777 html/textpattern
This command will go through every folder and file and change its permissions (the -R turns on the recursive bit).
Warning, this is very broad and not a good idea for production.
A better approach would be to change the permissions at a finer level of granularity. Google for "Linux file permissions" or type man chown at the shell.