ls and chmod not working on a nfs mounted file - linux

I mounted a directory using nfs. I am able to cd into the mounted directory and able to list the
one file in the directory. But when I try a ls -li on the file, it keeps failing with
ls: rst_dst/testnew1: Permission denied.
I tried to chmod the file but it keeps failing with chmod: failed to get attributes of 'rst_dst/testnew1': Permission denied. Even the stat command keeps failing with 'Unable to stat the file'.
I tried a sudo ls/chmod but it fails with the same errors.
I am able to chmod the file on the actual machine hosting the directory. But unable to read/write/modidy the permissions through the mounted directory.
Am I missing something?

On hosting machine check file /etc/exports which permissions you allow.
On guest machine check your mount command or line in /etc/fstab with which permissions you are mounting it.

Related

Lost permission after chmod command

I accidentally executed the following command:
chmod -rwxr-xr-x folder_name
And after the command, I was not able to access the folder folder_name. I'm wondering if there is any way that I could recover the full permission to the folder.

Can't upload an image to my server

I would like to upload my logo image to the website. To upload it to the Linux server from my computer, i created a directory "media" in the /var/www/html and tried this command:
scp /Users/kateryna/Desktop/my_site/pics/Logo.png root#95.142.160.135:/var/www/html/media
After this I entered the password to the server and then nothing happened, I got an error:
/Users/kateryna/Desktop/my_site/pics/Logo.png: No such file or
directory
.... even though the file exists on my machine.
Why does it happen? maybe I need to give some sort of permission? I read in one of the articles that to allow an upload, my folder permissions must be set to 777 with the command sudo chmod 777 /path/to/upload/folder... tried that for a different directory and didnt work either:
root#production-381d063e:~/new/myMedia# sudo chmod 777 /root/new/myMedia
-bash: sudo: command not found
root#production-381d063e:~/new/myMedia# chmod 777 /root/new/myMedia
root#production-381d063e:~/new/myMedia# scp /Users/kateryna/Desktop/my_site/pics/Logo.png root#95.142.160.135:/root/new/myMedia
root#95.142.160.135's password:
/Users/kateryna/Desktop/my_site/pics/Logo.png: No such file or directory
root#production-381d063e:~/new/myMedia#
Thanks so much!!!!!

Locked out of cifs mounted storage

I've been using this line in /etc/fstab for mounting a storage device to my host:
//url.to-my-storage.com/mystorage /mnt/backup cifs
iocharset=utf8,rw,credentials=/etc/backup-credentials.txt,uid=1000,gid=1000,file_mode=0660,dir_mode=0770
0 0
I was mounting it to another host, and I ran this to protect the files from change through the new host:
chmod -R 444 /mnt/backup
(I tried to protect the storage from writing from this host, which turned out to change the mode of all the storage files)
I assume the missing executable permissions what causing me this:
$ sudo mount -a
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
I tried unmounting and mounting again, that didn't help, got the same permission error when using the mount command.
ls the dir shows this:
$ ls -la /mnt/backup
?????????? ? ? ? ? ? backup
HELP !
Dismounting a "Locked Out" Network Drive
To dismount a "locked out" network drive, you can try to force the unmount:
umount -f -t cifs /mnt/backup
If you are having trouble dismounting a drive, make sure that you don't have a console open somewhere where the current working directory (CWD) on the drive which you are trying to dismount, or have a file open in an editor or player somewhere or such.
Properly Mounting a Network Drive
You should add your permissions in your mount options rather than trying to apply them afterwards. You would want to replace these mount options:
rw,file_mode=0660,dir_mode=0770
with
ro
Currently you are mounting your CIFS drive as read-write (rw), giving files read-write permission (file_mode=0660) and directories read-write-execute (dir_mode=0770). Simply mounting the drive as read-only (ro) should suffice. (If you do need to fine tune the file and dir modes, rather use umask.)
I would also advise you to double check whether you are using uid and gid correctly: if the user ID or group ID used gets deleted, that could also lead to problems.
References
https://linux.die.net/man/8/mount
https://en.wikipedia.org/wiki/File_system_permissions
https://oracletechdba.blogspot.com/2017/06/umount-lsof-warning-cant-stat-cifs-file.html
https://stackoverflow.com/a/40527234/171993

Permission Denied to write /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger

I am trying to run the following command on my Ubuntu machine
root#manav-R761-c:/# ls -la /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
ls: cannot access /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger: No such file or directory
root#manav-R761-c:/#
root#manav-R761-c:/# echo 'hash:stacktrace:bytes_req,bytes_alloc' > /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
bash: /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger: Permission denied
I am logged in as root, then why I am not able to create trigger file and write to it?

ant Permission Denied problem

After extracting and saving the ant files into an opt/ directory and setting the path variable
to $ANT_HOME/bin
I ran the following command on a CentOS 5
ant -version
and I am getting the following error
-bash:/path/opt/apache-ant-1.8.2/bin/ant: Permission denied
Is there some permission I am supposed to set or some typical source of this problem?
Thanks!
If you own the file, try
chmod u+x /path/opt/apache-ant-1.8.2/bin/ant
If someone else owns it, either sudo or become root then
chmod 755 /path/opt/apache-ant-1.8.2/bin/ant
You need to have execute permissions on the file; the first gives execute permissions to the owner only and is probably preferable if you own the file and are the only one that uses it. The second requires root privileges and gives execute and read permission to everyone, plus write permission to the owner.
You can view the current permissions and ownership of the file by running ls -l /path/opt/apache-ant-1.8.2/bin/ant.

Resources