Find the answer to your Linux question:
Results 1 to 4 of 4
Hello, i have an assignment to where i need to change files and directory permissions. the problem is that when i use chmod(filename,mode) on files it works fine. but when ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2013
    Posts
    2

    Help with chmod or mode_t..


    Hello, i have an assignment to where i need to change
    files and directory permissions.

    the problem is that when i use chmod(filename,mode)
    on files it works fine.
    but when i use that on directories, it does not.
    i have no idea as to why.. tried several approaches and
    still got stuck.

    please can anyone point me to solving this?

  2. #2
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    Location
    London, England
    Posts
    471
    Please show us the exact commands that you were using for files and directories, and then we might be able to point you in the right direction.

  3. #3
    Just Joined!
    Join Date
    Jan 2013
    Posts
    2
    first i defined an int with the permission required, say i = 775
    i have a char *name which is the name of the file/directory.
    then i use the line
    chmod(name,i);

  4. #4
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    Location
    London, England
    Posts
    471
    It doesn't look like you're using enough digits for the mode. Try using 5 digits instead of 3. I'll leave you to figure out what to prefix it with, but I'll give you a clue that it's what you use if you don't want any permissions at all.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •