{"id":12416,"date":"2019-03-26T23:26:01","date_gmt":"2019-03-26T23:26:01","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12416"},"modified":"2019-03-26T23:26:01","modified_gmt":"2019-03-26T23:26:01","slug":"translate-rwx-permissions-into-octal-format-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/26\/translate-rwx-permissions-into-octal-format-in-linux\/","title":{"rendered":"Translate rwx Permissions into Octal Format in Linux"},"content":{"rendered":"<p>Sometimes you may find it useful to display the access rights of files or directories in octal form instead of\u00a0<code>rwx<\/code>or perhaps you want to display both.<\/p>\n<p>Instead of using good old\u00a0<code>ls -l<\/code>\u00a0command, in most modern Linux distributions (if not all) you will find\u00a0<code>stat<\/code>, an utility that displays file or filesystem status.<\/p>\n<p>When run without arguments but followed by a given filename,\u00a0<code>stat<\/code>\u00a0will display a good deal of information about the file or directory. If used with the\u00a0<code>-c<\/code>\u00a0option,\u00a0<strong>stat<\/strong>\u00a0allows you to specify an output format. It is precisely this option that\u2019s of particular interest to us.<\/p>\n<p>To display all files in the current working directory followed by the access rights in octal form, type:<\/p>\n<pre># stat -c '%n %a' *\r\n<\/pre>\n<h5>Sample Output<\/h5>\n<pre>add_emails.sh <strong>755<\/strong>\r\nanaconda-ks.cfg <strong>600<\/strong>\r\ndelete_emails.sh <strong>755<\/strong>\r\nemployee-dump.sql <strong>644<\/strong>\r\nindex.html <strong>644<\/strong>\r\nlatest.tar.gz <strong>644<\/strong>\r\nnrpe-2.15.tar.gz <strong>644<\/strong>\r\nphp7 <strong>644<\/strong>\r\nplaybook.retry <strong>644<\/strong>\r\n<\/pre>\n<div id=\"attachment_22331\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/08\/Find-Linux-File-Permissions-in-Octal-Format.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22331\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/08\/Find-Linux-File-Permissions-in-Octal-Format.png\" alt=\"Find Linux File Permissions in Octal Format\" width=\"468\" height=\"163\" aria-describedby=\"caption-attachment-22331\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22331\" class=\"wp-caption-text\">Find Linux File Permissions in Octal Format<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<p>In the command above, the format sequence:<\/p>\n<ol>\n<li><code>%n<\/code>\u00a0\u2013 means file name<\/li>\n<li><code>%a<\/code>\u00a0\u2013 means access rights in octal form<\/li>\n<\/ol>\n<p>Alternatively, you can append\u00a0<code>%a<\/code>\u00a0to\u00a0<code>%A<\/code>, the argument passed to\u00a0<strong>stat<\/strong>\u00a0if you want to display the permissions in\u00a0<code>rwx<\/code>\u00a0format as well.<\/p>\n<p>In that case, you can type:<\/p>\n<pre># stat -c '%n %A' *\r\n<\/pre>\n<h5>Sample Output<\/h5>\n<pre>add_emails.sh <strong>-rwxr-xr-x<\/strong>\r\nanaconda-ks.cfg <strong>-rw-------<\/strong>\r\ndelete_emails.sh <strong>-rwxr-xr-x<\/strong>\r\nemployee-dump.sql <strong>-rw-r--r--<\/strong>\r\nindex.html <strong>-rw-r--r--<\/strong>\r\nlatest.tar.gz <strong>-rw-r--r--<\/strong>\r\nnrpe-2.15.tar.gz <strong>-rw-r--r--<\/strong>\r\nphp7 <strong>-rw-r--r--<\/strong>\r\nplaybook.retry <strong>-rw-r--r--<\/strong>\r\n<\/pre>\n<div id=\"attachment_22332\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/08\/Find-Linux-File-Permissions-in-Directory.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22332\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/08\/Find-Linux-File-Permissions-in-Directory.png\" alt=\"Find Linux File Permissions in Directory\" width=\"536\" height=\"165\" aria-describedby=\"caption-attachment-22332\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22332\" class=\"wp-caption-text\">Find Linux File Permissions in Directory<\/p>\n<\/div>\n<p>To view the file type in the output, you can add\u00a0<code>%F<\/code>\u00a0format sequence.<\/p>\n<pre># stat -c '%c %F %a'\r\n<\/pre>\n<p>There are several other format sequences you can specify, refer to the\u00a0<code>stat man<\/code>\u00a0page to find out more.<\/p>\n<pre># man stat\r\n<\/pre>\n<p>In this tip, we have covered an important Linux utility called\u00a0<strong>stat<\/strong>, that helps you to display a file or file system status. Our main focus here was to translate the\u00a0<code>rwx<\/code>\u00a0access rights from the traditional\u00a0<code>ls -l<\/code>\u00a0output to octal form.<\/p>\n<p>As I had mentioned earlier on, many modern Linux distributions now come with\u00a0<strong>stat<\/strong>\u00a0utility. But you must also remember that your shell may come with its own version of\u00a0<strong>stat<\/strong>, therefore refer to your shell\u2019s documentation for more information concerning options and how to use them.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/check-linux-file-octal-permissions-using-stat-command\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may find it useful to display the access rights of files or directories in octal form instead of\u00a0rwxor perhaps you want to display both. Instead of using good old\u00a0ls -l\u00a0command, in most modern Linux distributions (if not all) you will find\u00a0stat, an utility that displays file or filesystem status. When run without arguments &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/26\/translate-rwx-permissions-into-octal-format-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Translate rwx Permissions into Octal Format in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12416","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12416"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12416\/revisions"}],"predecessor-version":[{"id":12417,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12416\/revisions\/12417"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}