Coder Social home page Coder Social logo

c-mychmod's Introduction

c-mychmod

Unix/Linux 'chmod' shell command implementation in C Language

In Unix/Linux, who can do what to a file or directory is controlled through sets of permissions. There are three sets of permissions. One set for the owner of the file, another set for the members of the file’s group, and a final set for everyone else.

  • r: Read permissions. The file can be opened, and its content viewed.

  • w: Write permissions. The file can be edited, modified, and deleted.

  • x: Execute permissions. If the file is a script or a program, it can be run (executed).

  • u: User, meaning the owner of the file.

  • g: Group, meaning members of the group the file belongs to.

  • o: Others, meaning people not governed by the u and g permissions.

  • a: All, meaning all of the above.

  • –: Minus sign. Removes the permission.

  • +: Plus sign. Grants the permission. The permission is added to the existing permissions. If you want to have this permission and only this permission set, use the = option, described below.

  • =: Equals sign. Set a permission and remove others.

Custom 'mychmod' program's output:

$ ./mychmod u+rwx,g=rw,o=r,+rx,+r data.txt 
$ ls -l data.txt 
-rwxrw-r--  1 batux  staff  0 Feb 28 22:35 data.txt

$ ./mychmod 0 data.txt 
$ ls -l data.txt 
----------  1 batux  staff  0 Feb 28 22:35 data.txt

$ ./mychmod 777 data.txt 
$ ls -l data.txt 
-rwxrwxrwx  1 batux  staff  0 Feb 28 22:35 data.txt

$ ./mychmod +rw,o=r data.txt 
$ ls -l data.txt 
-rw-rw-r--  1 batux  staff  0 Feb 28 22:35 data.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.