GeForce GTX 1660 Super Nvidia error in ubuntu 22.04 - Failed to set new Fan Speed

I am unable to control the gpu fan speed manually from NVIDIA Settings > Thermal Settings > Enable GPU Fan Settings. After hitting the Apply button it is showing Failed to set new Fan Speed!.
From terminal, the command nvidia-settings -a GPUFanControlState=1 -a GPUTargetFanSpeed=60 showing the error:

suman@GTX1660:~$ nvidia-settings -a GPUFanControlState=1 -a GPUTargetFanSpeed=60

  Attribute 'GPUFanControlState' (GTX1660:1[gpu:0]) assigned value 1.


ERROR: Error assigning value 60 to attribute 'GPUTargetFanSpeed' (GTX1660:1[fan:0]) as specified in
       assignment 'GPUTargetFanSpeed=60' (Unknown Error).


ERROR: Error assigning value 60 to attribute 'GPUTargetFanSpeed' (GTX1660:1[fan:1]) as specified in
       assignment 'GPUTargetFanSpeed=60' (Unknown Error).

GPU Specifications:

suman@GTX1660:~$ nvidia-smi
Thu Jun  2 16:51:53 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.43.04    Driver Version: 515.43.04    CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  On   | 00000000:01:00.0  On |                  N/A |
| 26%   38C    P8    15W / 125W |    259MiB /  6144MiB |      3%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1791      G   /usr/lib/xorg/Xorg                 80MiB |
|    0   N/A  N/A      1888      G   ...ome-remote-desktop-daemon        1MiB |
|    0   N/A  N/A      1935      G   /usr/bin/gnome-shell               27MiB |
|    0   N/A  N/A      2539      G   ...2/usr/lib/firefox/firefox      146MiB |
|    0   N/A  N/A      4905      G   /usr/bin/nvidia-settings            0MiB |
+-----------------------------------------------------------------------------+

Solved this issue by editing the file: /./etc/X11/Xwrapper.config
Steps:

  1. cd /./etc/X11/
  2. sudo -s [because you need root access]
  3. gedit Xwrapper.config &
  4. add the line needs_root_rights=yes before allowed_users=console.

Therefore the Xwrapper.config file will be:

# Xwrapper.config (Debian X Window System server wrapper configuration file)
#
# This file was generated by the post-installation script of the
# xserver-xorg-legacy package using values from the debconf database.
#
# See the Xwrapper.config(5) manual page for more information.
#
# This file is automatically updated on upgrades of the xserver-xorg-legacy
# package *only* if it has not been modified since the last upgrade of that
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command as root:
#   dpkg-reconfigure xserver-xorg-legacy
needs_root_rights=yes
allowed_users=console

Check out this video here if you need any further help.