How can i prevent logging user1 from console?

Dear all,

i have two users user1 and user2 i want force user1 to login first by user2 and then su - user1

i want to prevent logging user1 from console directly

Try setting the user1 shell in /etc/passwd to /usr/bin/false

That should stop him logging in interactively but not stop a su

do u have another method ?

Unless you tell us why that method will not work, any method we pick is likely to be the 'wrong' one.

@Corona688: /usr/bin/false makes su useless. su is invoking the target user's shell after a successful login, thus su kind of succeeds but exits immediately.

Here is one that works:
Make user1 a role and grant it to user2:

usermod -K type=role user1
usermod -R user1 user2

No direct login as user1 will be allowed.
Only root and user2 will be allowed to su to user1.

@jlliagre thanks alot