I have installed on my raspberry pi running debian (raspbian) samba and samba-common-bin
Then I change the config of samba and add the following at the end:
[photocam]
comment = Photo taken from camera
path = /tmp/photocam/
valid users = #users
force group = users
create mask = 0755
directory mask = 0755
read only = no
browseable=Yes
writeable=Yes
only guest=no
public=no
I have created a user for samba with sudo smbpasswd -a pi
Then when I try to access it I can only read the files, I can't delete or create new ones...
Ok, really stupid from my part, I have realised that the folder I used and created with root so I had to use chown and chgrp commands to put it to the right user.
Yes you're right use chown command to change users to pi this will change all files in the current directory to
user=pi, group=pi
sudo chown pi:pi *
You may also need to set permissions on the files with chmod command. The following command will change all files in the current directory to
775 = rwxrwxr.x
sudo chmod 775 *
Related
it is in this file:
https://github.com/nathanctung/UCLA-CS-136/blob/1a883e2a6d1014fb5b162b332c867f6b4ef1e461/Assignment%203/submit2-1415097320/part2/patch2.sh
#!/bin/bash
sudo mkdir /home/memo-users # create memo-users directory in /home
sudo groupadd memo-users # create memo-users group and give them ownership
sudo chgrp -R memo-users /home/memo-users
sudo chmod 755 /home/memo-users
# at this point, users can be added to memo-users group
# all users dealing with memos should be added
sudo mkdir /home/memo-users/memo # add the actual dir for storing memos
sudo chmod 775 /home/memo-users/memo
sudo chmod +t /home/memo-users/memo # sticky bit keeps files from arbitrarily deletion
sudo cp fixed.patch /usr/lib/cgi-bin/ # copy the patch over to memo.cgi's dir
cd /usr/lib/cgi-bin
sudo chmod -s memo.cgi # remove root-SUID from memo.cgi altogether
patch < fixed.patch # apply the patch! this may need sudo su - access
This script can prevent different user from change others' memo. But I don't really know in detail what he has done. I can't understand why he set 755 to /home/memo-users but set 775 to /home/memo-users/memo. Could you tell me the purpose and the result of this scipt?
[7 for owner][7 for same group][5 for everyone]
R - read
W - write
X - execute
5 = R(yes)-W(no)-X(yes)
you can visit this directory only if you have R and X permission
7 = R(yes)-W(yes)-X(yes)
you can write sth. inside this directory
Now, you are in the same group with memo-users. You have R&X, so that you can enter /home/memo-users but unable to modify anything in this folder, and you have RWX in /home/memo-users/memo, so you can write sth. in this directory.
You have R+X permision in /home/memo-users is the prerequisite to access /home/memo-users/memo , but you can edit in /home/memo-users/memo is invoked by this directory itself.
This logic is smooth as far as I concerned. You have no permission writing anything in /home, but you can write sth. in /home/you-name right
Linux System: Ubuntu 14.04 LTS
I copy some app (like xxx) to the /opt folder to be used also by another user-accounts. Then to start it I use:
sudo /opt/xxx_folder/xxx
(of course, links to /usr/local/bin or /usr/bin, etc.) to start it;
Problem: I'm storing the results/projects of the app to my local folder ( like /home/myuser/xxx_data). And of course the folder and it's data xxx_data belongs to root (not myuser). So I have to change the owner every time I want to edit those files using another app not as a root.
Question: is there a way to install an app xxx to /opt so, that I don't need to start them as a root?
OR maybe you see another way to solve this 'root-user-problem?'
You can add execute permission to any file like this.
sudo chmod +x file.sh
If you want to do that for all files in that folder try this:
sudo chmod +x /opt/*
Note the +x just adds execute permission to your logged in user. I think all users have read (+r) by default so if you also want to add write permission:
sudo chmod +xw /opt/*
Personally I keep all my custom scripts in a bin folder e.g. /opt/bin/ and just do:
sudo chmod +x /opt/bin/*
To run the script without the full path add the bin or full opt folder to your path by adding the following to ~/bashrc file:
PATH=$PATH:/opt/bin
If you don't end up using the bin folder, edit above to be /opt instead of /opt/bin.
I want my php script to be able to create file, edit, and delete it, so I need to give it permissions to do so in Linux.
I've done this with one of the stackoverflow answers with this code:
sudo chown -R www-data:www-data .
But when I do so, I lose my user access to files - so I can't open them with gedit for example until I change permissions back like so:
sudo chown -R igor /var/www/html/demo/myDir
I think I need to give permission to Apache, but leave my access as well. I feel there is some easy answer to make it work, but I can't find one. Any suggestions?
You are changing the owner of the files, if you want to change the permission of the files without changing the owner you need to use : chmod.
For example if you want to read write and execute on the current folder you can use: chmod 777 .
If what you want is the two users have the same permissions over the folder you could add your user to the group www-data (assuming that you are in the files folder):
sudo usermod -a -G www-data youruser
sudo chgrp -R www-data .
sudo chmod -R 770 .
I have an EC2 instance with some php scripts running on Amazon. The folder with the files has permission 755 (chmod 755 folder).
Everytime I login I have to change the folder permissions to change anything to files.
Question: Is it possible to login as root with cyberduck?
Note: I found this link How to use sudo over SFTP with CyberDuck? , but it is from 2010 and I don't know if that info is accurate or not.
If it is a folder that your user should be able to read and write. Give your user account permissions to it...
1) Create a group
sudo groupadd mygroup
2) Add your user account to that group
sudo usermod -a -G mygroup myuser
3) Change the permissions of the folder such that group has execute/modify
sudo chown -R current_owner:mygroup myfolder
sudo chmod 776 myfolder
It is odd you have to change permissions every time. If this folder is deleted and re-created by another process or user, you will need to set the environment variable umask to 776 before creating the files and folders in your script.
I have problem with accessing the shared folder.
My host OS is Windows 7 Enterprise Edition SP1, and the guest OS is Ubuntu Linux 10.04 Desktop Version. I'm using Virtual Box 4.2.10, and I have installed VBox guest add-on and Oracle VM VirtualBox Extension Pack.
When I put commend:
mat#mat-desktop:~$ cd /media/sf_MAT/
bash: cd: /media/sf_MAT/: Permission denied
again with sudo:
sudo cd /media/sf_MAT/
sudo: cd: command not found
What could be the solution?
The issue is that your user "mat" is not in the same group as "vboxsf". This group "vboxsf" is the group which has read/write permissions to that folder. Also the root has permission to that folder because its in the group "vboxsf".
What you need is to add your user "mat" to the same group. Start your terminal and write the following line:
sudo usermod -aG vboxsf mat
sudo - because you need root permission
usermod - the command to change the user properties
-a means append to the group
-G means you will supply the group name now
vboxsf is the group name that you want your user to be in
mat is your username
A reboot, or a logout, may be required for changes to take affect.
After this operation you can verify that your user is indeed in the vboxsf group by doing this:
cat /etc/group | grep "vboxsf"
you will see your username there.
Now you shall be able to access that folder. If any issue, just comment here and I will tell you alternative methods.
Also, if all of this sounds too geeky, you can do the same thing using the graphical tools. One guide is here http://www.howtogeek.com/75705/access-shared-folders-in-a-virtualbox-ubuntu-11.04-virtual-machine/
Also, in new virtual box - 4.3.20 I guess, they have this new feature of drag and drop where you can just drag files and folders to your virtual machine just by dragging. Isn't that nice. :)
Open your Virtual Machine's Terminal. Type sudo su then enter your password.
Write the following commands
sudo usermod -a -G vboxsf your_account_name
sudo chown -R your_account_name:users /media/your_share_folder_name/
Example sudo usermod -a -G vboxsf mat
Example sudo chown -R mat:users /media/sf_MAT/
Now reboot your Virtual Machine and check the shared folder again
I have this problem to. The problem seems to be with your user account not having permission to use the folders. The only solution I have is to enter root using the su command. You can then read, write, and navigate freely. You might have to set a root password first using sudo passwd root.
Reason : sudo cd will not work as sudo works on program and not command. cd is an inbuilt command.
Soluiton: try sudo -i ..this will elevate you to super user.
Now you will be logged in as root and use any command you wish
eg.
sudo -i
cd folder/path
use exit to return back to normal user.
You only need to follow these steps:
in the terminal execute:
sudo adduser yourUserName vboxsf
enter your root password, expect the following message:
Adding user `yourUserName' to group `vboxsf' ...
Adding user yourUserName group vboxsf
Done.
Log out and back in.
You now can access your shared folders (with the limitations you set for them via VirtualBox)
For all other just add new optical drive in storage(Via setting) and add ISO manually(It is inside installed directory) in Host OS. Now click on mounted drive and install in Guest OS.
Reboot enjoy