Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A simple command line tool for changing file permissions, A `chmod 777 filename` util for nodejs.

License

NotificationsYou must be signed in to change notification settings

jaywcjlove/chmod-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buy me a coffeeCINPM DownloadsNPM version

A simple command line tool for changing file permissions. TheUNIX commandchmod 777 filename for node.

Installation

$ npm install chmod-cli# Or$ npm install --global chmod-cli

Usage

$ chmod-cli --help  A simplecommand line toolfor changing file permissions.  Usage: $ chmod-cli<path> …  Options:    --version, -v   Show version number    --help, -h      Displayshelp information.    --mode, -m      The new permissionsfor the file or directory.                    This can be a numeric mode (e.g. 666),                    or a string mode (e.g.'rwxr-xr-x')  Examples:    $ chmod-cli test.js xxx.js -m 0o777    $ chmod-cli test.js -m 0o777    $ chmod-cli test.js -m 0o777

API

chmod(path, mode, callback)

Changes the permissions of the file or directory at the specifiedpath.

  • path (string): The path to the file or directory.
  • mode (string ornumber): The new permissions for the file or directory. This can be a numeric mode (e.g. 666), or a string mode (e.g. 'rwxr-xr-x').
  • callback (function): A callback function to call when the operation completes. The callback should take one argument, an error object, which will be null if the operation completes successfully.
importchmodfrom'chmod-cli';chmod('./test.txt','666',(err)=>{if(err)throwerr;console.log('File permissions have been changed.');});

File Permissions Explanation

In the numeric notation of file permissions, each digit represents a file permission group (owner permission, user group permission, other user permission). In this notation, the numeric value for each permission is:

  • Read permission:4
  • Write permission:2
  • Execute permission:1

Therefore,777 means:

  • Owner permission:Read (4),Write (2),Execute (1) =4+2+1 = 7
  • User group permission:Read (4),Write (2),Execute (1) =4+2+1 = 7
  • Other user permission:Read (4),Write (2),Execute (1) =4+2+1 = 7

In total, this makes777, which means that the file's owner, members of the same user group, and all other users can read, write, and execute that file. This permission configuration is very open and should be used with caution.

License

This package is licensed under the MIT License.

About

A simple command line tool for changing file permissions, A `chmod 777 filename` util for nodejs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp