Change permission of mnt directory files - linux

I am not able to change the permission of files inside mnt directory.
Only owner (mysql) is having the rights to rwx but I am logged in using root still it is not able to change the permissions.
Is there any way of doing this?

First, it should be chmod -R 777 jol_main with -R, not -r.
Second, it seems that jol_main is on partition that is mounted as read-only. You can remount it as read-write with:
sudo mount -o remount,rw /dev/sdd3 /mnt/usb
( or without sudo if you are already a root )

Related

Unable to change directory or file permission [chmod question]

I am trying to change the permission of a file to 444 (read-only).
This directory resides in a NTFS drive. All files in this drive seem to be owned by root.
This is the present permissions for the directory.
drwxrwxrwx 1 root root 0 Jul 23 11:41 xxx_directory
I've tried sudo bash and then execute chmod 444 xxx_directory to no avail.
The expected outcome was dr--r--r-- for xxx_directory.
Thoughts? Thank you.
The directories need at least R-X
First, create a mount point in a terminal using 'mkdir'. Then, type the following line to mount the partition with options 'permissions':
sudo mount /dev/sdXN -t ntfs-3g -o permissions [Mount point]
Example:
sudo mount /dev/sdb1 -t ntfs-3g -o permissions /media/Data/
Then, you will be able to edit the permissions of the files on the NTFS partition with 'chmod' and 'chown' !
Check thia reference LINUX - MOUNT NTFS PARTITION WITH PERMISSIONS
You should at least require the x permission for directories otherwise you won't be able to cd into it.
You can specify the permissions (via fmask and dmask) while mounting the partition ( or in fstab if an entry is there).
An example of an fstab entry :
#mounting by UUID
UUID=<partition UUID> /mount/point ntfs-3g user,uid=1000,gid=1000,dmask=0022,fmask=0033
This would give all directories in that partition drwxr-xr-x parmissions. Any file created will get .rw-r--r-- permissions. And the ownership would be by the user with uid 1000 so he can change permissions (without sudo)

Restrict access on a mounted device (Linux)

The challenge is to allow access to only one directory on the mounted device for all users.
I have an external hard drive. I mount it using the command
sudo mount -o umask=0007,gid=0,uid=0 /dev/sdb1 /mnt/SAMSUNG/
I need to make one directory available for reading/writing to other users on this device. I cannot do this via sudo chmod 777 /mnt/SAMSUNG/my_directory, the command has no effect.
Is there some other way to do this? Maybe I'm doing something wrong?
When mounting the NTFS file system (/mnt/SAMSUNG/), there is no possibility of mounting a specific directory.
In your sudo chmod 777 /mnt/SAMSUNG/my_directory command you give
The user, rwx (Read, Write and Execute) permissions
The group, rwx permissions
And Everyone else rwx permissions
Inside of /mnt/SAMSUNG/my_directory is the thought that there should be more directories that is specific for other accounts?
If that is the case and the users are local you could do something like this:
sudo chown someuser:someuser /mnt/SAMSUNG/my_directory/someusersdir && sudo chmod 770 /mnt/SAMSUNG/my_directory/someusersdir

User cannot create file linux

may I know a command for root to change the mode to make the user able to create files.
I tried multiple times but I can seem to solve it.
[root#master ~]# useradd -d /opt/hadoop hadoop
useradd: cannot create directory /opt/hadoop
What are the permissions on /opt/hadoop? If you created the directory manually as root then it's probably owned by root and the user has no access to it - you'd need to chown -R it to the correct ownership.
chmod 755 /opt
chown root /opt
chmod 755 /opt/hadoop
chown -R user:user /opt/hadoop

mongodb & /data/db directory permissions

I'm trying to run mongod with its defaults so it's using the /data/db directory. I changed the owner of the data directory
sudo chown mongodb:mongodb /data -R
Like so many others i got the following error when first running mongod.:
2017-04-11T12:32:25.932-0500 I STORAGE [initandlisten] exception in initAndListen: 28596 Unable to determine status of lock file in the data directory /data/db: boost::filesystem::status: Permission denied: "/data/db/mongod.lock", terminating
Which makes sense but what doesn't make sense is the only way i can actually run it mongod is if i:
chmod 777 /data -R
If i
chmod 666 /data -R
i get the same error. Since this is supposed to be the data directory why does it require execute permission.
i added my user to the mongodb group
sudo usermod -g mongodb myuser
and then i tried
chmod 770 /data -R
and its still failing even through i'm a member of the mongodb group.
Why am i messing with all this? Because i want to secure the data directory appropriately and don't want to have to run with 777 security.
So the questions are:
Why is execute permission required
Why am i unable to run it when i was a member of the mongodb group?
Directories need to have execute permission, but the files within the directories do not need execute permission. Also, as noted by #franklinsijo, -R should be the first parameter to chmod.
To fix things I would do the following:
$ sudo chmod -R 770 /data
$ sudo find /data -type f -exec chmod 660 {} \;
This will first give everything under /data execute permission, and then return all the normal files to having only read and write, but not execute.

mkdir: cannot create directory `pgsql': Permission denied

I want to create directory like below:
ajs#ajs-HP-Compaq-dc5800-Small-Form-Factor:/usr/local$ mkdir pgsql
mkdir: cannot create directory `pgsql': Permission denied
But I am getting error:
Permission denied
How can I resolve and create directory pgsql in this location /usr/local$
Kindly suggest me, hope for reply.
Thanks
You have to check your user name to have permission for creating directory in the folder /usr/local$
Check your permission for the folder by the command
ls -ltr /usr
Link to refer about file permissions.
You are getting a Permission denied error because you do not have access rights to create a directory in /usr/local. You can determine the access rights for these directories by using the stat command. The output will look something like this.
$> stat -c '%n %A %G %U' /usr /usr/local
/usr drwxr-xr-x root root
/usr/local drwxr-xr-x root root
Now double check who you are. You can use the whoami command or the id command invoked below twice to reveal both username and group.
$> id -un; id -gn
In the stat output, root:root owns both /usr and /usr/local and only the owner may create (write) new directories based on the access rights. In order to create the directories, I'd recommend either becoming root or trying the command with sudo. If this is not possible, I'm afraid you'll have to create the directory elsewhere or contact the administrator of that machine.
You probably have to be root to do such things in /usr/local.

Resources