1

I've installed GNOME on my CentOS 6.8 server, i log in via NOMACHINE NX software from windows. Even if i use my normal user and password when i log in i'm root. I don't want to be root. I must have made some change on the linux config to get this behavior. I know i added my user to groups like "admin", "root", and "wheel" before because i was tired of being asked the password all the time. I edited sudoers and uncommented

%wheel ALL=(ALL)       NOPASSWD: ALL

But at some point i realized i wasn't my user anymore, even if i logged in with my credentials i was always root. Now i'm trying to get back as a normal users and i can't.

I commented back sudoers. My sudoers.d is empty. I've removed all groups from my user except the user group. I tried sudo su via ssh and i get:

user is not in the sudoers file.  This incident will be reported.

I don't understand what else can i do to log in as normal user on GNOME?


Requested info:

grep myuser /etc/passwd

myuser:x:502:502::/home/myuser:/bin/bash

Requested info 2:

grep root /etc/passwd

root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

# are we an interactive shell?
if [ "$PS1" ]; then
  if [ -z "$PROMPT_COMMAND" ]; then
    case $TERM in
    xterm*)
        if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
            PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
        else
            PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
        fi
        ;;
    screen)
        if [ -e /etc/sysconfig/bash-prompt-screen ]; then
            PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
        else
            PROMPT_COMMAND='printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
        fi
        ;;
    *)
        [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
        ;;
      esac
  fi
  # Turn on checkwinsize
  shopt -s checkwinsize
  [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
  # You might want to have e.g. tty in prompt (e.g. more virtual machines)
  # and console windows
  # If you want to do so, just add e.g.
  # if [ "$PS1" ]; then
  #   PS1="[\u@\h:\l \W]\\$ "
  # fi
  # to your custom modification shell script in /etc/profile.d/ directory
fi

if ! shopt -q login_shell ; then # We're not a login shell
    # Need to redefine pathmunge, it get's undefined at the end of /etc/profile
    pathmunge () {
        case ":${PATH}:" in
            *:"$1":*)
                ;;
            *)
                if [ "$2" = "after" ] ; then
                    PATH=$PATH:$1
                else
                    PATH=$1:$PATH
                fi
        esac
    }

    # By default, we want umask to get set. This sets it for non-login shell.
    # Current threshold for system reserved uid/gids is 200
    # You could check uidgid reservation validity in
    # /usr/share/doc/setup-*/uidgid file
    if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
       umask 002
    else
       umask 022
    fi

    # Only display echos from profile.d scripts if we are no login shell
    # and interactive - otherwise just process them to set envvars
    for i in /etc/profile.d/*.sh; do
        if [ -r "$i" ]; then
            if [ "$PS1" ]; then
                . "$i"
            else
                . "$i" >/dev/null 2>&1
            fi
        fi
    done

    unset i
    unset pathmunge
fi
# vim:ts=4:sw=4
  • Hey, On GNOME on the top right corner it says root. If i click system it says log out root. On the desktop instead of my user's folder i see root's folder and i can browse it. – Michael Rogers Jun 30 '17 at 16:01
  • 1
    ... Did you at some point alter your UID to 0 in /etc/passwd ? – Shadur Jun 30 '17 at 16:09
  • I bet the UID for your user is 0. grep <your-username> /etc/passwd and add that output to your question. – Thomas Jun 30 '17 at 16:11
  • I don't think i did i added the output of that command to my question, please let me know if you have more ideas or tests to run. – Michael Rogers Jun 30 '17 at 16:20
  • What if you grep root /etc/passwd? I would also look in /var/log/secure for clues. Maybe something in your ~/.bashrc or ~/.bash_profile (or /etc/bashrc and other system wide profile files) is executing a su or sudo. The root account does have a password, correct? – Deathgrip Jun 30 '17 at 16:37
3

This has nothing to do with Linux, it's NoMachine server config, specifically: server.cfg file, if you set:

CreateDisplay 1
DisplayOwner root

You will be root on GNOME, Reference: https://www.nomachine.com/TR04N06814&tn=DisplayOwner

Apparently i forgot about that change i made myself...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.