chmod
chmod(path, mode)
Change the permissions mode of path
to mode
. Only integer mode
s (e.g. 0o777) are currently supported.
Examples
-
Change file permissions:
julia> chmod("/path/to/file.txt", 0o644)
This example changes the permissions of the file located at "/path/to/file.txt" to
0o644
. The0o
prefix indicates an octal number. -
Set executable permission for a directory:
julia> chmod("/path/to/directory", 0o755)
It changes the permissions of the directory located at "/path/to/directory" to allow read, write, and execute permissions for the owner, and read and execute permissions for others.
- Restrict permissions to the file owner:
julia> chmod("/path/to/file.txt", 0o600)
This example sets the file permissions to
0o600
, which grants read and write permissions only to the owner of the file.
Common mistake example:
julia> chmod("/path/to/nonexistent_file.txt", 0o644)
ERROR: SystemError: chmod: no such file or directory (ENOENT)
In this example, the function throws an error because the provided file path does not exist. Make sure to provide the correct path to an existing file or directory when using chmod
.
See Also
abspath, basename, chmod, countlines, cp, ctime, dirname, download, evalfile, expanduser, fdio, filemode, filesize, functionloc, gperm, homedir, include_string, isabspath, isblockdev, ischardev, isdir, isdirpath, isexecutable, isfifo, isfile, islink, ismount, ispath, isreadable, issetgid, issetuid, issticky, iswritable, joinpath, less, lstat, mkdir, mkpath, mktemp, mktempdir, mtime, mv, normpath, operm, poll_fd, poll_file, readall, readcsv, readdir, readdlm, readlines, readlink, realpath, relpath, rm, splitdir, splitdrive, splitext, stat, symlink, tempdir, tempname, touch, truncate, uperm, watch_file, writecsv,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.