File Attributes: Difference between revisions
From Leo's Notes
This page was last edited on 11 June 2020, at 22:07.
Created page with "Unix file attributes can be listed with the {{stat}} utility. {{highlight|lang=terminal|code= # stat /some/file File: ‘/some/file’ Size: 13857688196 Blocks: 27066..." |
mNo edit summary |
||
| Line 1: | Line 1: | ||
Unix file attributes can be listed with the {{stat}} utility. | Unix file attributes can be listed with the {{code|stat}} utility. | ||
{{highlight|lang=terminal|code= | {{highlight|lang=terminal|code= | ||
Revision as of 22:07, 11 June 2020
Unix file attributes can be listed with the stat utility.
# stat /some/file
File: ‘/some/file’
Size: 13857688196 Blocks: 27066368 IO Block: 16777216 regular file
Device: 2dh/45d Inode: 12331 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:unlabeled_t:s0
Access: 2018-09-06 17:30:48.650399353 -0600
Modify: 2018-09-01 22:26:44.904672188 -0600
Change: 2020-06-11 15:53:36.225415501 -0600
Birth: -
Use the following tools to modify:
| Tool | Example | |
|---|---|---|
| Permissions | chmod <permission>
|
# chmod 644 file.dat
# chmod u+rw file.dat
|
| Ownership | chown / chgrp
|
## Both
# chown user:group file.dat
## Or individually
# chown user file.dat
# chgrp group file.dat
|
| SELinux Context | chcon -R <context>
|
# chcon -R unconfined_u:object_r:user_home_t:s0 /home/user/.ssh/
|
| Access Time | touch -a -t YYYYMMDDhhmm.ss
|
## Set access time to Dec 26 2020 at 1:30:30PM
# touch -a -t 202012261330.30 /some/file
## Set a file based on a reference file
# touch -a -r reference.ext target.ext
|
| Modify Time | touch -m -t YYYYMMDDhhmm.ss
|
## Set modification time to Dec 26 2020 at 1:30:30PM
# touch -m -t 202012261330.30 /some/file
## Set a file based on a reference file
# touch -m -r reference.ext target.ext
|
| Change Time | ??? |