1 / 6

Linux Programming Example: 3 - 7

Linux Programming Example: 3 - 7. 컴퓨터공학 2007242158 펠네르 파울로. Linux Programming. Contents - CHOWN – How to use ( Method ) STAT – How to use ( Method ) Example: 3 - 7 Explanation. CHOWN. Definition:

morna
Download Presentation

Linux Programming Example: 3 - 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linux Programming Example: 3 - 7 컴퓨터공학 2007242158 펠네르 파울로

  2. Linux Programming • Contents • - CHOWN – How to use ( Method ) • STAT – How to use ( Method ) • Example: 3 - 7 Explanation

  3. CHOWN Definition: Chown is a command for system that changes(변경)the owner(소유자)or group(그룹)of a file. Systax Chown [-R ] new-owner filenames

  4. STAT • Definition: • Stat display file or file system status. • Syntax: • Stat [ option ] file…

  5. Programming explanation #include <sys/types.h> #include <sys/stat.h> main(argc,argv) intargc; char *argv[]; { struct stat stbuf; int stat(), chown(); if(argc < 3) { printf("Usage: %s other-file your-file\n",argv[0]); exit(1); } if(stat(argv[1], &stbuf) == -1) { perror(argv[2]); exit(2); } if(chown(argv[2], stbuf.st_uid, stbuf.st_gid) == -1) { perror(argv[2]); exit(3); } exit(0); } Display file or system status Command for system that changes the owner of a file Print a system error message User ID of owner Group ID of owner

  6. Thank you

More Related