Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
OS File Operations
Next article icon

OS File Operations

Last Updated : 25 Oct, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

File operations within an operating system (OS) encompass a set of essential tasks and actions directed at files and directories residing within a computer's file system. These operations are fundamental for the effective management and manipulation of data stored on various storage devices. In this article, we will learn different file operations and what are the system calls and APIs used to perform them in a Linux / Windows-based OS.

File-Operations-in-OS

File Creation and Manipulation

File Creation and Manipulation encompasses essential operations within an operating system that involve creating, modifying, and organizing files and directories. These actions are vital for managing data efficiently and are integral to the functioning of computer systems.

File Operation

Description

System Calls / APIs

Creating Files

Create a new file for data storage.

  • open() (Linux-like systems)
  • CreateFile() (Windows)

Creating Directories

Create a new directory for organizing files.

  • mkdir() (Linux systems)
  • CreateDirectory() (Windows)

Opening Files

Open a file that you already have open to read or write from.

  • open() (Linux systems)
  • CreateFile() (Windows)

Reading Files

Retrieve data from an open file.

  • read() (Linux systems)
  • ReadFile() (Windows)

Writing Files

Store data in an open file.

  • write() (Linux systems)
  • WriteFile() (Windows)

Renaming Files and Directories

If you want to rename a file or directory,.

  • rename() (Linux systems)
  • MoveFile() (Windows)

Deleting Files and Directories

Remove files or directories.

  • unlink() (Linux systems)
  • remove() (Linux systems)
  • DeleteFile() (Windows)
  • RemoveDirectory() (Windows)

File Organization and Search

File organization and search are key OS operations for arranging files systematically and swiftly locating specific data, optimizing file management and user efficiency.

File Operation

Description

System Calls / APIs

Copying Files

Create duplicates of files in another location.

  • cp (Linux systems)
  • CopyFile() (Windows)

Moving Files

Relocate files from one location to another.

  • mv (Linux systems)
  • MoveFile() (Windows)

Searching for Files

Locate files based on specific criteria.

  • find (Linux systems)
  • FindFirstFile() and FindNextFile() (Windows)

File Security and Metadata

File Security and Metadata are vital components of file management, encompassing access control and crucial file information preservation within an operating system. They are essential for data security and efficient organization.

File Operation

Description

System Calls / APIs

File Permissions

Control access rights to files and directories.

  • chmod (Linux systems)
  • SetFileSecurity (Windows)

File Ownership

Assign specific users or groups as file owners.

  • chown (Linux systems)
  • SetFileSecurity (Windows)

File Metadata

Retrieve and manipulate file information.

  • stat (Linux systems)
  • GetFileAttributesEx (Windows)

File Compression and Encryption

File Compression and Encryption are essential for optimizing storage and enhancing data security. Compression reduces file sizes, while encryption safeguards data privacy by making it unreadable without the correct decryption key.

File Operation

Description

System Calls / APIs

File Compression

Reduce file sizes to save storage space.

  • gzip, zip, tar (Linux systems),
  • Compress-Archive (Windows)

File Encryption

Protect data by converting it into an unreadable format.

  • openssl, gpg (Linux systems)
  • Windows provides encryption libraries and APIs for encryption operations.

Conclusion

In summary, this article has explored essential file operations in Linux and Windows-based operating systems. It has provided insights into the system calls and APIs used to perform these operations, covering everything from file creation and manipulation to organization, search, security, metadata, compression, and encryption.


Next Article
OS File Operations

P

pratham007yadav
Improve
Article Tags :
  • Operating Systems
  • Geeks Premier League
  • Geeks Premier League 2023

Similar Reads

    Matrix Operations
    Matrix Operations are basic calculations performed on matrices to solve problems or manipulate their structure. Common operations include:Addition: Add two matrices of the same size.Subtraction: Subtract two matrices of the same size.Scalar Multiplication: Multiply each element of a matrix by a cons
    8 min read
    Operations on Processes
    Process operations refer to the actions or activities performed on processes in an operating system. These operations include creating, terminating, suspending, resuming, and communicating between processes. Operations on processes are crucial for managing and controlling the execution of programs i
    5 min read
    Basic Signal Operations
    Basic signal operations are nothing but signal manipulation or modification tools that are used in signal processing and analysis. It helps to understand the signals in different situations. These operations allow the modification and enhancement of signals for specific applications. In this article
    11 min read
    Binary Operation
    Binary Operation is an operation defined for any set S such that it takes two elements from S as input and produces a single element in S as output. As the name suggests, binary operations require at least two inputs as it is defined from the cartesian product of set to set itself.In this article, w
    7 min read
    IoT Operating Systems
    An Operating System is a software program software that manages and controls all the resources in a computer, together with the hardware and the software program. A running system is chargeable for controlling, dealing with, and coordinating all the sports and resources in a computer. An operating m
    13 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences