• We did not send an email asking for donations - please read this post.

File Permissions - chmod

CptCharis

Well-Known Member
Joined
Feb 27, 2018
Messages
562
Reaction score
465
Credits
970
Just choose a category and you will see a blue button

“ post new thread “

B7A592B4-BBE0-42E5-9684-6C47D5A7416A.png
 


rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
647
Reaction score
518
Credits
3,613
That's a nice tutorial but I found a lot easier way - with fstab: just add "uid=1000" in the options for each partition you want to be its owner, reboot and that's it.

Code:
UUID=79efb309-826e-40a7-a786-7b83b682dcb4 /               ext4    errors=remount-ro 0       1
UUID=88FCD635FCD61CEE /media/rado/Drive_D               ntfs    errors=remount-ro,uid=1000 0       1
UUID=6F01A23F6CA00FCF /media/rado/Drive_E               ntfs    errors=remount-ro,uid=1000 0       1
 

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
7,802
Reaction score
6,628
Credits
28,794
You are already uid=1000 by default, as the first normal (non-root) user set up by the system.

Code:
grep 1000 /etc/passwd

... should show rado and 1000

Also, although you may only be showing an example above with the NTFS partitions/drives, that method might have relevance if you are playing games that were Windows-based and you want to be able to access them (say, under Steam or Proton) under Linux so as not to have to set up new files, but other than that you are lowering security.

@Rob has, at the beginning

We will show you how to understand file permission symbols and how to modify certain files so that they're more secure.

My highlighting.

Besides, in Linux, you already have root privileges over Windows NTFS files and folders.

An example is here

Code:
[email protected]:~$ cd /media/chris/OS/Windows/System32/GroupPolicy
[email protected]:/media/chris/OS/Windows/System32/GroupPolicy$ ls -l
total 1
-rwxrwxrwx 1 chris chris 128 Mar  5 13:45 GPT.INI
drwxrwxrwx 1 chris chris   0 Feb  2 13:07 Machine
drwxrwxrwx 1 chris chris   0 Feb  2 13:07 User

So I already own those files and folders, without having to change anything.

Chmod (this Tutorial's subject) and chown are designed to be able to change the defaults of user access as part of a secure plan by the Administrator, as well as, in the case of chown, modifying downloaded files to make them executable.

Again as Rob has said, in 2013,

chmod 777 mydoc.txt read, write, execute for all! (may not be the best plan in the world...)

Whatever works for you with fstab, though, is great, it is a very useful file.

Cheers

Chris Turner
wizardfromoz
 

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
7,802
Reaction score
6,628
Credits
28,794
setuid

Welcome to linux.org @shadow543 :). Google under

linux srwxrwxr-x

... and you will find some good reading.

Cheers

Chris Turner
wizardfromoz
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
4,996
Reaction score
3,642
Credits
36,416
how to change a file's owner like i create a file but i want to change file ownership
With the chown command, try man chown.
Code:
EXAMPLES
       chown root /u
              Change the owner of /u to "root".

       chown root:staff /u
              Likewise, but also change its group to "staff".

       chown -hR root /u
              Change the owner of /u and subfiles to "root".
 

Harish Rathaur

New Member
Joined
Apr 23, 2021
Messages
5
Reaction score
1
Credits
30
With the chown command, try man chown.
Code:
EXAMPLES
       chown root /u
              Change the owner of /u to "root".

       chown root:staff /u
              Likewise, but also change its group to "staff".

       chown -hR root /u
              Change the owner of /u and subfiles to "root".
Thank you so much it is very help full for me.
thanks again
 

Bharghav

New Member
Joined
Sep 21, 2021
Messages
1
Reaction score
1
Credits
10
This would help someone what exactly the numbers are in permissions,
so 4 in binary format is represented as 100 and 2 is 010 and 1 is 001.
What this means? Consider 'r', 'w', 'x' you either want them set or not set i.e., in binary digit representation it is either 0 or 1.
Therefore, when we want a file to have permission for any user group,
if it is 'rwx' => 111 ( set , set, set) => 100 + 010 + 001 => 4 + 2 + 1 => 7
Inturn 7 in binary representation is 111 = 1*2^2 + 1*2^1 + 1*2^0 = 7

'rw-' = 110 = 100 + 010 + 000 = 4+2 = 6
'r-x' = 101 = 100 + 000 + 001 = 4 + 1 = 5
'-wx' = 011 = 000 + 010 + 001 = 3
and similarly other combinations.

Hope this helps.
 
Joined
Oct 3, 2021
Messages
1
Reaction score
0
Credits
6
I just wanna know for a small query that is it possible to change permission out of directory? (i.e: Software and as well as others staff)
 

mrp

New Member
Joined
Oct 19, 2021
Messages
1
Reaction score
1
Credits
6
day 1 and I learnt a lot from first lesson itself, post and comments are very helpful.
 

frenchthomas

New Member
Joined
Jun 13, 2022
Messages
3
Reaction score
0
Credits
25
Hey, I would like to grant myself permission to /opt/
so I wrote
chmod 777 /opt/
but It outputs
chmod: /opt/: Operation not permitted
I really don't care about security so it would be nice if I could grant everyone full access to everyfile
 

rajatkm93

New Member
Joined
Jun 19, 2022
Messages
6
Reaction score
0
Credits
41
I have one doubt: Lets say I have created a file with name abc.txt and it has default permission as _rwxr_xr_x. So, if I want change it in to a directory (drwxr_xr_x) using Chmod, is it possible to change the directory flag or not?
 

rajatkm93

New Member
Joined
Jun 19, 2022
Messages
6
Reaction score
0
Credits
41
What is 'S' and 'l' in below file permission?

(I know that similar question already asked in this thread but that 'S' is in directory flag place, however in this case it is in place of execution flag)

1656054343959.png
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
7,432
Reaction score
6,405
Credits
60,265
The l is a symbolic link and the s is the setuid bit. If you don't know what those are, search for those exact phrases and someone'll have explained them better than I will.
 

SlowCoder

Gold Member
Gold Supporter
Joined
May 2, 2022
Messages
456
Reaction score
316
Credits
3,611
Basically what KGIII said. The l (lowercase L) means it's a symbolic link. Symbolic links are a pointer that points to the actual file/directory, sort of like a shortcut in Windows.

The s means the setuid bit is set. When you set the setuid bit on an executable file, the file will be executed as if the owner (in the case above, root) called it, permissions included. There is also a setguid bit, which executes under the owned group. Powerful, but potentially dangerous functionality, so take caution.
 

appie

New Member
Joined
Aug 3, 2022
Messages
10
Reaction score
4
Credits
58
Hi there,

I am newbie here and started just learning Linux system. When I removed this "x" permission from a file (text file) I still can execute that files, may i know why?
 

appie

New Member
Joined
Aug 3, 2022
Messages
10
Reaction score
4
Credits
58
Oh... Got the point now... it is working now.
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top