Accidentally removed my common-session file

Linode Staff

Hi,

I accidentally renamed /etc/pam.d/common-session file to common-session.tmp using mv command instead cp before linux update.

Now I can't do anything and am receiving the error:

 sudo: unable to initialize PAM: No such file or directory

can you please help me to recover this common-session file?

2 Replies

Hey there,

You should be able to recreate this file and reboot your system to resume operation as normal. This process is going to require you to boot into Rescue Mode by clicking on the “Rescue” tab from your Linode’s Dashboard and selecting “Reboot into Rescue Mode”.

https://www.linode.com/docs/troubleshooting/rescue-and-rebuild/#booting-into-rescue-mode

Once your Linode is booted into rescue mode you can access the terminal through Linode’s LISH console on the “Remote Access” tab by clicking “Launch Lish Console »” at the bottom of the screen. At this point you will be treated by a terminal prompt that looks like this:

 Welcome to Finnix!

 [*] Total memory: 1998MiB, shared ramdisk: 1543MiB
 [*] Loading probed module: sysmodules: /lib/modules/4.1.2-finnix/modules.alias:y
 [*] Finnix media found at sdh
 [*] System: Intel Xeon E5-2697 v4 2.30GHz
 [*] Running Linux kernel 4.1.2-finnix on x86_64
 [*] Finnix 111 ready; 464 packages, 146M compressed

 root@ttyS0:~#

https://www.linode.com/docs/platform/manager/using-the-linode-shell-lish/#use-a-web-browser

Once you reach this screen you will want to go ahead and mount the disk that contains your file system. This us usually done with the command below:

 mount -o exec,barrier=0 /dev/sda

Next you will need to change root to the disk that you’ve just mounted using the command below:

 chroot /media/sda /bin/bash

Once you’ve successfully changed root to that file system your prompt will change to:

 root@finnix 

From this prompt you can make adjustments to the disk that you’ve just mounted. To recreate your common-sessions file you can run the command below:

   nano /etc/pam.d/common-session

Once you are in the nano text editor you can copy the default common-sessions file, expressed below, into the window. Pass the [ctrl]+[x] command to exit, the [y] command to save changes, and [enter] to verify the name /etc/pam.d/common-session.

 #
 # /etc/pam.d/common-session - session-related modules common to all services
 #
 # This file is included from other service-specific PAM config files,
 # and should contain a list of modules that define tasks to be performed
 # at the start and end of sessions of *any* kind (both interactive and
 # non-interactive).
 #
 # As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
 # To take advantage of this, it is recommended that you configure any
 # local modules either before or after the default block, and use
 # pam-auth-update to manage selection of other modules.  See
 # pam-auth-update(8) for details.

 # here are the per-package modules (the "Primary" block)
 session    [default=1]         pam_permit.so
 # here's the fallback if no module succeeds
 session    requisite           pam_deny.so
 # prime the stack with a positive return value if there isn't one already;
 # this avoids us returning an error just because nothing sets a success code
 # since the modules above will each just jump around
 session    required            pam_permit.so
 # The pam_umask module will set the umask according to the system default in
 # /etc/login.defs and user settings, solving the problem of different
 # umask settings with different shells, display managers, remote sessions etc.
 # See "man pam_umask".
 session optional            pam_umask.so
 # and here are more per-package modules (the "Additional" block)
 session    required    pam_unix.so
 session    optional    pam_systemd.so
 # end of pam-auth-update config

Now you should be able to reboot your Linode normally, from the button that says “reboot” on your Linode Dashboard under the “Dashboard” section, and log in using SSH as you normally would and be able to pass sudo commands.

I hope this helps, let us know if you have any issues with this process or still receive the error:

      sudo: unable to initialize PAM: No such file or directory

After this process has been completed.

Thanks,
Matt Watts
Linode Support Team

★★★★★★★★★★+
I can sudo it again :)
Thanks!!!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct