Understanding Files and Meta-level Information in Computing

files files a stream of bytes everything is a file l.w
1 / 25
Embed
Share

Dive into the world of files, bytes, and meta-level information in computing. Learn about the diverse types of files, their representation, and how permissions impact file access. Discover tools like chmod for changing file permissions and gain insights into meta-level data associated with files.

  • Computing
  • Files
  • Permissions
  • Meta-data
  • Bytes

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Files Files (a stream of bytes everything is a file) before moving on to more representations here is a little deeper look into files and a few tools you will need

  2. files can hold/represent image, email, audio, video, powerpoint, text, all the stuff/data we use the computer to manage data These bytes make up machine code, also called a: program/app/executable/a.out/application files Executable (fyi, this is not source code) A set of bytes I can give to the cpu to run Dance to this tune and what the computer does will make sense concept We also use files to represent hardware your main memory, terminal window, gps sensor, etc and stuff a process, network connection, compiler option, etc

  3. generic stuff which applies to all files meta-level information for files (information about the file, which is not in the file)

  4. Files have meta-level information Meta-level information Name User id of owner Group id of owner Size in bytes Permissions Times last access last modified last status change //.xyz and everything else is by convention //unique on the system //grouping of users //some program use unit of K //security, who can do what with the file //can be changed by anyone who can write the file

  5. The program stat(1) and kernel call stat(2) will give you the meta level information for any given file

  6. How permissions on files work Types of users, relative to a given file Owner Group World Types of Permissions read write execute - can read/copy it - can change it, and some of its meta data - can run a program/shell script; for directories it means permission to traverse

  7. chmod change permissions on a file File on which you wish to set them Permissions you want to set: chmod 754 filename Owner group world Each is an octal digit 111 101 100 The bits of which correspond to the three Types of permissions, read, write, execute

  8. chmod 754 xyz read write execute Owner 1 1 1 = 07 owner gets read,write,execute Group 1 0 1 = 05 group members get read, execute World 1 0 0 = 04 everyone else gets read only

  9. $ ls -l project1 - -rwxrwxrwx rwxrwxrwx. 1 rjoyce9 rjoyce9 0 Jan 24 16:06 project1 //this is 777 //this is 777 $ chmod 640 $ ls -l project1 - -rw rw- -r r----- -----. 640 project1 . 1 rjoyce9 rjoyce9 0 Jan 24 16:06 project1 $ chmod 750 project1 $ ls -l project1 - -rwxr rwxr- -x x--- ---. . 1 rjoyce9 rjoyce9 0 Jan 24 16:06 project1 $ chmod 400 project1 $ ls -l project1 - -r r-------- --------. . 1 rjoyce9 rjoyce9 0 Jan 24 16:06 project1

  10. There is a 4th octal digit which can be used for permissions: chmod 6755 filename Those 3 bits are the: userid bit - if set, when running a program you have the same privileges as the OWNER of the file containing the executable group id bit same as userID, but for the group sticky bit on directories, files within can only be changed by the owner of the file, the owner of the directory, or root (see ls ld /tmp). + other historical meanings There is another, more fine-grained, file access control scheme called Access Control Lists Access Control Lists which may or may not be enabled during a mount Both standard permissions and ACL ACL s can be used concurrently.

  11. Files have meta-level information Meta-level information Name //a file can be named anything, a file containing a jpeg image could //be named + ; the .jpg and similar suffixes are only by convention //do not embed space characters in file names, since the shell uses //space to separate tokens //8.3 and everything else is by convention cat myPaper //print the file named myPaper to the terminal cat my Paper //print two files, one named my, one named Paper cat my Paper //but you can force it if need be save the effort and don t embed space(s) in file names (that includes tabs)

  12. The mv (move) command (which is also change name) MV(1) User Commands MV(1) NAME NAME mv - move (rename) files SYNOPSIS SYNOPSIS mv mv [OPTION]... [-T] SOURCE DEST mv mv [OPTION]... SOURCE... DIRECTORY mv mv [OPTION]... -t DIRECTORY SOURCE... DESCRIPTION DESCRIPTION Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY. Mandatory arguments to long options are mandatory for short options too. . . .

  13. The mv (move) command (which is also change name) MV(1) User Commands MV(1) NAME NAME mv - move (rename) files SYNOPSIS SYNOPSIS mv mv [OPTION]... [-T] SOURCE DEST mv mv [OPTION]... SOURCE... DIRECTORY mv mv [OPTION]... -t DIRECTORY SOURCE... DESCRIPTION DESCRIPTION Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY. Mandatory arguments to long options are mandatory for short options too. . . .

  14. $ ls $ touch abc $ ls abc $ mv abc xyz $ ls xyz ;show me the files in this directory ;there are none, create one named abc ;show me the files in this directory ;now there is one named abc ;change the name of abc to xyz ;show me the files in this directory why is it called move , instead of rename ?? because if the destination is a directory, it will move it there and keep the name the same; you can choose a new name, and/or a new location

  15. Files have meta-level information Meta-level information Name User id of owner Group id of owner Size in bytes Permissions Times last access last modified last status change //.xyz and everything else is by convention //unique on the system //grouping of users //some program use unit of K //security, who can do what with the file //can be changed by anyone who can write the file

  16. The chown (change owner) command CHOWN(1) User Commands CHOWN(1) NAME NAME chown - change file owner and group SYNOPSIS SYNOPSIS chown chown [OPTION]... [OWNER][:[GROUP]] FILE... chown chown [OPTION]... --reference=RFILE FILE... DESCRIPTION DESCRIPTION This manual page documents the GNU version of chown group ownership of each given file. If only an owner (a user name or numeric user ID) is given, that user is made the owner of each given file, and the files' group is not changed. If the owner is followed by a colon and a group name (or numeric group ID), with no spaces between them, the group ownership of the files is changed as well. If a colon but no group name follows the user name, that user is made the owner of the files and the group of the files is changed to that user's login group. If the colon and . . . chown. chown chown changes the user and/or

  17. show me the files in this directory -l means long , give me the meta info for the file along with the name $ ls -l -rw-r--r-- 1 root root 0 Jan 26 13:42 xyz $ chown rick xyz $ ls -l -rw-r--r-- 1 rick root 0 Jan 26 13:42 xyz this is the name of the user which owns this file

  18. Files have meta-level information Meta-level information Name User id of owner Group id of owner Size in bytes Permissions Times last access last modified last status change //.xyz and everything else is by convention //unique on the system //grouping of users //some program use unit of K //security, who can do what with the file //can be changed by anyone who can write the file

  19. The chgrp (change group) command CHGRP(1) User Commands CHGRP(1) NAME NAME chgrp - change group ownership SYNOPSIS SYNOPSIS chgrp chgrp [OPTION]... GROUP FILE... chgrp chgrp [OPTION]... --reference=RFILE FILE... DESCRIPTION DESCRIPTION Change the group of each FILE to GROUP. With -- FILE to that of RFILE. --reference reference, change the group of each - -c c, -- --changes changes like verbose but report only when a change is made

  20. show me the files in this directory -l means long , give me the meta info for the file along with the name $ ls -l -rw-r--r-- 1 root root 0 Jan 26 13:42 xyz $ cgrp rick xyz $ ls -l -rw-r--r-- 1 root rick 0 Jan 26 13:42 xyz this is the name of the group associated with this file

  21. Files have meta-level information Meta-level information Name User id of owner Group id of owner Size in bytes Permissions Times last access last modified last status change //.xyz and everything else is by convention //unique on the system //grouping of users //some program use unit of K //security, who can do what with the file //can be changed by anyone who can write the file //atime //mtime //ctime

  22. $ ls -l total 0 -rw-r--r-- 1 root rick 0 Jan 26 13:42 xyz $ the long listing shows mtime, last time modified

  23. $ stat xyz File: xyz Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: fc01h/64513d Inode: 260013 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 1066/ rick) Access: 2023-01-26 13:42:56.972276962 +0000 Modify: 2023-01-26 13:42:56.972276962 +0000 Change: 2023-01-26 13:53:20.080315665 +0000 Birth: - stat shows them all

  24. The touch (change timestamps) command TOUCH(1) User Commands TOUCH(1) NAME NAME touch - change file timestamps SYNOPSIS SYNOPSIS touch touch [OPTION]... FILE... DESCRIPTION DESCRIPTION Update the access and modification times of each FILE to the current time. A FILE argument that does not exist is created empty, unless - -c c or - -h h is supplied. A FILE argument string of - is handled specially and causes touch to change the times of the file associated with standard output. Mandatory arguments to long options are mandatory for short options too. - -a a change only the access time

  25. about the Manual (man) try: $ man man sections of the manual: 1 Executable programs or shell commands 2 System calls (functions provided by the kernel) 3 Library calls (functions within program libraries) 4 Special files (usually found in /dev) 5 File formats and conventions eg /etc/passwd 6 Games 7 Miscellaneous (including macro packages and conventions), e.g. man 8 System administration commands (usually only for root) 9 Kernel routines [Non standard] man(7), groff groff(7)

Related


More Related Content