__fwritable - Linux


Overview

__fwritable is a Linux command used to test the write permissions of files and directories. It determines whether the current user has write access to the specified paths.

Syntax

__fwritable [options] path...

Options/Flags

| Option | Description | Default |
|—|—|—|
| -f | Force evaluation even if a non-regular file is specified | No |
| -q | Quiet mode: suppress most error messages | No |
| -s | Suppress error messages for missing files | No |

Examples

  • Check write permissions for a file:
    __fwritable /etc/passwd
    
  • Force evaluation of a symbolic link (usually ignored):
    __fwritable -f /usr/bin/ls
    
  • Test multiple paths silently:
    __fwritable -qs /tmp /var/log /home
    

Common Issues

  • Permission denied errores: If the current user lacks write permissions for a path, the command will exit with an error.
  • Argument not regular file: By default, __fwritable ignores non-regular files (such as directories or symbolic links). Use the -f option to force evaluation.

Integration

__fwritable can be combined with other commands to automate permission checks:

  • Test if a file is writable and executable:
    if __fwritable /path/to/file && __fexecutable /path/to/file; then ...
    
  • Check permissions for a list of files from a script:
    for file in $(cat files.txt); do __fwritable $file && echo "$file is writable"; done
    

Related Commands

  • find: Search for files and directories based on criteria, including permissions.
  • stat: Display file and directory attributes, including permissions.