[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"academy-blog-translations-none":3,"academy-blogs-en-1-1-all-go-file-permissions-all--*":4},{},{"data":5,"meta":74},[6],{"categoryId":7,"collectionId":8,"collectionName":9,"content":10,"createBy":11,"createDate":12,"created":13,"description":14,"expand":15,"group":66,"id":66,"image":67,"imageAlt":68,"imagePath":69,"keywordIds":70,"langId":62,"publishDate":46,"scheduleDate":12,"slug":71,"status":28,"title":68,"updateBy":11,"updated":72,"views":73},"wqxt7ag2gn7xcmk","sclblg987654321","school_blog","\u003Cp>\u003Cspan style=\"font-size:20px;\">\u003Cstrong>Go and File Permissions - Easily Manage File Access!\u003C\u002Fstrong>\u003C\u002Fspan>\u003C\u002Fp>\u003Cp>Have you ever wondered what file permissions like 0644 or 0755 mean? Today, we will dive deep into this topic.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>\u003Cspan style=\"font-size:18px;\">\u003Cstrong>What are File Permissions?\u003C\u002Fstrong>\u003C\u002Fspan>\u003Cbr>File permissions refer to the rights that indicate who can access or use a file. For example:\u003Cbr>🦿 Who can read the data in the file?\u003Cbr>🦿 Who can modify or write data to the file?\u003Cbr>🦿 Who can execute this file? (e.g., in cases where the file is a program)\u003Cbr>In Unix\u002FLinux systems and Go, we use numbers to indicate what actions can be performed by whom, such as 0644 or 0755.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>\u003Cspan style=\"font-size:18px;\">\u003Cstrong>Structure of File Permission Numbers\u003C\u002Fstrong>\u003C\u002Fspan>\u003Cbr>The file access permission numbers in Go use 3 digits, each digit representing different groups:\u003Cbr>1. Owner – The person who created the file.\u003Cbr>2. Group – People in the same group as the owner.\u003Cbr>3. Others – People who are neither the owner nor in the same group.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>\u003Cspan style=\"font-size:18px;\">\u003Cstrong>What Does Each Digit Mean?\u003C\u002Fstrong>\u003C\u002Fspan>\u003Cbr>To define permissions, we use the numbers 4, 2, and 1:\u003Cbr>🦿 4 means Read (can read)\u003Cbr>🦿 2 means Write (can write\u002Fedit)\u003Cbr>🦿 1 means Execute (can run, for program files)\u003Cbr>The combination of these numbers indicates what can be done, for example:\u003Cbr>🦿 7 = 4 + 2 + 1 = can read, write, and execute (rwx)\u003Cbr>🦿 6 = 4 + 2 = can read and write but cannot execute (rw-)\u003Cbr>🦿 4 = can only read (r--).\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>\u003Cspan style=\"font-size:18px;\">\u003Cstrong>Simple Examples of Permission Numbers\u003C\u002Fstrong>\u003C\u002Fspan>\u003Cbr>🦿 0644: The file owner (Owner) can read and write, while the group (Group) and others (Others) can only read.\u003Cbr>🦿 0755: The file owner (Owner) can read, write, and execute, while the group and others can read and execute but cannot write.\u003Cbr>🦿 0700: The file owner (Owner) can read, write, and execute, while the group and others cannot access this file.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>\u003Cspan style=\"font-size:18px;\">\u003Cstrong>Setting Permissions in Go\u003C\u002Fstrong>\u003C\u002Fspan>\u003Cbr>You can use the ioutil.WriteFile() command to set permissions when creating a file.\u003Cbr>In this example, 0644 means the file owner can read and write, while others can only read.\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext\">package main\r\n\r\nimport (\r\n    \"io\u002Fioutil\"\r\n    \"log\"\r\n)\r\n\r\nfunc main() {\r\n    content := []byte(\"Hello, Permissions!\")\r\n    err := ioutil.WriteFile(\"example.txt\", content, 0644) \u002F\u002F อ่านได้ทุกคน แก้ไขได้เฉพาะเจ้าของ\r\n    if err != nil {\r\n        log.Fatal(err)\r\n    }\r\n}\r\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>\u003Cspan style=\"font-size:18px;\">\u003Cstrong>Summary\u003C\u002Fstrong>\u003C\u002Fspan>\u003Cbr>Permission 4 means can read.\u003Cbr>Permission 2 means can write.\u003Cbr>Permission 1 means can execute (for program files).\u003Cbr>The 3-digit number (e.g., 644 or 755) separates permissions into 3 groups: Owner, Group, and Others.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>If you want to try testing, set a file with permission 0755 and check if you can open the file. Then try setting it to 0700 and test again to see the difference!\u003C\u002Fp>","r8v4zgsahjuwpeb","","2026-03-04 08:33:59.307Z","Learn how to set file access permissions in Go using numeric values, converting read, write, and execute permissions into permission codes.",{"categoryId":16,"keywordIds":30,"langId":57},{"blogIds":17,"collectionId":18,"collectionName":19,"createBy":20,"created":21,"id":7,"image":22,"imageAlt":12,"imagePath":23,"label":24,"name":25,"priority":26,"publishDate":27,"scheduleDate":12,"status":28,"updateBy":20,"updated":29},[],"sclcatblg987654321","school_category_blog","oplnwslvnmx5axc","2026-03-04 08:33:53.210Z","59ty92ns80w_15oc1implw.png","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclcatblg987654321\u002Fwqxt7ag2gn7xcmk\u002F59ty92ns80w_15oc1implw.png",{"en":25,"th":25},"Golang The Series",1,"2026-03-16 04:39:38.440Z","Publish","2026-03-17 06:07:59.733Z",[31,38,43,48,52],{"collectionId":32,"collectionName":33,"createBy":12,"created":34,"id":35,"publishDate":36,"scheduleDate":12,"status":28,"title":37,"updateBy":12,"updated":34},"sclkey987654321","school_keyword","2026-03-04 08:31:27.403Z","v9recrqz2zy57go","2025-02-04 03:27:30.534Z","coding",{"collectionId":32,"collectionName":33,"createBy":12,"created":39,"id":40,"publishDate":41,"scheduleDate":12,"status":28,"title":42,"updateBy":12,"updated":39},"2026-03-04 08:20:33.316Z","ln1ntwattzmxo0o","2026-01-14 05:00:33.957Z","programming",{"collectionId":32,"collectionName":33,"createBy":12,"created":44,"id":45,"publishDate":46,"scheduleDate":12,"status":28,"title":47,"updateBy":12,"updated":44},"2026-03-04 08:33:54.631Z","kdd19lomeac0os3","2025-01-27 04:35:29.822Z","file access permissions",{"collectionId":32,"collectionName":33,"createBy":12,"created":49,"id":50,"publishDate":46,"scheduleDate":12,"status":28,"title":51,"updateBy":12,"updated":49},"2026-03-04 08:33:56.297Z","bc4kmgt2hdjtmln","File Permissions",{"collectionId":32,"collectionName":33,"createBy":12,"created":53,"id":54,"publishDate":55,"scheduleDate":12,"status":28,"title":56,"updateBy":12,"updated":53},"2026-03-04 08:20:11.547Z","ey3puyme01a9bsw","2026-01-28 00:54:28.566Z","Go",{"code":58,"collectionId":59,"collectionName":60,"createAt":61,"id":62,"is_default":63,"language":64,"updateAt":65},"en","pbc_1989393366","locale","2026-01-22 11:00:02.726Z","qv9c1llfov2d88z",false,"English","2026-02-05 10:48:59.032Z","2lebgsr2mzotrs4","26_1_h964mzasgl.webp","EP.12.1 Go and File Permissions - Easily Manage File Access!","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclblg987654321\u002F2lebgsr2mzotrs4\u002F26_1_h964mzasgl.webp",[35,40,45,50,54],"go-file-permissions","2026-03-04 08:33:59.670Z",283,{"pagination":75},{"page":26,"pageSize":26,"pageCount":26,"total":26}]