So by default my / directory is chmod 555. I ran the following to test something out:
sudo chmod 777 /
mkdir /dss
sudo chmod 555 / # reset permissions
if I run stat /dss then it shows
File: ‘/dss’
Size: 6 Blocks: 0 IO Block: 4096 directory
Device: 10302h/66306d Inode: 5802557 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 1001/ssm-user) Gid: ( 1002/ssm-user)
Access: 2021-06-30 22:01:44.478434800 +0000
Modify: 2021-06-30 22:01:44.478434800 +0000
Change: 2021-06-30 22:01:44.478434800 +0000
I expected /dss to inherit 777 permissions from / at the time it was created? And if I create any subdirectories under /dss, they're all 755. What's happening here?
You are matching two different things in this question, chmod is a command to set the permissions for a specific path or file, you can do it recursively in differents ways but that you are asking is umask value that determinants the permissions given to a file when is created.
If you want to check the value setting, you have to execute the command “umask”, this could tell you the value as default that the user has to create files.
If you want to change the umask value you can run the following command to set it.
umask 022
Keep in mind that the numbers that are you described in the command above are the permissions that won't give to the file, so, in this case, will be generated with 755.
Please refer to the next table.
Number
Permission
4
read
2
write
1
execute
This command isn’t permanent, once you logout this will be lost and set as default, if you want to change the value in a permanent way you need to set up in “/etc/profile” or “bashrc” and add the command above, you can refer to[1].
BR.
[1] https://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html
Related
I have a file on a server which has a permission like
-rw-rw-r--
Now , I want to set this permission by using chmod or some other way
How to set this permission. I tried using
chmod 700 filename
can any one help me with this ?
When amending file permissions on a given file/directory, you have to set permissions for user (u), group (g) and other (o)
This can be done by specifying the permissions in octal format where:
1 is execute
2 is write
4 is read
So in your scenario, you would need to add the numbers together to get the permissions required for each of u, g and o so:
chmod 664 filename
As an alternative, you can get the permissions in the following format:
chmod u+rw,g+rw,o+r filename
So you can add permissions with + and you can also remove permissions with - e.g.
chmod o-r filename
This would remove read permission from "others"
You should try with chmod 664 <filename>, this will make the permission -rw-rw-r--
I just set up a apache server on my Raspberry pi. To make the development easier I shared the /var/www/html folder with samba.
I'm able to create new files from my computer in the Pi folder, but they have the following permission :
-rwxrw---- 1 pi pi 52 juin 10 17:54 test.php
With those permissions Apache is not able to read the file.
So each time I need to send the following command to make the file readable by Apache :
chmod a+rwx test.php
Then my permission are :
-rwxrwxrwx 1 pi pi 52 juin 10 17:54 test.php
So ok, after sending this command, it's works... But I am trying to find the command to set up the default file permissions to "-rwxrwxrwx "
I'm new with linux so maybe it's easy to fix.... Do you have any ideas ?
Thanks a lot,
Maxime
Thanks for your answers.
the solution was to change the "create mask" value to 0775 in the smb.conf file.
Maxime
For changing default permissions of the file created, you can use umask command. umask is user mask which is used whenever a new file is created.
umask is a three digit number with octal base. First digit decides the user permissions, second is for group while third determines the permissions for others.
umask value is used in inverted/complemented form though. That means to determine the required umask value for the permissions you want, subtract the permissions (in octal form) from 666. The result should be used as your umask value. e.g. if you want to set default permissions to rw-r--r-- (which is 644 in octal) subtract 644 from 666. The result (022) is your umask value.
To set value for umask you can simply use:
umask 022
command.
For your case here, I think you can use
umask 000
The default umask value is 0022, which decides the default permission for a new file or directory. The default permission for a directory is 0777, for files the permissions are 0666 from which the default umask value 0022 is deducted to get the newly created files or directory permission.
Similar to this question, I am unable to unset execute permissions on files after recently upgrading Cygwin.
I have a file with the following permissions:
ls -l filename
-rw-rwxr--+ 1 gstrycker Users 1334935 Jan 26 09:23 filename
I'm trying to get rid of execute privileges, but running chmod -x or even chmod 0 does not seem to work now (note that it always did work for me before -- but I don't believe there were this many columns in the POSIX security permissions)
chmod 0 filename
ls -l filename
----rwx---+ 1 gstrycker Users 1334935 Jan 26 09:23 filename
Why can I not seem to be able to modify this central group of privileges now? I've always been able to before. I even tried to change the group owner, but that didn't seem to help.
I'm stuck -- any ideas? Is this a new Cygwin bug? Did Cygwin recently add columns to the POSIX permissions, and if so, how do I access these?
I'm trying to give read permissions to lighttpd access logfiles to normal users which are on the same system.
The permissions are currently:
-rw-r--r-- 1 www-data www-data 211K Feb 28 11:27 /var/log/lighttpd/access.log
So, if I understood correctly others have read permissions. Unfortunately this doesn't seem to work. If I try to read this file with an user account I get:
/var/log/lighttpd/access.log: Permission denied
I already tried to add the user to the group www-data which didn't work as well.
Any hints what I'm doing wrong here?
To access a file, the system needs the execute permission on all the directories containing the file.
In this case it was necessary to issue the chmod o+x /var/log/lighthttps command (after making sure that the user belongs to the "other" part of the permission set).
The "execute" permission for a directory allows you to enter it. The "read" permission for the directory allows you to see the names of the files inside. The interesting thing is that you can give the x permission alone, what means that anyone can access the files inside, but he needs to know its names.
You might not have execute permission for the lighthttpd so the directory does not give the permission to access its containing file.
Use the command to set the execute permission to that directory.
chmod +x /var/log/lighthttpd
I am running apache with mod mono and my asp.net app is using mono sqlite as its db. When i refresh the page twice i get the DB is locked error. The folder it is in is chmod 777. The webapp is creating sqlite.db and sqlite.db-journal but it doesnt seem to be able to delete the journal. Also it has problems when i load the page once. It definitely seems to be a permission problem.
i'm confused. What permissions do i need to set these? i tried precreating the files using 777 and had no luck.
-edit- I didnt find a solution however i thought how silly i was being since i was planning to use mysql for my webapp. So i just ported the code and i no longer had issues.
When creating/deleting a file the directory permission matter.
So, if you really want that, you have to set the containing directory's permissions to 777.
Sample:
$ ls -la
total 21
dr-xr-xr-x 2 me me 1024 May 22 19:19 . #no write permissions to directory
drwxrwxrwt 21 root root 19456 May 22 19:19 ..
-rwxrwxrwx 1 me me 0 May 22 19:19 abc #all permissions to file abc
$ rm abc
rm: cannot remove `abc': Permission denied #abc has 777, but deleting doesn't work
$ chmod 777 . #change directoy's permissions
$ rm abc #now removing works
$ ls #file abc is gone
The reason is that when you delete a file, you actually modify the directory and not the file itself.
Think of a hard link: The file itself will not change when you delete one hardlink to it, but the directory changes.
Sounds more like one instance of the session in apache is blocking the other session, i.e. has the db file open exclusively. Try to let the database(model) run as a singleton (or similar) which all sessions access.