60 likes | 168 Views
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:
E N D
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: Chown is a command for system that changes(변경)the owner(소유자)or group(그룹)of a file. Systax Chown [-R ] new-owner filenames
STAT • Definition: • Stat display file or file system status. • Syntax: • Stat [ option ] file…
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