Linux files ownership and permissions [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have Linux VPS and few accounts there. I used SSH with root logins to copy files from one account to another (e.g. in this folder
/home/firstacc/public_html/forum I typed cp -R * /home/secondacc/public_html/community).
Now when I use regular FTP to edit files on secondacc - I can't modify it - SmartFTP says permission denied. Now how do change ownership or permissions so they can be edited via regular FTP ?

use chmod to set the permissions (but be careful not to allow any wild process to modify your files) and chown/chgrp to change ownership/group-membership of your file.
ideally you would create a group (i call it 'fancyhomepage') where both users are members thereof:
# addgroup fancyhomepage
# adduser firstacc fancyhomepage
# adduser secondacc fancyhomepage
then make sure that all files you want to share belong to this group and are group-writeable
$ chgrp -R fancyhomepage /home/secondacc/public_html/community/
$ chmod -R g+rwX /home/secondacc/public_html/community/

$ chown -R <user>:<org> on the directory changes the permissions for everything in the directory and below.

Related

Could not chdir to home directory after create a user [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 years ago.
Improve this question
I've created a user in Ubuntu 16.04 using the commands
sudo useradd peris
sudo passwd peris
Then I log off, ans log in with the new user but I got this error:
Could not chdir to home directory /home/peris: No such file or directory
To automatically create the user's home directory you have to call:
sudo useradd -m peris
From now on, the best you can do is manually create the user's home directory using:
sudo mkdir /home/peris
And set the user's home directory so the system actually knows where to go. This can be done using:
sudo usermod -d /home/peris peris
Also, you want to make sure the said user has rights on his own folder. Use:
sudo chown peris:peris /home/peris

Create a SFTP user to access only one directory. [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I need to create a user which can only SFTP to specific directory and take a copy of some infomation. that is it. I keep looking online and they bring up information about chroot and modifying the the sshd_config.
So far I can just
add the user "useradd sftpexport"
create it without a home directory "-M"
set its login location "-d /u02/export/cdrs" (Where the information is stored)
not allow it to use ssh "-s /bin/false"
useradd sftpexport -M -d /u02/export/cdrs -s /bin/false
Can anyone suggest what am meant to edit so the user can only login and copy the file off?
I prefer to create a user group sftp and restrict users in that group to their home directory.
First, edit your /etc/ssh/sshd_config file and add this at the bottom.
Match Group sftp
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
This tells OpenSSH that all users in the sftp group are to be chrooted to their home directory (which %h represents in the ChrootDirectory command)
Add a new sftp group, add your user to the group, restrict him from ssh access and define his home directory.
groupadd sftp
usermod username -g sftp
usermod username -s /bin/false
usermod username -d /home/username
Restart ssh:
sudo service ssh restart
If you are still experiencing problems, check that the directory permissions are correct on the home directory. Adjust the 755 value appropriately for your setup.
sudo chmod 755 /home/username
EDIT: Based on the details of your question, it looks like you are just missing the sshd_config portion. In your case, substitute sftp with sftpexport. Also be sure that the file permissions are accessible on the /u02/export/cdrs directory.
An even better setup (and there are even better setups than what I am about to propose) is to symlink the /u02/export/cdrs directory to the user home directory.
You could need to add a restricted shell for this user can put some files there. You can use rssh tool for that.
usermod -s /usr/bin/rssh sftpexport
Enable allowed protocols in config /etc/rssh.conf.

Linux set permission to a folder and all it's sub files or folders [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
i am using fedora and a folder i want to set permission public every one read write
chmod -R 755 /directory
chmod owner group world FileName
and other's but can't work
how i can give public permission to every one one of my folder and every thing under it to other users
thanks
Following two commands will ensure your purpose
chmod -R 755 /directory
chown -R owner.group /directory
This will give read permissions to everyone. You may be facing issue due to wrong ownership. If the file is not very sensitive, you can also use:
chown -R nobody.nobody /directory ( No body means anyone )
use command chmod -R 777 yourdirectory

Can't edit a read-only file for which I have the write access and also can not change its permission; how to remount its parent folder? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I need to edit a file which is read only. This file is located at a remote appliance. Through ssh I logged in to this as admin and I have the root access.
Command "ls -l" show the permissions of file as
"-rwxr-xr-x 1 admin root 952 Oct 30 02:01 file.sh"
I am not as such familiar with Linux but I searched and found that this above line means that the admin is the owner and he/she has the read and write permission.
But the file is appearing to be read only, I am unable to edit it. So I tried to change the permission using command chomd
[admin#appliance targetfolder]# chmod 666 file.sh
chmod: changing permissions of `file.sh': Read-only file system
But still it is just read-only.
Someone suggested to remount the folder which contains this file.
How will I remount it, I used
" mount -o remount,rw /folde1/folder2/targetFolder"
but It gave
"mount: can't find /folde1/folder2/targetFolder in /etc/fstab or /etc/mtab".
Problem is solved, I remounted folder by using "mount -o remount,rw /" and then edited the file, without changing any permissions, it worked.

Why can't I access this folder? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
A while back I bought a 1TB USB external drive. I formatted it ext4 in Ubuntu and copied a bunch of files / folders to it from several machines, all to /home/machinename/whatever, respectively.
At some point I ran a chmod -R shell command on it to change the permissions. That was months ago and I don't remember what I typed but it made the drive so I could only access its /home folder as root. This wasn't a problem because I could still access everything, but today I decided to try to fix it.
I went to my shell as root, went to that drive and typed:
chown -R rick:rick ./
chmod -R 666 ./
It seemed to work. That home directory and everything else in it now shows up as rw for each:
rick#rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ ls -l
drw-rw-rw- 7 rick rick 4096 2012-03-04 13:08 home
So, if I try to access that directory with the shell, I get:
rick#rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ ls -l
drw-rw-rw- 7 rick rick 4096 2012-03-04 13:08 home
rick#rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ cd home
bash: cd: home: Permission denied
rick#rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ _
When I access it with nautilus I can see the multiple machine names within the /home/ folder, but they all appear with a file icon. I can right-click on them and choose "Properties" but it won't let me see the permissions.
Am baffled. Why can't I access that folder? I'm the owner? I'm even the group. I have r/w privileges. What am I doing wrong?
You're neither trying to read (list) nor write (create a new entry) the directory. You want to enter it, therefore you need (slightly misnamed in the case of directories) exexute permissions.

Resources