Skip to main content

Recursively fixing file and directory permissions

·126 words·1 min· ·
Linux Bash Git Sh File Permissions
Ariejan de Vroom
Author
Ariejan de Vroom
Jack of all Trades, Professional Software Craftsman

While working on a Gitlab installation I noticed that all repository file permissions were off. Fixing recursive file and directory permissions can be quite hard. Or so I thought.

Using the following commands (in plain Bash) allow you to recursively set permissions for files and directories. So, to fix the proper read permissions on your Gitlab repositories you can use this:

# Go to your git repositories directory (as git or the gitlab user)
cd /home/git/repositories

# Fix ownership
sudo chown -R git:git *

# Fix directory permissions
sudo find -type d -exec chmod 770 {} \;

# Fix file permissions
sudo find -type f -exec chmod 660 {} \;

After this, your Gitlab should have no trouble accessing your code (e.g. in the tree browser).

Related

Bash it! - Number of messages in Postfix queue
·37 words·1 min
Blog Features Linux Bash Bash IT Shell Postfix Scripting Mail Server Queue Email Messages
Contributing to Open-Source with Github
·447 words·3 mins
Git Rebase Github Flow Fork Upstream
Fixing a slow starting Terminal or iTerm2 on Mac OS X
·171 words·1 min
Bash Shell MacOSX Devops Terminal Terminal.app Iterm Iterm2 Zsh