LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 11-11-2016, 02:11 PM   #1
agarwaldvk
LQ Newbie
 
Registered: Oct 2016
Posts: 27

Rep: Reputation: Disabled
Are the changes made using chmod and chown permanent or persistent after reboot?


Hi Everyone


I understand that we can make changes to the file and directory permissions including their ownership using chmod and chown commands.

However, could someone please advise/confirm if these changes made by the above commands are permanent. In other words are these changes persistent after reboot of the machine? If not, is there a way to realize this?


Best regards


Deepak
 
Old 11-11-2016, 02:22 PM   #2
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,572
Blog Entries: 19

Rep: Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451
Yes, they are permanent. The ownership and permissions of a file are stored in the file's inode. They are permanent properties of the file, just like the file type or the creation date. It's worth pointing out that ownership is stored as the UID number, not the name. Software such as ls translates it into a name for display.
 
Old 11-11-2016, 02:30 PM   #3
agarwaldvk
LQ Newbie
 
Registered: Oct 2016
Posts: 27

Original Poster
Rep: Reputation: Disabled
Hi hazel


Thanks for that. That would make life a lot easier for me because from what I had read and interpreted, I believed these changes are only live until the current session and die out on reboot.


Good-O.

I will have a couple of follow up questions as separate threads as I need to get some of file and directory permissions right.


Best regards


Deepak
 
Old 11-11-2016, 02:40 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Some exploratory commands to look at permissions of a file:

Code:
[root@centos01 ~]# stat asdf
  File: ‘asdf’
  Size: 520       	Blocks: 8          IO Block: 4096   regular file
Device: fd01h/64769d	Inode: 268197      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-11-04 15:57:22.396000000 +0000
Modify: 2016-10-31 19:22:37.986000000 +0000
Change: 2016-10-31 19:22:37.986000000 +0000
 Birth: -

[root@centos01 ~]# lsattr asdf
-------------e-- asdf

[root@centos01 ~]# ls -ialh asdf
268197 -rw-r--r-- 1 root root 520 Oct 31 19:22 asdf
 
Old 11-11-2016, 10:58 PM   #5
agarwaldvk
LQ Newbie
 
Registered: Oct 2016
Posts: 27

Original Poster
Rep: Reputation: Disabled
Hi szboardstretcher


Thanks for that info. I didn't know about these but I will play around with these commands to get better understanding of the available commands in linux and what information I can get about my files and directories from using them.



Best regards


Deepak
 
Old 11-12-2016, 06:53 AM   #6
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Where did you read that the changes are not permanent and which distribution are you using? There's the possibility that the author suggesting that the change sare not permanent was referring to a "live" distribution or similar -- otherwise they should be beaten to death with a clue stick.
 
1 members found this post helpful.
Old 11-12-2016, 03:06 PM   #7
agarwaldvk
LQ Newbie
 
Registered: Oct 2016
Posts: 27

Original Poster
Rep: Reputation: Disabled
Hi


As I said, I didn't know this - it was just my interpretation of what I had online of what was suggested by some. That was the reason that I wanted to confirm on this forum.


Deepak
 
Old 11-13-2016, 05:09 AM   #8
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by agarwaldvk View Post
from what I had read and interpreted, I believed these changes are only live until the current session and die out on reboot.
When you make a change with chown or chmod the changes will persist - except in the case of a live session (live DVD or USB).
Changes are not preserved in that case. (Depending on exactly WHAT you changed...)

Quote:
Originally Posted by hazel View Post
Yes, they are permanent. The ownership and permissions of a file are stored in the file's inode. They are permanent properties of the file, just like the file type or the creation date. It's worth pointing out that ownership is stored as the UID number, not the name. Software such as ls translates it into a name for display.
...another very accurate and well-said post by hazel.

I would like to throw a wrench into the gears, with the only example where that does not APPEAR to hold true.

EXAMPLE: Create a partition with an ext filesystem (either on a hard drive or USB drive). When I connect my USB drive, /dev/sdc, which has one ext partition, it is mounted at /media/dan/8GBPatriot
I enter the command:
Code:
sudo chown -R dan:dan /media/dan/8GBPatriot/
Then I create a mount point with the command:
Code:
sudo mkdir /mnt/DATA
Obviously, the DATA directory I created is owned by root...
dan@skynet1 ~ $ ls -la /mnt
total 12K
drwxrwxrwt 3 dan dan 4.0K Nov 13 04:46 ./
drwxr-xr-x 25 root root 4.0K Nov 11 22:04 ../
drwxr-xr-x 2 root root 4.0K Nov 13 04:46 DATA/

I then unmount my usb drive:
Code:
sudo umount /media/dan/8GBPatriot
and mount it at /mnt/DATA:
Code:
sudo mount /dev/sdc1 /mnt/DATA
The ownership of /mnt/DATA has magically changed from root to dan!

dan@skynet1 ~ $ ls -la /mnt
total 12
drwxrwxrwt 3 dan dan 4096 Nov 13 04:46 .
drwxr-xr-x 25 root root 4096 Nov 11 22:04 ..
drwxrwxrwt 5 dan dan 4096 Nov 11 22:06 DATA

The explanation for that is in the mechanics of the mount process. When you mount a partition to a directory, the properties of the directory are replaced by the properties (ownership and permissions) of the filesystem you mounted. When you unmount, the original properties return.

So the moral of the story is that ownership and permissions are permanent - except when they aren't...

Last edited by TxLonghorn; 11-13-2016 at 05:14 AM.
 
Old 11-13-2016, 06:28 AM   #9
Dave Lerner
Member
 
Registered: May 2005
Location: Florida, USA
Distribution: Pop_OS, Xubuntu
Posts: 152

Rep: Reputation: 44
Another exception, which is probably obvious, would be files that get recreated on each boot, such as those in /tmp.
 
Old 11-13-2016, 09:16 AM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by TxLonghorn View Post
The explanation for that is in the mechanics of the mount process. When you mount a partition to a directory, the properties of the directory are replaced by the properties (ownership and permissions) of the filesystem you mounted. When you unmount, the original properties return.
The properties are not changed, just hidden. Everything about the mount point directory, including its contents, is hidden while another filesystem is mounted there. All you see there is the root inode of the mounted filesystem. It's like putting a sticker with a new address over the old address printed on an envelope. All you see is the new address -- until you peel off the sticker (unmount the filesystem).

The original mount point directory is still there unchanged, and there are actually ways to "peek under the sticker" and see it. (See the "--bind" option in the mount command.)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
chmod and chown not working NirvanaII Mandriva 11 12-06-2008 08:08 PM
chown v/s chmod justmovedtolinux Linux - Newbie 3 10-02-2008 06:43 AM
chown and chmod specialized Linux - Hardware 9 04-04-2006 09:26 PM
making chmod permanent Beckerjr Linux - General 5 05-11-2005 12:08 PM
chmod/chown and folders :) chibi Linux - Newbie 2 04-28-2005 04:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 02:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration