How to change user in ubuntu
How to change user in ubuntu
Смена пользователя в Linux
Иногда компьютерами под управлением операционных систем Linux пользуются несколько юзеров по очереди, например, дома. В таких случаях не всегда удобно иметь одну учетную запись на всех человек, поскольку каждый желает задать определенную конфигурацию ОС и получить хотя бы минимальную конфиденциальность. Именно поэтому разработчики добавляют возможность создавать неограниченное количество защищенных профилей, чтобы в любой момент переключиться к какому-либо из них. На нашем сайте уже имеется статья, в которой детально описано два способа создания юзеров, поэтому сегодня мы опустим этот процесс и сразу перейдем к теме способов переключения между профилями.
Меняем пользователя в Linux
Далее вы узнаете о четырех доступных вариантах смены учетной записи в Linux на примере дистрибутива Ubuntu. Проще всего это сделать через графическую оболочку или сразу же при начале нового сеанса. Однако существуют и другие условия, о которых мы тоже поговорим в рамках данного материала. Дополнительно вам может понадобиться просмотреть список всех профилей, чтобы знать, какие у них установлены пароли и имена. Для этого мы предлагаем ознакомиться со следующей статьей по ссылке ниже, а мы переходим к первому варианту.
Способ 1: Список профилей при входе в систему
По умолчанию абсолютно во всех существующих дистрибутивах Линукс функция автоматического входа отключена, поэтому при создании нового сеанса требуется выбрать пользователя для входа, а уже потом появится строка для ввода пароля. На этом этапе вы можете указать, к какой именно учетной записи хотите подключиться.
Как видите, этот метод максимально прост, что позволит даже самому начинающему юзеру выполнить его без каких-либо трудностей. Однако если вы уже создали сеанс и не желаете перезагружать ПК для смены профиля, обратите внимание на следующий способ.
Способ 2: Кнопка «Сменить пользователя» в окружении
Еще раз уточним, что мы рассматриваем выполняемую процедуру на примере Ubuntu и установленной по умолчанию в ней графической оболочке. Если же вы обнаружили какие-либо различия, изучая скриншоты, вам предстоит самостоятельно отыскать необходимую кнопку. Это не составит труда, если вы хотя бы немного ориентируетесь в графическом интерфейсе. В противном случае можно обратиться к официальной документации дистрибутива и его оболочки. Смена учетной записи через окружение рабочего стола происходит так:
Теперь вы можете с легкостью проверить, произошла ли смена пользователя. Это осуществляется через ту же кнопку на панели задач, о которой мы говорили в первом шаге или путем запуска «Терминала». Там вы увидите, от какого имени была открыта консоль.
Способ 3: Команда в «Терминале»
Отметим, что этот вариант подойдет только в том случае, если вы не хотите менять юзера для всей сессии, а желаете выполнить какие-либо команды от его имени через консоль, а потом снова вернуться к управлению через исходный профиль. В любом дистрибутиве существует единая команда, позволяющая осуществить задуманное.
Как видите, для осуществления данного способа потребуется знать точное имя пользователя, а не только его пароль. Однако это единственный доступный вариант, позволяющий выполнять команды в пределах одной консоли от имени другого юзера.
Способ 4: Функция «Автоматический вход»
Иногда во время установки или уже после нее юзер создает учетную запись без пароля и активирует функцию «Автоматический вход». В такой ситуации авторизация происходит самостоятельно, поэтому у других юзеров нет возможности сменить профиль при включении компьютера. Исправить это положение или назначить другой профиль для автоматического входа помогут параметры, реализованные через графическую оболочку.
Выше вы узнали о четырех доступных вариантах смены пользователя, последний из которых предполагает включение опции автоматического входа, что позволит упростить процедуру переключения в тех ситуациях, когда она производится довольно редко. Вам осталось только выбрать подходящий способ и следовать инструкциям, чтобы без проблем справиться с поставленной задачей.
How to Change User in Linux
Linux is a robust multi-user operating system. There can be numerous users accessing the system and using system resources. Having separate user accounts also offer better control over various permissions.
If there are multiple users in the system, there will be numerous occasions where you’d like to switch the current user. In this guide, check out how to change the user in Linux.
User in Linux
Linux has three types of user accounts: system, user, and root.
Depending on the interface (GUI or CLI), there are multiple ways to change the current user.
Change user in CLI
This section covers how to change users in the console. This section is applicable to any Linux distro.
Change user using su
This is the default way of changing the current user for the session. The su (switch user) command offers a simple way to switch users.
To change to a different user, use the following command structure. Once run, you’ll have to enter the password of the target user account to complete the login process.
To verify, check the value of the USERNAME environment variable.
There’s one variation of this command. If no username is specified, then su will default to the root user. In that case, the following commands are equivalent.
Verify the change.
It’s strongly recommended not to log in as root unless you have to. If it’s just for running commands with root privilege, then the sudo tool offers more flexibility and security.
Change user using sudo
While sudo is mostly used for running a command with root privilege, it can also change the user. However, not every user can use sudo. The user must be added in the sudoers file located at the /etc/sudoers location. Learn how to add a user in sudoers.
Assuming the current user can use the sudo tool, to change to a different user, run the following command. Here, the user “jones” is a regular user, whereas “hector” is an administrator.
Verify the action.
This is not where it stops. Using the sudo command, it’s also possible to run a command as a different user without logging in. The default way of using sudo is to run commands as root.
However, sudo also allows running a command as another user. This is what the command structure looks like.
Change users in GUI
If you’re using a desktop environment, then you can switch to a different user without running any command. The method will depend on what desktop environment you’re using.
Here, I’ll be showcasing how to change users on GNOME.
Change user in GNOME
GNOME is one of the most popular desktop environments out there. It’s available on almost any popular Linux distro. Its interface is pleasing, modern, and fluid. Of course, you can tweak it to give it a more pleasant vibe. Check out some of the best GTK3 themes for Linux. These are GNOME-compatible themes and should work on any modern version of GNOME.
To switch the user account, click the power button at the top-right corner and select “Switch User”.
Click the desired user account, enter the password, and voila!
Final thoughts
Changing user in Linux is quite an easy task. It doesn’t matter whether you’re a system admin or a casual user; the task is simple but important to know. Feel free to try out all the methods mentioned.
About the author
Sidratul Muntaha
Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.
How do I change the default user in Ubuntu?
In the Command Prompt or PowerShell window (not a Bash shell window), run the appropriate command for your Linux distro. Replace “username” in the below command with your new username: Ubuntu: ubuntu config –default-user username.
How do I login as a different user in Ubuntu?
How do I change my username in Ubuntu?
To put it all together:
What is the default username for Ubuntu?
4 Answers. Try ‘ubuntu’ with an empty password.
How do I change user permissions in Ubuntu?
How do I login as a different user in Linux?
How do I list all users in Ubuntu?
Viewing All Users on Linux
How do I change my Ubuntu username and password?
How to change a user password in Ubuntu
How do I change my Linux username and password?
Changing user passwords on Linux
How do I change my username in Unix?
The straight out way of doing this is:
How do I login as Sudo?
How to become superuser on Ubuntu Linux
What is root password?
How do I find my Ubuntu username and password?
What does chmod 777 mean?
Setting 777 permissions to a file or directory means that it will be readable, writable and executable by all users and may pose a huge security risk. … File ownership can be changed using the chown command and permissions with the chmod command.
How do I chmod to a specific user?
To change directory permissions for everyone, use “u” for users, “g” for group, “o” for others, and “ugo” or “a” (for all). chmod ugo+rwx foldername to give read, write, and execute to everyone. chmod a=r foldername to give only read permission for everyone.
How do I change user permissions in Linux?
To change file and directory permissions, use the command chmod (change mode). The owner of a file can change the permissions for user ( u ), group ( g ), or others ( o ) by adding ( + ) or subtracting ( – ) the read, write, and execute permissions.
Quick Answer: How To Change User In Linux?
Type the target user’s password when prompted.
What command is used to switching between users in Unix?
su command is used to switch the current user to another user from SSH. If you are in the shell under your “username”, you can change it to another user (say root) using the su command.
How do I change user to Sudo in Linux?
4 Answers
How do I change user in Ubuntu?
How to Change sudo Password in Ubuntu
How do I change the GID of a user in Linux?
First, assign a new UID to user using the usermod command. Second, assign a new GID to group using the groupmod command. Finally, use the chown and chgrp commands to change old UID and GID respectively. You can automate this with the help of find command.
How do I change user shell in Linux?
Only root can run a shell not listed in /etc/shells file. If an account has a restricted login shell, then only root can change that user’s shell.
Now let’s discuss three different ways to change Linux user shell.
How do I change from normal user to root in Linux?
Switch To The Root User. In order to switch to the root user you need to open a terminal by pressing ALT and T at the same time. If you ran the command with sudo then you will be asked for the sudo password but if you ran the command just as su then you will need to enter the root password.
How do I run sudo as a different user?
How do I login as a different user in Linux?
How do I change owner in Linux?
Use the following procedure to change the ownership of a file. Change the owner of a file by using the chown command. Specifies the user name or UID of the new owner of the file or directory. Verify that the owner of the file has changed.
How do I change user in Linux?
The command ‘usermod’ is similar to that ‘useradd’ or ‘adduser’ but the login granted to an existing user.
How do I change the hostname in Ubuntu?
Start a new terminal to see the new hostname. For Ubuntu server without a GUI, run sudo vi /etc/hostname and sudo vi /etc/hosts and edit them one by one. In both files, change the name to what you want and save them. Finally, restart your computer to apply the changes.
How do I become root user in Ubuntu?
Method 2 Enabling the Root User
How do I change the hostname in Linux?
The procedure to change the computer name on Ubuntu Linux:
How do I change my parrot OS username?
How do you add a user in Linux?
Steps to Create a New Sudo User
How do I change bash in Linux?
From root user, you can change the shell of a particular user using usermod command. If your question is about just switching to the bash prompt, type ‘bash’ from the current shell.
If you have “gedit” installed then use it else use “vi” or “vim” to edit.
How do I change bash to Shell?
Change the default shell from bash to tcsh as used by Terminal app in three steps:
What is shell in Linux and its types?
The shell is the command interpretor in an operating system such as Unix or GNU/Linux, it is a program that executes other programs. It provides a computer user an interface to the Unix/GNU Linux system so that the user can run different commands or utilities/tools with some input data.
How do I change to root in Linux?
Changing the root password in CentOS
How do I go back to root user?
How do I change to root user in CentOS?
Steps to Create a New Sudo User
How do I give root access to user in Linux?
Procedure 2.2. Configuring sudo Access
How do I change the owner of a file in Linux?
Notes on usage
How do I see all users in Linux?
Get a List of All Users using the /etc/passwd File
How do I give permission to user in Linux?
If you wanted to add or remove permissions to the user, use the command “chmod” with a “+” or “–“, along with the r (read), w (write), x (execute) attribute followed by the name of the directory or file.
How do I change the mode in Linux?
The chmod command allows a user to change the permissions of a file/directory. To use chmod, the user must be the owner of the file. (Recursively) will cause all files and directories within (underneath) the file/directory whose permissions are being changed to take those permissions.
What is the difference between chmod and Chown?
Difference Between chmod and chown. The chmod command stands for “change mode”, and allows changing permissions of files and folders, also known as “modes” in UNIX. The chown command stands for “change owner”, and allows changing the owner of a given file or folder, which can be a user and a group.
How do I become super user in Ubuntu?
How to become superuser on Ubuntu Linux
How do I become superuser in Linux?
How to Become Superuser (root) or Assume a Role
How do I login as Sudo as root?
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
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.
As a sudo user yourself, you can create sudo user by adding the user to sudo group.
Conclusion
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!