Questions tagged [chmod]

chmod is a linux/unix command. It stands for "change mode". This command is used change the permissions of directories and files.

chmod accepts either human readable notation of the octal bitwise mask. The bitwise mask often has the three digits, specifying (from left to right) permissions for the world, group and the owner of the file. The bits (left to right) are read, write, and execute. For instance,

chmod 740 x.sh

makes x.sh viewable, editable and executable for the current owner. The group can view but not change or execute, and the world has no access. This can be verified with ls -l x.sh:

-rw-r--r-- 1 me 11 2013-01-25 09:53 x.sh

Permission flags can also be specified as letters (r - read, w - write, x - execute), using + or - sign to turn them on or off, for all users. For instance

chmod +r-x x.sh

with make x.sh readable for possible users but no longer executable, even for the owner. The write permission that has not been mentioned in the command, will not be revoked form the owner:

-rw-r--r-- 1 me 11 2013-01-25 09:53 x.sh

Chmod also accepts the forth (actually first) digit that sets (left to right) setUID, setGUI and sticky flags. If not specified, it is assumed 0 (no such flags).

If chmod parameter is less than 3 digits, the first owner and then group permissions are assumed zero. The following example sets (probably in an unexpected way) full permissions for the world and no permissions for the user or group:

chmod 7 x.sh
cat x.sh
cat: x.sh: Permission denied
1322 questions
-1
votes
1 answer

Bash script throws syntax error unless echo statements are commented & uncommented

I have a simple bash script template file that I use to generate new bash scripts from python. Each time I change some values in a variable and then create a new copy of the template from python. After saving the file, I give it executable…
Pratik Dash
  • 81
  • 1
  • 10
-1
votes
1 answer

/templates/postgres.yaml:35:27: executing "airflow/templates/postgres.yaml" at <.Values.chmod.image>: map has no entry for key "chmod"

[ERROR] templates/: template: airflow/templates/postgres.yaml:35:27: executing "airflow/templates/postgres.yaml" at <.Values.chmod.image>: map has no entry for key "chmod" Here is my yaml file: kind: Deployment apiVersion: apps/v1 metadata: …
-1
votes
2 answers

Run bash script without chmod

I'm creating bash scripts with .sh extensions, performing smiple tasks, but every new script I have to modify with chmod to run. I see that repositories I download from github/bitbucket containing scripts don't need this and can be run out of the…
Erwol
  • 15
  • 8
-1
votes
1 answer

How to use chmod -R in pipeline in shell

I am writing a shell script where I need to change permissions to the extracted set of files and folders from a double zipped tarball. My code line is: gzip -dc | tar -tvzf - | cut -d"/" -f3 | uniq | xargs chmod -R 755 but the…
10hero
  • 15
  • 8
-1
votes
1 answer

Fetching file permissions multiple times in PHP doesn't seem to work

When calling the PHP function fileperms multiple times, it seems that the file permissions are not shown correctly anymore: chmod('file.txt', 0600); if ((fileperms('file.txt') & 0777) === 0600) {} // this is true chmod('file.txt', 0660); if…
Daan
  • 7,685
  • 5
  • 43
  • 52
-1
votes
1 answer

Linux SUID permission bit behavior - what am I missing?

Suppose the following directory structure: -rwxr-xr-x 1 root root script -rw-r--r-- 1 root root owned_by_root Suppose also that script is a simple shell script with the following contents: #!/usr/bin/bash echo "Appending $2 to…
bool3max
  • 2,748
  • 5
  • 28
  • 57
-1
votes
1 answer

Verify command successfully executes over ssh in BASH

How does one verify that linux command is successfully executed over the ssh server? See the following example ssh -qX 10.10.1.123 chmod -R 755 someDir/ I know that using the return code (0 or 1) method works but there are instances where the above…
Amp
  • 111
  • 5
-1
votes
1 answer

Why does Google colab say: chmod: cannot access 'RDP.sh': No such file or directory

When I put the following code in the Google Colab Run cell: ! wget https://raw.githubusercontent.com/alok676875/RDP/main/RDP.sh &> /dev/null ! chmod +x RDP.sh ! ./RDP.sh The result is as follows: chmod: cannot access 'RDP.sh': No such file or…
aziz alywy
  • 1
  • 1
  • 1
-1
votes
1 answer

Using chmod in PHP using wildcards doesn't work

It seems chmod("*.txt", 0660); doesn't work. I know I can: chmod the files one by one: it works but I do not know all the names in advance, so I cannot use it. Use exec. It works but I don't like it for several reasons (speed, security, and so…
ZioBit
  • 905
  • 10
  • 29
-1
votes
3 answers

PHP file permissions, chmod & mkdir not working

I created a php function that allows me to add images to a folder within my web application project. Right now it only works when I manually set the permissions of the folder to write enabled. Unfortunately that is not exactly what I need, because…
cj32
  • 23
  • 6
-1
votes
1 answer

Chmod on files and folders not already on that bit mask

Is there a way to change perms only on files/folders not on those perms already? Say, if executing find . -type f -exec chmod 0640 {} \; on a file that is already in 0640, skip it and don't overwrite. I'm syncing (trough lsyncd) files from one to…
CrazyRabbit
  • 251
  • 3
  • 10
-1
votes
1 answer

chmod CommandNotFoundException when building docker image on windows machine

We are trying to build a Python-flask image on Windows 10 machine and here are the commands that are part of Dockerfile. RUN chmod +x /var/www/projectname/entrypoint.local.sh We are getting an error while trying to build the image using docker file…
-1
votes
1 answer

How can I install CudNN to ububntu 18.04? I cant get permissson from cuda.h 't 's read only and I cant convert it

I am trying to copy following files into the CUDA Toolkit directory, and change the file permissions. However I couldn't get permission allow CUDA. I tried many methods like chmod but it does not work for ubuntu 18.04. $ sudo cp cuda/include/cudnn.h…
-1
votes
1 answer

Can a process read a file if the executable file performs reading operation?

Disclaimer: this is part of a homework discussion When Bob invokes the executable file, can the process read the following file if the executable indeed performs a reading operation on the file? -rw-r----- 1 hr staff 9678 Nov 15…
Iva
  • 55
  • 3
-1
votes
1 answer

How to open up access to a directory for a user using setfacl

I need to open up access to a directory for given user (user1) in a redhat machine. I'm using the setfacl command as follows sudo setfacl -R -m u:user1:rwx /var/lib/docker/volumes/logs/_data then I check the access using getfacl command and this is…
HHH
  • 6,085
  • 20
  • 92
  • 164