Using Mkdir -M -P and Chown Together Correctly

Using mkdir -m -p and chown together correctly

It goes a little like this:

install -d -m 0755 -o someuser -g somegroup /dir/dir2

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)

For what it's worth, before installing Homebrew you will need to install Rosetta2 emulator for the new ARM silicon (M1 chip). I just installed Rosetta2 via terminal using:

/usr/sbin/softwareupdate --install-rosetta --agree-to-license

This will install rosetta2 with no extra button clicks.

After installing Rosetta2 above you can then use the Homebrew cmd and install Homebrew for ARM M1 chip: arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Once Homebrew for M1 ARM is installed use this Homebrew command to install packages: arch -x86_64 brew install <package>

Permissions with mkdir won't work

Yes, it's because of umask...

from comments of docs: http://php.net/manual/en/function.mkdir.php

You might notice that when you create
a new directory using this code:

mkdir($dir, 0777);

The created folder actually has
permissions of 0755, instead of the
specified
0777. Why is this you ask? Because of umask(): http://php.net/manual/en/function.umask.php

The default value of umask, at least
on my setup, is 18. Which is 22 octal,
or
0022. This means that when you use mkdir() to CHMOD the created folder to
0777, PHP takes 0777 and substracts
the current value of umask, in our
case 0022, so the result is 0755 -
which is not what you wanted,
probably.

The "fix" for this is simple, include
this line:

$old_umask = umask(0);

Right before creating a folder with
mkdir() to have the actual value you
put be used as the CHMOD. If you would
like to return umask to its original
value when you're done, use this:

umask($old_umask);

How to change the user and group permissions for a directory, by name?

import pwd
import grp
import os

uid = pwd.getpwnam("nobody").pw_uid
gid = grp.getgrnam("nogroup").gr_gid
path = '/tmp/f.txt'
os.chown(path, uid, gid)

HDFS 'No such file or directory' error when trying to copy csv from one directory to another

-put command looks for yellow_tripdata_2016_01.csv file in local file system not on hdfs.

But your file is in HDFS that's the reason why you are getting that error.

Refer to this link for more details regards to Hadoop -put/-cp/-mv commands.

If you want to copy/move the HDFS file into another HDFS directory use below commands

Copy the file into another hdfs directory:

hadoop fs -cp /user/root/yellow_tripdata_2016_01.csv /user/nyc_taxi/

Move the file into another directory:

hadoop fs -mv /user/root/yellow_tripdata_2016_01.csv /user/nyc_taxi/

Why Docker COPY doesn't change file permissions? (--chmod)

I figured out:

the flag --chmod is a new feature from Docker Buildkit, so it is necessary to run the build enabling it via:

DOCKER_BUILDKIT=1 docker build ./

However, it is really not clear why Docker swallows the --chmod option without any error or warn about the non-existing option .



Related Topics



Leave a reply



Submit