5. Android File Structure

The Android file system is organized into several directories, each serving a specific purpose in managing the operating system, applications, and user data. It combines the Linux file system structure with additional Android-specific directories, providing a secure and modular way to handle files and processes.

Key Directories

  1. /system

    • Contains the core operating system files, pre-installed apps, libraries, and system configurations.

    • Divided into:

      • /system/app: Default location for system applications.

      • /system/priv-app: Holds privileged system apps with higher permissions.

    • Example: Stock apps like Calculator, Clock, and Settings.

  2. /data

    • Stores user-installed applications and their data.

    • /data/app: Location of APKs for third-party apps installed by the user.

    • /data/data: Contains app-specific data, including databases, shared preferences, and caches.

    • Requires root access to view or modify.

  3. /sdcard or /storage/emulated/0

    • User-accessible storage for media, downloads, and app data (non-sensitive files).

    • Shared by all apps unless restricted by Android's scoped storage policies.

    • Example: Photos, videos, music, and documents.

  4. /cache

    • Temporary storage for frequently accessed data or system updates.

    • Can be cleared to free up space without affecting the system.

  5. /vendor

    • Contains device-specific files, drivers, and firmware provided by the hardware manufacturer.

    • Used to support hardware components like cameras, GPUs, and fingerprint sensors.

  6. /dev

    • Holds virtual files representing device nodes for hardware components.

    • Examples: Input devices, USB connections, and block storage.

  7. /proc

    • A virtual directory providing information about system processes and kernel status.

    • Frequently used for debugging and system monitoring.

    • Example: /proc/cpuinfo (CPU details) or /proc/meminfo (memory details).

  8. /etc

    • Contains configuration files for the Android operating system.

    • Examples: Network configurations, permissions, and system-wide settings.

  9. /mnt

    • Mount point for external storage, such as SD cards and USB drives.

    • Example: /mnt/media_rw/ for SD card storage.

  10. /boot

    • Stores the kernel and bootloader required to start the device.

    • Modifications here are critical and can brick the device.

  11. /lib

    • Holds shared libraries required by the Android runtime and system processes.

  12. /bin

    • Contains essential binary files and executables for system-level commands.


File Types and Permissions in Android

The Android file system, built on Linux, manages files and directories using specific types and permissions. Understanding these is critical for secure app development, security testing, and system management.

File Types in Android

  1. Regular Files:

    • Common files containing data or code.

    • Examples: Images, text files, APK files, libraries.

  2. Directories:

    • Containers for organizing files and subdirectories.

    • Examples: /data, /system, /sdcard.

  3. Special Device Files:

    • Represent hardware or software resources.

    • Character Device Files: Represent devices like keyboards (/dev/input).

    • Block Device Files: Represent storage devices like SD cards (/dev/block).

File Permissions in Android

Android follows the Linux permission model, using three key attributes for each file or directory:

1. Permission Types

Each file or directory has three permission categories:

  • Read (r): Allows viewing the file or directory contents.

  • Write (w): Allows modifying the file or directory contents.

  • Execute (x): Allows running a file as a program or accessing a directory.

2. User Categories

Permissions are assigned to three user groups:

  • Owner: The user who created the file.

  • Group: A group of users who share specific permissions.

  • Others: All other users not in the owner or group categories.

Command Example

Use ls -l to view file permissions:

$ ls -l
-rwxr-xr-- 1 root root 1024 Jan 7 2025 file.txt
  • rwxr-xr--: Permissions (read, write, execute for owner; read, execute for group; read for others).

  • 1: Number of links.

  • root root: Owner and group.

  • 1024: File size in bytes.

  • Dec 13 2019: Last modification date.

  • file.txt: File name.


Sensitive Files in Android

Sensitive files in Android store critical information such as user data, app configurations, and authentication credentials. These files are integral to app functionality but must be handled securely to prevent data breaches or unauthorized access.

  1. Keystore

    • Purpose: Stores cryptographic keys for encryption, decryption, and signing.

    • Location: /data/misc/keystore/

    • Key Points: Protects keys using hardware-backed security (if available).

  2. Databases

    • Purpose: Stores structured data using SQLite (e.g., user info or tokens).

    • Location: /data/data/<package-name>/databases/

    • Key Points: Private by default but should be encrypted for sensitive data.

  3. Shared Preferences

    • Purpose: Stores small app settings or user preferences in key-value pairs.

    • Location: /data/data/<package-name>/shared_prefs/

    • Key Points: Avoid storing sensitive data unless encrypted.

Last updated