{"id":1636,"date":"2023-11-01T10:06:08","date_gmt":"2023-11-01T10:06:08","guid":{"rendered":"https:\/\/matob.web.id\/random\/?p=1636"},"modified":"2023-11-01T10:06:08","modified_gmt":"2023-11-01T10:06:08","slug":"chown-linux","status":"publish","type":"post","link":"https:\/\/matob.web.id\/random\/chown-linux\/","title":{"rendered":"What is CHOWN Linux and How to Use It"},"content":{"rendered":"<p>In this article, we will discuss the differences between CHMOD and <a href=\"https:\/\/matob.web.id\/random\/technology\/chown-linux\">CHOWN<\/a> and how to use them.\u00a0In addition, there are also some things you need to know why CHMOD and CHOWN are important.\u00a0Before that, you can first read a brief explanation about Linux and the command text.<\/p>\n<p>Linux is an operating system that is already familiar today.\u00a0These operating systems mostly use text commands to install, move and copy files, or operate them.\u00a0There are many basic linux commands, but there are two commands that are often used that are important to know, namely CHMOD and CHOWN.<\/p>\n<p>CHMOD and CHOWN are widely used to set permissions and ownership of files and folders in Linux.\u00a0At first glance, the two commands have the same function, but they don&#8217;t.\u00a0In order to more clearly understand the difference between CHMOD and CHOWN, we will discuss it in this article in full.<\/p>\n<h2><strong>Basic Access and Ownership Rights on Linux<\/strong><\/h2>\n<p>Linux is an operating system similar to Unix in that every file and folder has an\u00a0<strong><em>owner<\/em><\/strong>\u00a0and\u00a0<strong><em>group<\/em><\/strong>\u00a0.\u00a0While\u00a0<strong><em>others is<\/em><\/strong>\u00a0used for users who are not the owner and are not in the same group.<\/p>\n<p>All files in Linux have three types of users (sometimes called classes) above.\u00a0The three classes describe what commands can\/can be applied to a file.<\/p>\n<figure>\n<table>\n<tbody>\n<tr>\n<td><strong>owner<\/strong><\/td>\n<td>All users who create and own files\/directories.<\/td>\n<\/tr>\n<tr>\n<td><strong>group<\/strong><\/td>\n<td>All users are members of the same group.<\/td>\n<\/tr>\n<tr>\n<td><strong>others<\/strong><\/td>\n<td>All other users in the system who are not owners or members of a group.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>Commands that can be done in Linux are:\u00a0<strong>read<\/strong>\u00a0(the ability to open and view files),\u00a0<strong>write<\/strong>\u00a0(the ability to open and modify files), and\u00a0<strong>execute<\/strong>\u00a0(the ability to execute program files).<\/p>\n<p>So in the management of permissions (access rights or ownership) in Linux.\u00a0All\u00a0<strong><em>owner<\/em><\/strong>\u00a0,\u00a0<strong><em>group<\/em><\/strong>\u00a0, and\u00a0<strong><em>others<\/em><\/strong>\u00a0classes\u00a0can\u00a0<em>read<\/em>\u00a0,\u00a0<em>write<\/em>\u00a0, or\u00a0<em>execute.\u00a0<\/em>It&#8217;s just a matter of how we manage it on a file or folder.<\/p>\n<h2><strong>Difference between CHMOD and CHOWN<\/strong><\/h2>\n<p>In simple terms, there is the most basic difference between chmod and chown, which is based on their function.<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-1638\" src=\"https:\/\/matob.web.id\/random\/wp-content\/uploads\/sites\/2\/2021\/12\/CHOWN-LINUX-COMMAND.jpg\" alt=\"CHOWN\" width=\"528\" height=\"346\" title=\"\"><\/p>\n<p><strong>Chown<\/strong>\u00a0is a Linux command that comes from the abbreviation of the\u00a0<strong><em>ch<\/em><\/strong><em>\u00a0ange\u00a0<\/em><strong><em>own<\/em><\/strong><em>\u00a0er<\/em>\u00a0(change mode).\u00a0This command is used to change the ownership of a file or folder to a specific user.\u00a0The goal is that only the user who owns the file or folder can open it.<\/p>\n<p>For example, there is a folder or file named\u00a0<strong>A<\/strong>\u00a0which was previously owned by the <b>jaems <\/b>user\u00a0, then the chown command is executed and ownership is given to a new user named <b>james<\/b>. After being replaced, then folder A changed ownership to <strong>james<\/strong>.<\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-1639 aligncenter\" src=\"https:\/\/matob.web.id\/random\/wp-content\/uploads\/sites\/2\/2021\/12\/CHMOD-COMMAND.jpg\" alt=\"\" width=\"570\" height=\"372\" title=\"\"><\/p>\n<p><strong>Chmod<\/strong>\u00a0a Linux command whose name is derived from the word\u00a0<strong><em>ch<\/em><\/strong><em>\u00a0ange\u00a0<\/em><strong><em>mod<\/em><\/strong><em>\u00a0e<\/em>\u00a0(change mode).\u00a0This command is used to change the mode of a file or folder.\u00a0There are three types of access rights that are usually used by\u00a0<strong>chmod<\/strong>\u00a0and their symbols, namely:<\/p>\n<ul>\n<li>r for read<\/li>\n<li>w for write<\/li>\n<li>z to execute<\/li>\n<\/ul>\n<p>Generally when using the chmod command use a number to declare the desired permission type.<\/p>\n<figure>\n<table>\n<tbody>\n<tr>\n<td><strong>Numerical<\/strong><\/td>\n<td><strong>Character<\/strong><\/td>\n<td><strong>Explanation<\/strong><\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>\u2014<\/td>\n<td>No permission<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>\u2013x<\/td>\n<td>Execute<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>-w-<\/td>\n<td>Write<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>-wx<\/td>\n<td>Write and Execute<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>r\u2013<\/td>\n<td>Read<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>rx<\/td>\n<td>Read and Execute<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>rw-<\/td>\n<td>Read and Write<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>rwx<\/td>\n<td>Read, Write, and Execute<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>Or 7 comes from 1+2+4 which means 1 (execute), 2 (write), 4 (read) so 7 becomes (execute, write, and read).<\/p>\n<p>To make it easier to understand the difference between chmod and chown, here are some examples of using chmod and chown in file management on Linux.<\/p>\n<h2><strong>How to Use CHMOD and CHOWN<\/strong><\/h2>\n<p><img decoding=\"async\" class=\" wp-image-1640 aligncenter\" src=\"https:\/\/matob.web.id\/random\/wp-content\/uploads\/sites\/2\/2021\/12\/CHOWN-CHMOD-LINUX.jpg\" alt=\"\" width=\"645\" height=\"363\" title=\"\" srcset=\"https:\/\/matob.web.id\/random\/wp-content\/uploads\/sites\/2\/2021\/12\/CHOWN-CHMOD-LINUX.jpg 1280w, https:\/\/matob.web.id\/random\/wp-content\/uploads\/sites\/2\/2021\/12\/CHOWN-CHMOD-LINUX-768x432.jpg 768w\" sizes=\"(max-width: 645px) 100vw, 645px\" \/><\/p>\n<p>The chown and chmod commands can be run using the <a href=\"https:\/\/matob.web.id\/random\/tips\/check-ubuntu-version-using-terminal\/\">Linux Terminal<\/a>.\u00a0These two commands can only be executed by the\u00a0<strong>root\u00a0<\/strong><strong>user<\/strong>\u00a0or\u00a0<strong>super user<\/strong>\u00a0.\u00a0You can view the ownership and user owners of a file using the\u00a0<strong>ls -l<\/strong>\u00a0or ll\u00a0commands\u00a0.<\/p>\n<p>The results will be displayed in a format like this:<\/p>\n<blockquote><p><em>drwxrwxr-x 2 antvps antvps 4090 Dec 3 07:16 folderC<\/em><\/p><\/blockquote>\n<figure>\n<table>\n<tbody>\n<tr>\n<td><em>drwxrwxr-x<\/em><\/td>\n<td>This section displays the permissions (permissions) of a file or folder.\u00a0The letter d in front means that it is a directory.\u00a0If the file has no leading letters, for example like this -rw-rwx-wxrwx is the type of permission that applies to the file or folder.<\/p>\n<p>The initial \u201crwx\u201d indicates the permissions for the\u00a0<strong>user<\/strong>\u00a0.\u00a0&#8220;Rwx&#8221; both indicate the permissions for\u00a0<strong>the group<\/strong>\u00a0owner, and rx show user type permissions for\u00a0<strong>others<\/strong>\u00a0.<\/td>\n<\/tr>\n<tr>\n<td><em>2<\/em><\/td>\n<td>Number of hard links.\u00a0Usually a hard link is an additional name for a file.<\/td>\n<\/tr>\n<tr>\n<td><em>antvps<\/em><\/td>\n<td>Is the user name information owner of the file or folder.<\/td>\n<\/tr>\n<tr>\n<td><em>antvps<\/em><\/td>\n<td>Is the group name information of a file or folder.<\/td>\n<\/tr>\n<tr>\n<td><em>4096<\/em><\/td>\n<td>Displays the file size in bytes.\u00a0You can use the -h option to display sizes in other forms<\/td>\n<\/tr>\n<tr>\n<td><em>Dec 3 07:16<\/em><\/td>\n<td>The last date the file was modified.<\/td>\n<\/tr>\n<tr>\n<td><em>FolderC<\/em><\/td>\n<td>File or folder name.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h2><strong>CHMOD to Change File and Folder Permissions<\/strong><\/h2>\n<p>The command used to change permissions in <a href=\"https:\/\/www.linux.org\/\" target=\"_blank\" rel=\"noopener\">Linux<\/a> is very simple.\u00a0Chmod has the following format:<\/p>\n<blockquote><p><em>$ chmod [permissions] [files]<\/em><\/p><\/blockquote>\n<p>\u201c[permission]\u201d can be numeric notation, which is the best format for changing permissions for all types of users.<\/p>\n<p>For example, if you want to change the permissions of folderC to \u201cdrwx-r\u2013rw-\u201d, the command used is like this:<\/p>\n<blockquote><p><em>$ chmod 746 folderC<\/em><\/p><\/blockquote>\n<p>Or if changing the file to<\/p>\n<blockquote><p><em>$ chmod 746 fileC.txt<\/em><\/p><\/blockquote>\n<p>\u201c[permission]\u201d can also use symbol notation, which is easier to use to modify certain types of users.<\/p>\n<p>For example, if you want to change the permissions of user (u) to \u201crwx\u201d, group (g) to \u201crw\u201d, and others (o) to \u201crw\u201d, the command used is like this:<\/p>\n<blockquote><p><em>$ chmod u=rwx fileC.txt<\/em><\/p>\n<p>next<\/p>\n<p><em>$ chmod g=rw fileC.txt<\/em><\/p>\n<p><em>$ chmod o=rw fileC.txt<\/em><\/p><\/blockquote>\n<p>Or can use a single command line:<\/p>\n<blockquote><p><em>$ chmod u=rwx,g=rw,o=rw fileC.txt<\/em><\/p><\/blockquote>\n<p>In certain cases, you want to add access rights for one of the users.\u00a0Examples of commands that can be used like this:<\/p>\n<blockquote><p><em>$ chmod u+x fileC.txt<\/em><\/p><\/blockquote>\n<p>The above command reads &#8216;add execute (x) in the fileC.txt file for the user.\u00a0Sedankan to eliminate can use a command like this:<\/p>\n<blockquote><p><em>$ chmod o-wx fileC.txt<\/em><\/p><\/blockquote>\n<p>Finally, if you want to change the permissions of the folder and all its contents, you can add a recursive option with the -R symbol in the command before executing it.\u00a0An example of the command is like this:<\/p>\n<blockquote><p><em>$ chmod -R 755 folderC<\/em><\/p><\/blockquote>\n<p>You can view information related to the chmod user using the \u201c\u00a0<strong><em>$\u00a0<\/em><\/strong><strong><em>man chmod<\/em><\/strong>\u00a0\u201d\u00a0command\u00a0.<\/p>\n<p>There are several chmod modes that are often used, namely chmod 644, chmod 777, chmod 755, and chmod 555.<\/p>\n<h4><strong>What Does CHMOD 644 Mean?<\/strong><\/h4>\n<p>These permissions are ideal for publicly accessible files because they balance flexibility with security.\u00a0Usually the chmod 644 setting is used for files on the website.\u00a0Setting file permissions to chmod 644 means that only the owner can access and modify the desired file.\u00a0While other users can only access it without being able to modify or even execute the file, including the owner of the file.<\/p>\n<h4><strong>What Does CHMOD 777 Mean?<\/strong><\/h4>\n<p>Setting permissions to chmod 77 means that all users can do whatever they want with the file.\u00a0This is very risky at the level of security, especially for files that are shared publicly such as on hosting.\u00a0In general, all users can access it, modify it, and even execute it on the system.<\/p>\n<h4><strong>What Does CHMOD 755 Mean?<\/strong><\/h4>\n<p>Setting permissions to chmod 755 is almost the same as chmod 644. The difference is that all users have access rights to execute files.\u00a0This is usually used for public folders that require commands to move from one directory to another.<\/p>\n<h4><strong>What Does CHMOD 555 Mean?<\/strong><\/h4>\n<p>Setting permissions to chmod 555 makes the file unmodifiable by all users except superuser.<\/p>\n<h2><strong>CHOWN to Change Ownership<\/strong><\/h2>\n<p>Chown is used to change the owner and group of files and folders.\u00a0In the example above, folderC is owned by the\u00a0<strong>antvps user<\/strong>\u00a0and\u00a0<strong>the\u00a0<\/strong><strong>antvps\u00a0<\/strong><strong>group<\/strong>\u00a0.\u00a0If you want to change it there are several commands you can use.<\/p>\n<p>Format of the &#8220;chown&#8221; command:<\/p>\n<blockquote><p><em>$ chown [owner\/group owner] [filename]<\/em><\/p><\/blockquote>\n<p>Then we see an example of the file format that appears via the ls -l command above.<\/p>\n<blockquote><p><em>drwxrwxr-x 2 antvps antvps 4090 Dec 3 07:16 folderC<\/em><\/p><\/blockquote>\n<p><strong>Changing Ownership<\/strong><\/p>\n<p>How to change ownership from antvps to root can be done using a command like this:<\/p>\n<blockquote><p><em>$ chown root folderC<\/em><\/p><\/blockquote>\n<p>The above command only changes the userowner, not the group owner.<\/p>\n<p><strong>Changing Group<\/strong><\/p>\n<p>If you want to change the group only, then the command used is like this:<\/p>\n<blockquote><p><em>$ chown :root folderC<\/em><\/p><\/blockquote>\n<p>The command above only changes the group owner, while the user owner remains.<\/p>\n<p><strong>Changing Ownership &amp; Group<\/strong><\/p>\n<p>Another example is changing the user owner and group owner in one command.<\/p>\n<blockquote><p><em>$ chown root:root folderC<\/em><\/p><\/blockquote>\n<p>When &#8220;enter&#8221; then folder C will change user owner and user group to &#8221;\u00a0<strong>root<\/strong>\u00a0&#8220;.\u00a0Complete information on how to use &#8220;chown&#8221; you can see using the &#8221;\u00a0<strong>man chown<\/strong>\u00a0&#8221;\u00a0command\u00a0.<\/p>\n<p>There are several chown options that are often used such as &#8221;\u00a0<strong>-c<\/strong>\u00a0&#8220;, &#8221;\u00a0<strong>-R<\/strong>\u00a0&#8220;, and &#8221;\u00a0<strong>-v<\/strong>\u00a0&#8220;.<\/p>\n<figure>\n<table>\n<tbody>\n<tr>\n<td>-c, \u2013changes<\/td>\n<td>Similar to verbose, but only when changes are made.<\/td>\n<\/tr>\n<tr>\n<td>-R, \u2013recursive<\/td>\n<td>Executes the command not only on the folder, but on all the files and folders in it.<\/td>\n<\/tr>\n<tr>\n<td>-v, \u2013verbose<\/td>\n<td>Displays all operations performed, both failed and changes made.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>The chown and chmod commands are very important to know, especially when it comes to files on websites.\u00a0Files on the website should be accessible only to certain files, for example index.html.<\/p>\n<p>If all files are open to public access rights, then all internet users can access those files online. Even though sometimes the files on the website are often important files and are quite dangerous if they are damaged or replaced by unknown users.<\/p>\n<p>However, if all file access rights are made private, the website cannot be accessed.<\/p>\n<p>Meanwhile, the difference between chown and chmod itself is in the function and how to use it.\u00a0You can use it according to the needs you want to do.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will discuss the differences between CHMOD and CHOWN and how to use them.\u00a0In addition, there are also some things you need to know why CHMOD and CHOWN are important.\u00a0Before that, you can first read a brief explanation about Linux and the command text. Linux is an operating system that is already [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1642,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[178],"class_list":["post-1636","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-linux-command"],"_links":{"self":[{"href":"https:\/\/matob.web.id\/random\/wp-json\/wp\/v2\/posts\/1636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matob.web.id\/random\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matob.web.id\/random\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matob.web.id\/random\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/matob.web.id\/random\/wp-json\/wp\/v2\/comments?post=1636"}],"version-history":[{"count":1,"href":"https:\/\/matob.web.id\/random\/wp-json\/wp\/v2\/posts\/1636\/revisions"}],"predecessor-version":[{"id":2411,"href":"https:\/\/matob.web.id\/random\/wp-json\/wp\/v2\/posts\/1636\/revisions\/2411"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/matob.web.id\/random\/wp-json\/wp\/v2\/media\/1642"}],"wp:attachment":[{"href":"https:\/\/matob.web.id\/random\/wp-json\/wp\/v2\/media?parent=1636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matob.web.id\/random\/wp-json\/wp\/v2\/categories?post=1636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matob.web.id\/random\/wp-json\/wp\/v2\/tags?post=1636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}