Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8547037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:10:37+00:00 2026-06-11T13:10:37+00:00

I am creating a file with full permission (777) using the open system call,

  • 0

I am creating a file with full permission (777) using the open system call, but when I do ls -l I can see only permission as (755). Could you please tell why file permission is not 777?

Code

#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

int main()
{
        int fd;

        /* Creates a file with full permission*/
        fd = open("test", O_CREAT | O_RDWR | O_APPEND, 0777);

        if (fd = -1)
        {
                return -1;
        }

        close(fd);
}

Output

     $ ls -l
    -rwxr-xr-x 1 ubuntu ubuntu    0 2012-09-19 11:55 test
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:10:39+00:00Added an answer on June 11, 2026 at 1:10 pm

    There’s a value maintained by the system called the umask; it is a property of the process, just like the PID (process ID) or EUID (effective user ID) is. It will be set to 022 (octal), which indicates that the system should remove the group and other write permission from files that are created.

    You can call umask(0); before using open() so that the mode you specify in open() won’t be altered. You should certainly do this to demonstrate that umask is the issue. However, it is generally best to let the user’s choice of umask prevail — I for one get very stroppy if a program doesn’t obey my umask setting; it tends not to be used again after I spot and verify the problem.

    The shell also has a (built-in) command umask which you can use. The 022 value is a sensible default; most of the time, you do not want just anybody writing to your files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a StreamWriter using a relative path. But the file doesn't appear. To
I am creating a file manager application using vaadin as ui and alfresco as
I am creating excel file using below code public class ResultSetToExcel { private HSSFWorkbook
I am creating a file abc.txt and storing the data. How can I know
I am creating Excel file download using NOPI libraries. I have lot of data
I am creating a file from a SELECT query using sqlplus with SPOOL command.
I am creating an application using Netbeans 7.1.2 and I am using a file
I'm creating a site with full browser video (see http://bitstream.ca/ ). For an optimum
Using SQL statements (sybase) how can I create or restore a full database given
I started creating file downloader class. Here is what i have: public class Downloader

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.