access
Quick Reference
Command Name:
access
Category:
file management
Platform:
linux
Basic Usage:
Common Use Cases
- 1
File permission checking
Check if a file can be accessed with current permissions
- 2
Script automation
Test file accessibility before performing operations in scripts
- 3
Security validation
Verify file access rights for security auditing purposes
- 4
Error handling
Prevent script failures by checking file accessibility beforehand
Syntax
access [-acfmrwx] [-e] [-h] file ...
Options
| Option | Description |
|---|---|
| -e | Check if file exists, regardless of access mode |
| -r | Check if file is readable |
| -w | Check if file is writable |
| -x | Check if file is executable |
| -f | Check if file exists and is a regular file |
| -a | Show access information in verbose mode (implementation dependent) |
| -c | Check the file's access by context (SELinux) |
| -m | Check the file's access by mode (ACL) |
| -h | Display help information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the access command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
access -r /etc/passwd && echo "File exists and is readable"
access -w /etc/shadow || echo "No write permission to this file"
access -x /bin/bash && echo "File is executable"
access -e myfile.txt && echo "File exists"