Changing Linux Folder Permissions

Recently I copied an entire directory of Music from my mp3 player onto my ArchLinux install. In so doing I had to sudo mount the device so the files copied all had root permissions. This was rediculous when moving files etc. but I didn’t know how to change permissions from the cli, which is all I’m using as a file manager. So here’s how you do it:

ls -l
Displays info on the files/directories.

In order: 10 spaces determining file permissions, size, owner, group, date and time of last change, name.
I wanted to change owner and group to my user name and the group to users. To find out what group you want, use ls -l in a directory where you already have the permissions you want, or if such a place doesn’t exist then:

groups yourusername

will contain the groups the user is a member of.
Anyway, to change the owner:

chown yourusername thefilename

For me I wanted it to change an entire directory of files so:

chown -R yourusername *

Then the group change with recursion included:

chgrp -R yourgroupname *

Hey presto you changed the permissions on all the files, also any file created here will have the new permissions. You could also use this to add security or nuisance when you have to sudo every renaming or file move.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.