[Question]
  [
# File Permissions
[code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'")
*Adapted from the UIL - Computer Science Programming free response question "Carla" for 2018 District.*
# Introduction
In UNIX-like operating systems, each file, directory, or link is "owned" by a "user", who is a member of a "group", and has certain "permissions" represented by a ten-character string such as "drwxrwxrwx". The first character is 'd', '-', or 'l' (directory, file, or link), followed by three sets of "rwx" values, indicating "read, write, execute" permissions. The first set is the user's rights, the middle set the group's rights, and the third everyone else's rights to that object.
Permission denied for any of these rights is represented by a '-' in place of the 'r', 'w', or 'x'. For example, a sample directory permission string would be "drwxr--r--", indicating full directory rights for the user, but "read-only" rights for the group member and all others.
**Each "rwx" combination can also be represented by an octal value (0-7) with the most significant bit representing read permission, the next most significant bit representing write permission, and the least significant bit representing execute permission.**
# Challenge
Given a four-character code string made up of a character: 'D', 'F', or 'L', followed by a three-digit octal integer value, like 664, output the resulting 10 character string that represents the permission value indicated.
# Input
Your program or function may either read the input from standard in (four characters will be entered, optionally followed by a newline) or be passed the input as an argument.
Your program may accept uppercase or lowercase inputs but must be consistent (either all inputs are uppercase or all inputs are lowercase).
# Output
Your program must print the resulting ten-character string that represents the permission value indicated in the exact format specified above. Tailing white space is allowed.
# Test Cases
In: `F664` Out: `-rw-rw-r--`  
In: `D775` Out: `drwxrwxr-x`  
In: `L334` Out: `l-wx-wxr--`  
In: `F530` Out: `-r-x-wx---`  
In: `D127` Out: `d--x-w-rwx`
# Scoring and Rules
* [Standard loop-holes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* [Standard rules](https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet/2422#2422) apply.
* Please provide a link to test your code as well as an explanation.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins!
  
[Answer]
## bash, ~~59~~ 53 bytes
```
chmod ${1:1} a>a;stat -c%A a|sed s/./${1:0:1}/|tr f -
```
Right tool for the job?
Thanks to [Dennis](https://codegolf.stackexchange.com/users/12012/dennis) for saving 5 bytes and [HTNW](https://codegolf.stackexchange.com/users/50062/htnw) for saving one.
[Try it online!](https://tio.run/##S0oszvj/PzkjNz9FQaXa0MqwViHRLtG6uCSxREE3WdVRIbGmODVFoVhfTx8kbQBUoF9TUqSQpqD7////NDMzEwA "Bash – Try It Online")
```
chmod ${1:1} a>a;  # call chmod with the input with its first character removed
                   # note that the redirection creates the file a *before* the
                   #   chmod is run, because of the way bash works
stat -c%A a|       # get the human readable access rights
sed s/./${1:0:1}/  # replace the first character with the first char of input
|tr f -            # transliterate, replacing f with -
```
[Answer]
# [Python 2](https://docs.python.org/2/), 78 bytes
```
lambda a,*b:[a,'-'][a=='f']+''.join('-r'[x/4]+'-w-w'[x/2]+'-x'[x%2]for x in b)
```
Takes input as a character and three ints.  
[Try it online!](https://tio.run/##VYvLCsIwEEX3fkU2Mo1OfMTWgpAviVkklGBLTUooNH59nG6kcjaHw73TZ37FIItn6llG@3adZRYP7qEtggCjrVLgwRwBTkPsQwUigc7nmopYxLK6XD2T7aXxMbHM@sAcL1Pqw8x8RX@8EzXf/VIH2BLNJo2AN2K7omND6fJ/vKLElpcv "Python 2 – Try It Online")
### Explanation
`[a,'-'][a=='f']` takes either the input character or `-`, if the character is `f`.  
`'-r'[x/4]+'-w-w'[x/2]+'-x'[x%2]` is essentially an octal conversion to get the `rwx` string.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 19 bytes
```
“rwx“-”Œp⁺;Ṁ⁾f-yị@~
```
[Try it online!](https://tio.run/##y0rNyan8//9Rw5yi8gogqfuoYe7RSQWPGndZP9zZ8KhxX5pu5cPd3Q51/x/u3nK4/VHTmsj//9PMzEy4UszNTblyjI1NuNJMjQ24UgyNzAE "Jelly – Try It Online")
### How it works
```
“rwx“-”Œp⁺;Ṁ⁾f-yị@~  Main link. Argument: s (string)
“rwx“-”              Set the return value to ["rwx, "-"].
       Œp            Take the Cartesian product, yielding ["r-", "w-", "x-"].
         ⁺           Take the Cartesian product, yielding
                     ["rwx", "rw-", "r-x", "r--", "-wx", "-w-", "--x", "---"].
          ;Ṁ         Append the maximum of s (the letter).
            ⁾f-y     Translate 'f' to '-'.
                  ~  Map bitwise NOT over s.
                     This maps the letter to 0, because it cannot be cast to int,
                     and each digit d to ~d = -(d+1).
                ị@   Retrieve the results from the array to the left at the indices
                     calculated to the right.
                     Indexing is modular and 1-based, so the letter from s is at
                     index 0, "---" at index -1, ..., and "rwx" at index -8.
```
[Answer]
## [Perl 5](https://www.perl.org/) with `-p`, 37 bytes
```
s/\d/(<{-,r}{-,w}{-,x}>)[$&]/ge;y;f;-
```
Takes input in lowercase.
[Try it online!](https://tio.run/##K0gtyjH9/79YPyZFX8OmWlenqBZIlIOIilo7zWgVtVj99FTrSus0a93//9PMzEy4UszNTblyjI1NuNJMjQ24UgyNzP/lF5Rk5ucV/9ctAAA "Perl 5 – Try It Online")
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 43 bytes
```
\d
$&r$&w$&x
f|[0-3]r|[0145]w|[0246]x
-
\d
```
[Try it online!](https://tio.run/##K0otycxL/P8/JoVLRa1IRa1cRa2CK60m2kDXOLYISBmamMaWA2kjE7PYCi5dLqC6///TzMxMuFLMzU25coyNTbjSTI0NuFIMjcwB "Retina 0.8.2 – Try It Online") Link includes test cases. Takes input in lower case. Explanation:
```
\d
$&r$&w$&x
```
Triplicate each digit, suffixing with `r`, `w` and `x`.
```
f|[0-3]r|[0145]w|[0246]x
-
```
Change all the incorrect letters to `-`s.
```
\d
```
Delete any remaining digits.
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 51 bytes
```
f
-
0
---
1
--x
2
-w-
3
-wx
4
r--
5
r-x
6
rw-
7
rwx
```
[Try it online!](https://tio.run/##DctBCsAgDADB@/4loEbNewpWKJQepND83uYyh4Vd53s9R957IiREhBw6BfkEDZ3Kit5Cp7OiW@gx9V4ZZo1btTKbJkYu9gM "Retina – Try It Online")
No idea how to use Retina, so please let me know how to do this better. I just figured I'd try to learn at least one language that isn't Pyth.
### Explanation:
Replace `f` with `-` (leaving `d` and `l` unchanged), then replace each digit with the appropriate `rwx`.
[Answer]
# JavaScript (ES6), 63 bytes
Expects the input string in lowercase.
```
s=>s.replace(/\d|f/g,c=>1/c?s[c&4]+s[c&2]+s[c&1]:'-',s='-xw-r')
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@7/Y1q5Yryi1ICcxOVVDPyalJk0/XSfZ1s5QP9m@ODpZzSRWG0QZQSjDWCt1XXWdYlt13Ypy3SJ1zf/J@XnF@Tmpejn56RppGkppZmYmSpqaXGjCKebmpliEc4yNsalOMzU2wGaIoZE5UPg/AA "JavaScript (Node.js) – Try It Online")
### Commented
```
s => s.replace(   // replace in the input string s
  /\d|f/g, c =>   //   each character c which is either a digit or the letter 'f'
    1 / c ?       //   if c is a digit:
      s[c & 4] +  //     append '-' or 'r'
      s[c & 2] +  //     append '-' or 'w'
      s[c & 1]    //     append '-' or 'x'
    :             //   else:
      '-',        //     just replace 'f' with '-'
  s = '-xw-r'     //   s holds the permission characters
)                 // end of replace()
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 27 bytes
```
ＦＳ≡ιdιlιf¦-⭆rwx⎇§↨⁺⁸Ｉι²⊕λκ-
```
[Try it online!](https://tio.run/##bc@/CsIwEAbw3ac4Ml0gDgqi6KROHYSCvsCRpLYY03JJbUV89prin8nhlt8H38fpkljX5IahqBkw800bj5Erf0YpIXRV1CVgJeEx0RQsCCPWkKc8Jtx8zP2x4mdiKpIaW1Dr4hffGwdqUHDXCwUny574jtuYeWN73KUWzF0bcKVgT2Hslgrm6TKv2V6tj9agG/GiYByRaeaZHlkuZsP05l4 "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
 Ｓ                          Input string
Ｆ                           Loop over characters
   ι                        Current character
  ≡                         Switch
    d                       Literal `d`
     ι                      Implicitly print current character
      l                     Literal `l`
       ι                    Implicitly print current character
        f                   Literal `f`
         ¦                  (Separator between string literals)
          -                 Implicitly print literal `-`
                            Implicit default case
            rwx             Literal `rwx`
           ⭆                Map over characters
                     ι      Input character
                    Ｉ       Cast to integer
                   ⁸        Literal 8
                  ⁺         Sum
                      ²     Literal 2
                 ↨          Base conversion
                        λ   Inner index
                       ⊕    Incremented
                §           Index into base conversion
                         κ  Inner character
                          - Literal `-`
               ⎇            Ternary
                            Implicitly print
```
[Answer]
# [Haskell](https://www.haskell.org/), ~~84~~ ~~83~~ 81 bytes
```
f 'f'='-'
f y=y
t#n=f t:((\x->["-r"!!div x 4,"-w-w"!!div x 2,"-x"!!mod x 2])=<<n)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P01BPU3dVl1XnStNodK2kqtEOc82TaHESkMjpkLXLlpJt0hJUTEls0yhQsFER0m3XLcczjcC8iuAvNz8FBAvVtPWxiZP839uYmaegq1CSj6XAgQUlJYElxT55KkAbVKONtMx0zGJxZRLAcqZ65jrmGKRywHKGesYY9UHMtMUKGeAw0xDHSMd89j/AA "Haskell – Try It Online")
Ended up being pretty similar in concept to Mnemonic's Python 2 answer. f creates the file type, the rest is the gets permissions from the octal number. This one really made me wish & was a bitwise and operator included in prelude.
[Answer]
# Java 8, 100 bytes
```
s->s.replaceAll("(\\d)","$1r$1w$1x").replaceAll("f|[0-3]r|[0145]w|[0246]x","-").replaceAll("\\d","")
```
[Try it online.](https://tio.run/##hU/JbsIwEL3zFSMrh1hqIky2AwKJD4ALR8jBdRLkYExkm02Qbw/T1pdWqiLNaLY38960/MqjtjoOQnFrYc2lfk4ApHa1abioYfNVAmydkfoAIvSJpXPs9@ho1nEnBWxAwwIGGy1tbOpO4fpKqZCE@31FyQcJmAnYLWB3Qn/Nm9duGiWlwcDSrLxhnKV5eceV6A8UL2GX0GH@w9xdPhUyewHXs6zghC94lbuSUy//YV19is8XF3c4cUqHOhZInecpod@//A@qiiIbBakkGb/UZMl0nI7NCg/qJ/3wBg)
Port of [*@Neil*'s Retina answer](https://codegolf.stackexchange.com/a/163713/52210).
**Explanation:**
```
s->                                 // Method with String as both parameter and return-type
  s.replaceAll("(\\d)","$1r$1w$1x") //  Replace every digit `d` with 'drdwdx'
   .replaceAll("f                   //  Replace every "f",
                |[0-3]r             //  every "0r", "1r", "2r", "3r",
                |[0145]w            //  every "0w", "1w", "4w", "5w",
                |[0246]x",          //  and every "0x", "2x", "4x", "6x"
               "-")                 //  with a "-"
   .replaceAll("\\d","")            //  Remove any remaining digits
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 21 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
Ḣ⁾f-yɓOBṫ€4a“rwx”o”-ṭ
```
A full program printing to STDOUT. (As a monadic link the return value is a list containing a character and a list of three lists of characters.)
**[Try it online!](https://tio.run/##y0rNyan8///hjkWPGvel6VaenOzv9HDn6kdNa0wSHzXMKSqveNQwNx@IdR/uXPv///8Uc3NTAA "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##y0rNyan8///hjkWPGvel6VaenOzv9HDn6kdNa0wSHzXMKSqveNQwNx@IdR/uXPv/4e4th9uBckf3OACZWUAWUI2Crp0CUEHk//9pZmYmXCnm5qZcOcbGJlxppsYGXCmGRuYA "Jelly – Try It Online").
### How?
```
Ḣ⁾f-yɓOBṫ€4a“rwx”o”-ṭ | Main Link: list of characters
Ḣ                     | head & pop (get the 1st character and modify the list)
 ⁾f-                  | list of characters = ['f', '-']
    y                 | translate (replacing 'f' with '-'; leaving 'd' and 'l' unaffected)
     ɓ                | (call that X) new dyadic chain: f(modified input; X)
      O               | ordinals ('0'->48, '1'->59, ..., '7'->55 -- notably 32+16+value)
       B              | convert to binary (vectorises) (getting three lists of six 1s and 0s)
        ṫ€4           | tail €ach from index 4 (getting the three least significant bits)
           “rwx”      | list of characters ['r', 'w', 'x']
          a           | logical AND (vectorises) (1s become 'r', 'w', or 'x'; 0s unaffected)
                 ”-   | character '-'
                o     | logical OR (vectorises) (replacing any 0s with '-'s)
                   ṭ  | tack (prepend the character X) 
                      | implicit print (smashes everything together)
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg) `-p`, 37 bytes
```
s:g[\d]=[X~]('-'X <r w x>)[$/];s/f/-/
```
[Try it online!](https://tio.run/##K0gtyjH7/7/YKj06JiXWNjqiLlZDXVc9QsGmSKFcocJOM1pFP9a6WD9NX1f///80MzMTrhRzc1OuHGNjE640U2MDrhRDI/N/@QUlmfl5xf91CwA "Perl 6 – Try It Online")
Port of Dom Hastings' Perl 5 solution.
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 38 bytes
Inspired by [a comment](https://codegolf.stackexchange.com/questions/163691/file-permissions#comment396365_163694) from [ASCII-only](https://codegolf.stackexchange.com/users/39244/ascii-only).
```
\d
---$&*
---____
r--
--__
w-
-_
x
f
-
```
[Try it online!](https://tio.run/##K0otycxLNPz/PyaFS1dXV0VNC0TFAwFXka4uF4jJVQ6k47kquNK4dP//TzMzM@FKMTc35coxNjbhSjM1NuBKMTQyBwA "Retina – Try It Online")
The idea is converting each digit to unary (the default unary digit in Retina is `_`) with three leading `-`, and then converting binary digits from the most to the least significant.
[Answer]
# [Python 3](https://docs.python.org/3/), 71 bytes
```
lambda s:("-"+s)[s[0]!="f"]+stat.filemode(int(s[1:],8))[1:]
import stat
```
[Try it online!](https://tio.run/##VYtBCsMgFAX3OUX6V0raktQmlkBOYl1YzKeCRoluenoTNwVXD@bNhF/6@o1lXN7ZKvfRqo0zgRt0kYooenlZAEF2Mal0R2NX5/VKzJZIFMMsry9KyzbGBb@ntmg57OVHAjhNT6C0@QPN@VgBy1ht4Mj6Ohke/AT5AA "Python 3 – Try It Online")
Python 3.3+ has a built-in for that, although due to the need for an import, and differences in expected input format, it is not very golf-friendly.
[Answer]
# [Tcl](http://tcl.tk/), 139 bytes
```
proc P s {join [lmap c [split $s ""] {expr {[regexp \\d $c]?"[expr $c&4?"r":"-"][expr $c&2?"w":"-"][expr $c&1?"x":"-"]":$c==f?"-":$c}}] ""}
```
[Try it online!](https://tio.run/##XY69CsIwFEb3PMXlEtwE@w@FklfonmaQtJVKtCGpWAh59nip4OD0Hc5yvk2blKxbNfTgIdzX5QnSPK4WNEhvzbIB94CoIEy7dRCkm25EMAwjcK0EysNzfSoFOmzxjOqncoHvP5UJ3L8KW667bhbERDEqysR0tOkJm@u6ZGPTVMwURcnmqriwMcsbFiHY1@bpVzuA7GlVTB8 "Tcl – Try It Online")
---
# [Tcl](http://tcl.tk/), 144 bytes
```
proc P s {join [lmap c [split $s ""] {expr {[regexp \\d $c]?[list [expr $c&4?"r":"-"][expr $c&2?"w":"-"][expr $c&1?"x":"-"]]:$c==f?"-":$c}}] ""}
```
[Try it online!](https://tio.run/##XY7NCsMgEAbvPsWySG@F5h8CwVfIXT0Uk5QU24haGhCf3UoKPfS0w3yHHa90SsZuCkZwEO7b@gSuH1cDCrgzevVAHSBKCPNuLARu51smEGICqiTjenUe@DFSdaoZWuzxjPKnSobvP1Uw3L9K9lQNw8IyZ4pR5l8xHQE5hyxtW5Op6xqiq6omS1NdyFSUHYkQzMu7HNcL4GO@MqYP "Tcl – Try It Online")
## 
# [Tcl](http://tcl.tk/), 149 bytes
```
proc P s {join [lmap c [split $s ""] {if [regexp \\d $c] {list [expr $c&4?"r":"-"][expr $c&2?"w":"-"][expr $c&1?"x":"-"]} {expr {$c==f?"-":$c}}}] ""}
```
[Try it online!](https://tio.run/##Xc5LCsMgEIDhvacYRLorNG8IBK@QvXFRTCwpthG1NCCe3Q4pdNHVMB8M8wdlcrZuUzCCh3jf1icI87haUCC8NWsA5oFSCXHVINxyW3YL0zQDU2hm9QEEksP9VHPqaE/PVP6o5PT9RwWn@5cSxAMjU8OgOVLPVEpJ4sOUjwpsIrptazJ3XUNMVdVEN9WFzEXZEby3r@CxsJ9AjDhlyh8 "Tcl – Try It Online")
## 
# [Tcl](http://tcl.tk/), 150 bytes
```
proc P s {join [lmap c [split $s ""] {if [regexp \\d $c] {set v [expr $c&4?"r":"-"][expr $c&2?"w":"-"][expr $c&1?"x":"-"]} {expr {$c==f?"-":$c}}}] ""}
```
[Try it online!](https://tio.run/##Xc5NCsIwEIbhfU4xhOBOsH8WCiVX6D7NQtJGKtGGJGoh5OxxqODC1cADw/cGZXK2blUwgId4W5cHCHO/WFAgvDVLAOaBUglx0SDcfJ03C@M4AVNofg7wAoHmEA41p4529Ejlj0pO339UcLp9KUHcMTLV95ojdUyllCQuprxnYBTR53NNprZtiKmqmuimOpGpKFuC//YZPCZ2I4gBr0z5Aw "Tcl – Try It Online")
## 
# [Tcl](http://tcl.tk/), 180 bytes
```
proc P s {join [lmap c [split $s ""] {if [regexp \\d $c] {[set R regsub] (..)1 [$R (.)1(.) [$R 1(..) [$R -all 0 [format %03b $c] -] r\\1] \\1w\\2] \\1x} {expr {$c==f?"-":$c}}}] ""}
```
[Try it online!](https://tio.run/##HY9Bi8IwEIXv@RWPkoX1UGmsWhDEvyBekxxq2kiXuA1JRKHkt3dncxjm48G8eS8Zt64@zAZXRCw/8/QL6Z69h4GM3k0JPKKqNJbJQobxMX48lBrADWkyjgk3kBxfd43v7XYjIPmNaCNoCot/uVDdO4cG0s7h2Sd8Ne29@NQaQSmhyVi8ldoV@GQs9Cxg4eZ8tpeqrk7c5Jw15clrCUmRmT0e92zougNzbbtn9tA2bBC7jtG9f6VIBU4K8kpb5/UP "Tcl – Try It Online")
**Still very ungolfed!**
[Answer]
# [Java (JDK 10)](http://jdk.java.net/), 118 bytes
```
s->{var r=s[0]=='f'?"-":""+s[0];var z="-xw r".split("");for(int i=0;++i<4;)r+=z[s[i]&4]+z[s[i]&2]+z[s[i]&1];return r;}
```
[Try it online!](https://tio.run/##VU/BbsIwDL3zFVYkRrvSiEEBiRCmadJuO3GseshawsJKWjkuGyC@PWsBTdrB8rPfs/28UwcV74ovb/Z1hQS7tuYNmZLrxuZkKssfRS8vlXPwroyFcw@gbj5Kk4MjRW06VKaAfcsFa0Jjt2kGCrcuvEoB3u57lvmnwjQb3kQr0NK7eHU@KASULh1lUg704JnFbMFY1DVEx50ki3@@ARl3dWkoYCwUusLAWAIjRyKKzDIRIUbylLrUZA9JFt3R@A89ZQI31KAFFBcvrr66JTcvQBtHi3@mAdZHR5s9rxridSsiHbB@4iBeQd/1LRteh4aguarr8hh0Fafqtf3xBVEdgzAMb3cuvS4u3uvZLPHFfD715WSSeD2djHzxNJ7/Ag "Java (JDK 10) – Try It Online")
## Credits
* 13 bytes saved thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)
[Answer]
# Excel, 224 bytes
```
=IF(LEFT(A1,1)="f","-",LEFT(A1,1))&CHOOSE(MID(A1,2,1)+1,"---","--x","-w-","-wx","r--","r-x","rw-","rwx")&CHOOSE(MID(A1,3,1)+1,"---","--x","-w-","-wx","r--","r-x","rw-","rwx")&CHOOSE(MID(A1,4,1)+1,"---","--x","-w-","-wx","r--","r-x","rw-","rwx")
```
Done in 4 stages:
```
IF(LEFT(A1,1)="f","-",LEFT(A1,1))    Replace "f" with "-".
```
And 3 times:
```
CHOOSE(MID(A1,2,1)+1,"---","--x","-w-","-wx","r--","r-x","rw-","rwx")
```
Trying to be smarter, adds `25 bytes` per set of rights, 75 in total:
```
IF(INT(MID(A1,2,1))>3,"r","-")&IF(MOD(MID(A1,2,1),4)>1,"w","-")&IF(ISODD(MID(A1,2,1)),"x","-")
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~34~~ 27 bytes
```
ćls8βbvyi…rwx3*Nèë'-}J'f'-:
```
[Try it online!](https://tio.run/##MzBNTDJM/f//SHtOscW5TUlllZmPGpYVlVcYa/kdXnF4tbpurZd6mrqu1f//bmZmJgA "05AB1E – Try It Online")
Golfed down 7 bytes by [@MagicOctopusUrn](https://codegolf.stackexchange.com/users/59376/magic-octopus-urn)
---
```
ć                           # Remove head from string.
 ls                         # Lowercase swap.
   8βb                      # Octal convert to binary.
      vy                    # For each...
        i        ë  }
         …rwx3*Nè           # If true, push the correct index of rwx.
                  '-        # Else push '-'.
                     J      # Repeatedly join stack inside the loop.
                      'f'-: # Repeatedly replace 'f' with '-' inside the loop.
```
[Answer]
# [Python 2](https://docs.python.org/2/), 238 bytes
```
lambda m,r=str.replace,s=str.split,j="".join,b=bin,i=int,z=str.zfill,g=lambda h,y:y if int(h)else "-":r(m[0],"f","-")+j(j([g(z(s(b(i(x)),"b")[1],3)[0],"r"),g(z(s(b(i(x)),"b")[1],3)[1],"w"),g(z(s(b(i(x)),"b")[1],3)[2],"x")])for x in m[1:])
```
[Try it online!](https://tio.run/##fc7NCsIwEATgVwl72sW1@IMIhTxJLdJoY1PSNiQR2758jcWrXgYGPoZxU2yG/rBoIcVlsVWn7pXo2MsQfeZrZ6tbzWFtwVkTuZUAWTuYnpVUKY00feR5FbM21vJDfmcanvJJGC2SwIZqG2oBW8g9dsWuZNDAqdKmxRaLB84YUKHBkYhBARX7ko@0Sg/EP0FKeP0DhwRGoJL04MWY3oiu2OclLc5/nmn01etqeveMSETL/Xw@vQE "Python 2 – Try It Online")
I had assumed this would be a drop in the bucket, but I was wrong indeed. Probably should have realized that a lambda wasn't the best idea at some point.
[Answer]
# APL+WIN, 55 bytes
Prompts for input string with leading character lower case:
```
('dl-'['dlf'⍳↑t]),⎕av[46+(,⍉(3⍴2)⊤⍎¨⍕1↓t←⎕)×9⍴69 74 75]
```
Explanation:
```
9⍴69 74 75 create a vector of ascii character codes for rwx -46, index origin 1
1↓t←⎕ prompt for input and drop first character
,⍉(3⍴2)⊤⍎¨⍕ create a 9 element vector by concatenating the binary representation for each digit 
46+(,⍉(3⍴2)⊤⍎¨⍕1↓t←⎕)×9⍴69 74 75 multiply the two vectors and add 46
⎕av[.....] convert back from ascii code to characters, 46 being '-'
('dl-'['dlf'⍳↑t]), append first character from input swapping '-' for 'f'
```
[Answer]
# [Python 3](https://docs.python.org/3/), 77 bytes
```
lambda a,*b,k='-xw-r':f'{a}-'[a=='f']+''.join(k[x&4]+k[x&2]+k[x&1]for x in b)
```
[Try it online!](https://tio.run/##XYvNCgIhFEb3PYWrrjbXaP4aCHySyYUySDaTDjKQET27GUFUnMUHh@/Mt@XkXZ0MEcc0qYseFFG40TgK4PHKAxwM3NWDQ6@EAAOyANievXV07OO6kcVrqveU0vhAIrGOaJbmYN1CDc0R7jMNY6uPGwC7TPvtJsA68/PLbZvd7q8tscKOsfQE "Python 3 – Try It Online")
[Answer]
# [J](http://jsoftware.com/),  57  52 bytes
5 bytes saved thanks to FrownyFrog!
```
-&.('-DLld'i.{.),[:,('-',:'rwx'){"0 1&.|:~1#:@}."."0
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/ddX0NNR1XXxyUtQz9ar1NHWirXSAAuo6VupF5RXqmtVKBgqGano1VnWGylYOtXpKekoG/zW5uFKTM/IV0hTU3czMTNThPBdzc1MEz8fYGEnOzdTYAEmloZG5@n8A "J – Try It Online")
Yet another long solution... I don't know how to make `}` work in tacit verbs and that's why I used the much longer `{"0 1&.|:` for selection.
## Explanation:
`@}.` Drop the first symbol and
`,.&.":` convert the rest to a list of desimal digits
`]:#:` convert each digit to a list of binary digits (and cap the fork)
`('-',:'rwx')` creates a 2-row table and use 0 to select from its first row / 1 - from its second one
```
   '-',:'rwx'
---
rwx
```
`{"0 1&.|:~` uses the binary digits to select from the table above 
`[:,` flattens the result
`('d-l'{~'DFL'i.{.)` formats the first symbol 
`,` appends the fisrt symbol to the list of permissions
[Answer]
# PHP, 68 bytes
```
<?=strtr(strtr($argn,[f=>_,___,__x,_w_,_wx,r__,r_x,rw_,rwx]),_,"-");
```
translates `f` in lowercase input to underscore and every octal number to its `rwx` equivalent, using underscores instead of dashes (to save the need for quotes), then replaces the `_` with `-`.
Run as pipe with `-nF` or [try it online](http://sandbox.onlinephpfunctions.com/code/fc954b2f180b55b9c250179105dec22bf2e4cbef).
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 109 104 bytes
At least C can convert octal input.... :-)
**Edit:** I realized that the size modifier wasn't strictly required, and that `putchar()` is shorter than `printf()` in this case!
```
f(a,b){char*s="-xwr";scanf("%c%o",&a,&b);putchar(a-70?a:*s);for(a=9;~--a;putchar(s[(1&b>>a)*(a%3+1)]));}
```
[Try it online!](https://tio.run/##PcrRCoIwFIDhe59iLJQdc1GESC3tpreILo7HloPawmkFYq@@6qbLn@8neSEKM2PpOjRntvN9Y9yirYIWmNUwUotd6ksuX8@OK09oteAxxY5nCWZJDeo@9L9JoCyWe9ymHpR23yw36i0l/t0fxSqpqwohFRiv5ys4AagpGNuzGxorHs40wMaIMS1ARVM4FHn@AQ "C (gcc) – Try It Online")
Original:
```
f(a,b){char*s="-xwr";scanf("%c%3o",&a,&b);putchar(a-70?a:*s);for(a=9;~--a;printf("%c",s[(1&b>>a)*(a%3+1)]));}
```
[Try it online!](https://tio.run/##HcvRCoIwFIDhe59iLJQd2yIRkVraTW8RXRxny0Ft4rQCsVc36/KH71fiptS8Mlbdh/pKDr6vjds05awZ8gpG1WAX@4KK96uj0iu0mtFQhamjPEIeVSDbof8phiLfHnEfe5DaLVns5EcIlG1nbP@/KPdnlkRVWSLEDMN0ncAFQE7zIsgDjWVPZ2ogY0CIZiCDaT7lWfYF "C (gcc) – Try It Online")
]