Score:0

How to give permission to my current user

sx flag

so basically i want to able to write data using stfp but when I use it. it says permission denied. I want to be able to do it in this directory /home/user so when I use ls -l command it has following output

total 8
drwxr-xr-x 2 root root 4096 Apr 22 21:43 FOLDER1
drwxr-xr-x 2 root root 4096 Apr 22 22:00 FOLDER2

How can i see who is the owner of this dir. I know i can use this cmd chmod a+rw user to give everyone read and write permission to everyone but i just wanna give it to only one user. And there is only one user in system but i might create more in future. I wanna understand concept of owner and groups. Additional questions:- how to see what groups are there. how to create groups and how to add users to that groups.

rɑːdʒɑ avatar
ph flag
TBH, I dont encourage you to do it. Every sftp can access his home directory which should be suffice, if they need access to a specific folder like /var/www/ you can provide, but letting one user accessing another users home directory by chaning permissions, I wont recommend that
Score:1
ai flag
yxz

In your ls -l output, the 3rd and 4th column are the user (owner) and group (owner) respectively, so your folders are both owned by root.

If you run chmod +006 yourfile, this gives all users read and write permission to yourfile. In this case, root owns the folder, so you would need to use sudo (or some other method to issue the command as root). If you only want a single user or a few to have access, you can use chown userowner[:groupowner] (with sudo) to make that user or group the owner of the file and use chmod +600 to give read write to owner and chmod +060 to give read write to group owner.

To list the groups the current user belongs to, use groups username. To list all groups you can use cat /etc/group. getent group also works.

To create a new group, use groupadd.

To add a user to a group, use usermod -Ga groupname username. If you do not use the -a flag, the user username is removed from all current groups and only present in the new group groupname.

mook765 avatar
cn flag
The `ls -l` output OP provided has only three rows, so how it comes that there is some information in the forth row? Also the `command chmod +600 username` will end up with an error message unless a file named `username` exists in the current directory. Also you can't use chmod on a file owned by root without using sudo. Your answer is just wrong in to many points, sorry, but you shouln learn more about permissions and look at the man pages for the commands befor posting an answer.
yxz avatar
ai flag
yxz
sorry I meant the third and forth column. by `username`, I meant to insert OP's username or the username that they want to use. Using `sudo` is something I should have hinted but there are other ways (to become superuser (not that this is recommended)).
mook765 avatar
cn flag
Please take a look at `man chmod`, you need to provide a filename, not a username.
yxz avatar
ai flag
yxz
@mook765 sorry you are right, I got `chmod` and `chown` mixed up
Raffa avatar
jp flag
`groups` without specifying a user will not list the groups present on the system, but rather will print the groups for the current process.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.