Как сменить пользователя в linux
Перейти к содержимому

Как сменить пользователя в linux

  • автор:

Sorry, you have been blocked

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

What can I do to resolve this?

You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.

Cloudflare Ray ID: 80fcbe778e84b357 • Your IP: Click to reveal • Performance & security by Cloudflare

How to switch user in terminal

How does one do this. I tried: su sensu but nothing happens.

terdon's user avatar

1 Answer 1

You should use su :

If you specify the login option (either — , or -l , or —login : all are synonyms), you will get an environment similar to if you directly logged in as that user. Otherwise you stay in the current environment (e.g. many env variables, the current directory, etc).

Example: (note the usernames and current working directories!)

PS: If you run su not as root, you will of course be prompted for the password of the user as who you want to log in.

Byte Commander's user avatar

You must log in to answer this question.

    Featured on Meta
Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.9.29.43652

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

How to Change Users in Linux Command Line

Linux systems have different users and different types of users. Learn how to switch the users in Linux command line or how to change to the root user in Linux.

How to Change Users in Linux Command Line

Linux systems have different types of users with different types or permissions as well.

Not all users can execute all commands and not all users are allowed to switch to other users neither. This all might sound confusing but, I will try to explain these so it can be easy to understand.

For the moment, here’s a quick summary of how to switch users in Linux command line.

To switch users, you need to know the password of that user. You can switch the users with this command:

To switch to root user in Ubuntu, you can use this command:

Various user types in Linux

If you list all users in Linux, you’ll see a lot of users that you didn’t know about. Who are these users? Where did they come from? I could write an entire article in regards of how users work in Linux, however, this is not the idea for this one.

Basically, there are 3 types of users in Linux:

1. System Users

These are the users that are automatically created in Linux systems to be able to run services or applications and are not intended to log in to the system (in fact you can’t log in as any of these users).

2. Regular Users

These are the (human) users who can log in to a system. Each of these users might have or not different permissions or levels in the system which is given by the groups they belong to.

3. Super Users

These are system administrators or users who can perform high-level tasks that can be considered critical or system dangerous.

Switch users in the command line

When using a Linux system you can log in with a user and then simply “switch” to another user through the same command line session. In order to do this, there is a command “su -“, which allows you to switch to become another user:

In the above example, you need to know the password of janedoe in order to switch to that user. Which makes sense because if you are going to switch to a user, you need to know the password of that user else it will be a security risk.

Switch to root user

For security reasons, some systems have ‘root’ account blocked for direct login, either locally or remotely, so this means it will not accept someone who tries to log in using ‘root’ even with the correct password.

So, how do you perform actions as the ‘root’ user? That’s what the ‘sudo’ command allows you to.

The sudo command will basically execute anything you want in the system as if the ‘root’ was doing it. You don’t need to know the ‘root’ user’s password, in fact, probably nobody knows it or there is no password assigned to ‘root’. You only need to know your own user’s password and that user must be in the ‘sudoers’ group, which is basically the group of users which can use ‘sudo’ in the system.

Normally, it is a good practice to run the commands with sudo that needs to run with root permission like this:

But if you want to change to root user so that all the subsequent commands will be run as root, you can use:

You’ll use your own password here, not the root account’s password.

Change to root user in Linux

As a sudo user yourself, you can create sudo user by adding the user to sudo group.


Linux systems allow you to easily switch users or execute high-level commands with the usage of ‘su‘ and ‘sudo’ commands. And remember: with great sudo power comes great responsibility!

Как сменить пользователя в Ubuntu

Ubuntu рассчитана на работу под учетной записью одного пользователя, менять пользователей в системе приходится не так уж часто. Для работы достаточно ввести логин и пароль, то есть пройти авторизацию, и пользоваться системой до окончания работы. Если нужны административные привилегии, то для этого предусмотрена sudo. Тем не менее, остаются ситуации, когда необходимо сменить пользователя в Ubuntu. В этой статье мы поговорим о том как сделать это в графическом интерфейсе и в терминале.

Как поменять пользователя в Ubuntu

Находим значок выключения в правом нижнем углу, жмем на него, выбираем «Завершить сеанс» или «Сменить пользователя»:

Теперь подтверждаем завершение сеанса или смены:

Как сменить пользователя в Ubuntu

Дальше откроется стандартное окно входа, где можно выбрать пользователя из списка или ввести его логин в поле ввода. Затем пользователь снова окажется на рабочем столе Ubuntu.

Как сменить пользователя в Ubuntu

Поговорим о том, как выполняется смена пользователя в терминале. Для этого надо использовать команду su. Например, чтобы сменить пользователя на losst достаточно выполнить:

Программа запросит пароль пользователя losst после чего откроет командную строку от его имени:

Как сменить пользователя в Ubuntu

Как сменить пользователя в Ubuntu

В этой инструкции мы рассмотрели, как поменять пользователя в Ubuntu. Успехов!

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *