How to change permission VM shared folder to 777 (drwxrwxrwx)? - linux

I'm using Oracle Linux 5.7 x86 on Virtual Box 5.1.8 Window 10 x64. I have shared a host folder Temp with VM and can access it and trying to copy its contents to VM but stuck at;
[root#localhost ~]# cd /downloads
[root#localhost downloads]# cp /media/sf_Temp/*.zip
cp: target `/media/sf_Temp/V25347-01.zip' is not a directory
[root#localhost downloads]#
I guess I'll need to change the permissions of shared folder to 777 (drwxrwxrwx) but cannot. Is chmod 777 /media/sf_Temp right command for this?
[root#localhost sf_Temp]# ls -ld /media/sf_Temp
drwxrwx--- 1 root vboxsf 12288 Oct 25 20:46 /media/sf_Temp
[root#localhost sf_Temp]# ls -ld /downloads
drwxrwxrwx 2 root root 4096 Oct 26 19:14 /downloads
[root#localhost sf_Temp]#

You are already root, you don't need any other permissions.
cp command needs two arguments, one for target file/folder, one for destination.
cp origfile newfile
http://www.computerhope.com/unix/ucp.htm

Related

Unable to write to a file with group permissions

We are getting the error "permission denied" when trying to write to a file that is owned by a service user and a shared group. In particular that is www-data:www-data and the user trying to write to it is in the group www-data.
There is no acl on none of the parent folders and the permissions to the file and folders are correct.
Here some details:
$ sudo -u deploy id -Gn
www-data
$ ls -lah /tmp
drwxrwxrwt 17 root root 4.0K Jul 11 11:22 .
drwxr-xr-x 23 root root 4.0K Jul 8 10:08 ..
...
-rw-rw-r-- 1 www-data www-data 0 Jul 11 10:50 test
...
$ echo 'hello world' | sudo -u deploy tee -a /tmp/test
tee: /tmp/test: Permission denied
hello world
we tried that on different folders and made sure there is no acl on any of the folders or parents or files...
Unfortunately that is not described in the link stark posted in the comment. And also not in any other page I found until I found an answer here on stackoverflow that clarified it.
2018 two new filesystem configurations got added to sysctl that should prevent regular files and fifos from beeing opened with the O_CREAT flag (as append mode is doing) in directories with the sticky bit set unless the user is the owner of the file. This commit added the settings: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=30aba6656f61ed44cba445a3c0d38b296fa9e8f5
To change that behaviour you have to set fs.protected_regular to 0:
sudo sysctl fs.protected_regular=0
Or to persist the change add fs.protected_regular=0 to your sysctl.conf.
side node: since O_CREAT is not deleting or renaming the file I'm wondered why it is connected to the sticky bit. It really is possible to create a file in directories with the stick bit set.

add write access to user ubuntu - shared folder cifs-utils

I have folder in /media on ubuntu - shared from windows via fstab and cifs-utils. Can I share this folder to other user: "miki" (not root)
root#localhost:/media#
drwxr-xrwx 4 root root 4096 Nov 15 12:21 .
drwxr-xr-x 23 root root 4096 Nov 14 06:34 ..
drwxr-xr-x 2 padm root 0 Nov 15 09:34 Archive
drwxr-xrwx 2 root root 4096 Feb 25 2019 kekik
I have try with:
root#localhost:~# sudo chmod -R 757 /media/Archive/
but get:
chmod: changing permissions of '/media/Archive/': Permission denied
Find a solution:
need to modify /etc/fstab by changing:
//windowsServer/Archive /media/Archive cifs username=wundowsuser,password=somepass,uid=1000,iocharset=iso8859-1,rw,file_mode=0777,dir_mode=0777,vers=1.0 0 0
and change group of folder (must umont it first!)
sudo umount -l /media/Archive
sudo chown miki:miki /media/Archive/

Apache user can't create files in 777 directory

I'm not using SELinux, and still I can't get the apache user to create files in my cache storage directory. Can this work without using chown to change the user to the actual apache user?
[root#server live_storage]# getenforce
Disabled
[root#server live_storage]# su -s /bin/bash -c 'touch /home/admin/live_storage/c50d02d942c0a3d.cache' apache
touch: cannot touch ‘/home/admin/live_storage/c50d02d942c0a3d.cache’:
Permission denied
[root#server admin]# ls -lsa
total 84
4 drwx------. 10 admin admin 4096 24 mei 10:32 .
4 drwxr-xr-x. 3 root root 4096 9 mei 11:12 ..
4 drwxrwxrwx 3 admin admin 4096 24 mei 10:33 live_storage
[admin#server live_storage]$ touch '/home/admin/live_storage/c50d02d942c0a3d.cache'
[admin#server live_storage]$ ls '/home/admin/live_storage/c50d02d942c0a3d.cache'
/home/admin/live_storage/c50d02d942c0a3d.cache
Figured it out. Apache didn't have execute rights on the /home/admin directory. chmod +x /home/admin fixed the problem

Cannot delete file on cifs share

I downloaded a file on a cifs share under Linux Mint with the user "gab". I had to format this computer and I reinstalled Mint. I cannot delete the files that were downloaded with the first Mint. Here's what I've tried.
sudo chmod 777 folder //permission denied
sudo chown gab folder //permission denied
Tried both with root access aswell, same result. On Windows, if I try to delete the folder it gives the error: You require permission from Unix user\1000 to modify this file. If I try changing the owner/permissions on windows, I get an access denied error. Here's a ls -la of the folder:
ls -la '/media/yoshi_share/Torrents/delete_me' total 1015132
drwxrwxr-x 2 gab gab 0 May 21 03:12 .
drwxrwxrwx 15 gab 702 0 May 30 00:19 ..
-rw-rw-r-- 1 gab gab 92 Dec 13 00:20 some_file.txt
-rw-rw-r-- 1 gab gab 1038470195 Dec 13 00:20 some_file.mkv
I've mounted the share using uid=gab and uid=1000 because it was originally created this way. Still no luck with chmod or chown.
I was able to delete the file. I'm new to linux and I found out I had monted the share on the first OS using NFS. I remounted with nfs and was able to delete the files.

Unix files permissions depending on path(?)

I have a directory cyanspring with a nohup.out file.
drwxr-xr-x 12 usr1 usr1 4096 Aug 20 13:59 cyanspring
Owner of the file is able to read it:
[root#lw414 usr1]# sudo -u usr1 ls -l cyanspring/nohup.out
-rw-r--r-- 1 usr1 usr1 30617 Aug 20 14:00 cyanspring/nohup.out
When I try to read it with another user, I get Permission denied.
[root#lw414 usr1]# sudo -u zabbix ls -l cyanspring/nohup.out
ls: cannot access cyanspring/nohup.out: Permission denied
If i go inside the directory, I am able to read the file with the same user who had "Permission Denied".
[root#lw414 usr1]# cd cyanspring
[root#lw414 cyanspring]# sudo -u zabbix ls -l nohup.out
-rw-r--r-- 1 usr1 usr1 30617 Aug 20 14:00 nohup.out
Absolute path doesn`t work as well.
I thought it doesn`t matter where you try to access the file from as long as you have the link and permissions. Can anybody give me a hint where I am wrong? Could it be because of outer folders permissions?
You got "Permission denied" because user zabbix does not have search permission to lachesis directory.
This can be fixed by starting this command from lachesis directory:
sudo chmod go+x .
Permissions are calculated for each directory beginning from current directory if you give relative path, or beginning from root, if you give absolute path.

Resources