Thursday 16 November 2017

Toggle Read-only behaviour of buffer in Emacs

When a file to which you have read access as regular user is opened in emacs, the buffer is marked read-only. If the user escalates to root and opens the same file in emacs, the buffer still remains read-only. To modify the file, the user needs to toggle the read-only behaviour of the buffer (for which the default key binding is C-x C-q) first.

Increasing the maximum number of file descriptors allowed per user on Cent OS 6

For some applications like elasticsearch, the maximum number of file descriptors needs to quite high. The way of modifying the value varies from distro to distro. In Cent OS6, the following did not work.

1. Using sysctl as root
sysctl -w fs.file-max=100000

2. Using ulimit as root

After the above approaches, when you check the value using the following, the value will show up.

cat /proc/sys/fs/file-max

However, setting the values as root, does not change the values for other regular users. To set it specifically for any user, change the value in /etc/security/limits.conf file. Setting only the soft or hard limit will not be sufficient. Therefore, the following lines should be added.

<user> soft nofile <value>

<user> hard nofile <value>

After the modifications, it is required to logout and log back into the system.