Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Q1. I tried to configure NFS on client and server and had the following issue.
In Server config file /etc/exports
/var/log client1(rw)
In the client I mounted the file system
#mount -t nfs server:/var/log /mnt
when I try to view the files I am able to view them and read the contents of the file.
When I try to make any changes in the existing file, or create a new file, or delete a existing file, I am getting an error message saying "Only root can do that" or something like "Permission Denied"
Let me know what is wrong here. I mounted the NFS from client as root and accessing the files as a normal user.
You don't mention the Linux distro you're using, so I cannot say for sure, but most distros set the permissions for /var/log and its contents to the owner and group of root:root. Some files and dirs within /var/log are owned by special users. Like 'cups' for the print scheduler logs, etc, but most, if not all, files cannot be modified by regular users. This is basic security so a non-root user cannot delete/modify lines in log files in an attempt to hide bad behaviour.
Also, many files within /var/log are in a opened state by the running process(es) (OS services) that are writing to them, again, like cups, the print scheduler, holds its log files open, so it can write to them quicker. Modifying a log file that is open by a process can cause problems for the process because it may decide its log file is being tampered with.
Attempting to change the permissions on files in /var/log is a bad idea because processes will either not be able, or will refuse, to write to log files with incorrect permissions.
Unless there are good reasons to have the file you want to modify in /var/log, I suggest creating a directory somewhere else in the file system, and share out that directory. You can set the owner of that directory and its contents to the user that will access the files, and NFS will work for you. Keep in mind that the 'user' must have the same uid on both the client and server. In other words, make sure the entries in /etc/passwd on both systems have the same number in field 3 for your user.
Otherwise, to modify files in /var/log, you will need to add to the line in /etc/exports:
/var/log client1(rw,no_root_squash)
and access files from the client as 'root', but I really cannot recommend this.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.