How to switch users on the Linux command line
Just like Windows or macOS, Linux systems also have different types of accounts and users with different system access privileges. However, not all users can execute all commands and not all users have the right to switch to another user account.
1. Overview
To switch users, we must first know the password of that user. Use the command below to switch users:
su -
To switch to root user on Ubuntu, we use the command below:
sudo -i
2. List of users on Linux
Basically Linux system has 3 types of users:
- System users
Is a user created automatically on Linux systems to be able to run services or applications.
- Regular users
Is a user who can log into the system. Each user may or may not have access to the system.
- Super User
These are system Admins or users who can perform high level tasks, which can be tasks that affect or endanger the system.
3. How to switch users on Linux command line
On Linux systems, we can log in as any user, and then switch to another user through the same command line session. To do this, we will use the "su -" command, which allows us to switch directly to another user:
For example:
johndoe@system:-$ su - janedoe
Password:
janedoe@system:-$
In the above example we need to know the password of the user janedoe to switch to that user.
4. Switch to root user
For some security reasons, some systems block direct login, local login or remote login of the root account. So to execute commands under the root user, we will have to use the sudo command .
The sudo command will basically execute anything you want on the system as if "root" did it. Importantly, you don't need to know the root user's password, in fact probably no one knows what password root is assigned.
All you need to know is the user's password and that the user must belong to the " sudoers" group, which is basically the group of users that can use the sudo command on the system.
Normally to run commands as root via sudo command, we use the command below:
sudo
In case you want to switch to root user so that all subsequent commands will run under root user, we use the command:
sudo -i
The password we use here is the user password, not the root account password.
So, in the above article, TipsMake has just guided you on how to switch users on the Linux command line. Basically, Linux systems allow users to easily switch users or execute advanced commands using the su and sudo commands.
In addition, if you have any questions or queries that need to be answered, you can leave your comments in the comment section below the article.
Creating a user in Windows 10, creating a new user account is also a question that many people who are new to using Windows 10 are wondering about. For details on creating a user in Windows 10, please find out on Taimienphi.
Also a trick on Linux operating system, changing IP address with command on Linux - one of the ways not many people know, you can refer to how to change IP address with command on Linux presented in detail on our page.
You should read it
- 5 best video conversion software available today
- How to use large file fileshifter.io convert
- Best free image conversion programs 2021
- How to use Max Converter convert video, audio, images
- The best online file conversion website online
- Switch from base 16 to base 2
- Convenient currency conversion feature on Opera, did you know?
- Download the PDF Conversion Tool Windows 10 application is free
May be interested
- How to manage Linux services using Systemdone of the most important skills that any new systemd user needs to learn is how to manage computer services. this article will teach you the basics: start, stop, enable and disable services from the linux command line.
- How to send email using the command line in Linuxin this article, i will show you how to use the linux command to send mail with a script. in addition, it is the sending of attachments from the command line.
- How to Launch Programs from Command Line on Linuxmost linux distributions have a graphical user interface that allows us to open programs just by clicking on the program icon in the apps menu. however, sometimes you may want to launch programs from terminal. terminal is a powerful tool that allows users to launch programs and manage linux systems through keyboard commands. today's tipsmake will show you how to launch programs from terminal on linux.
- Instructions for using find command in Linuxthe find command is one of the most important and handy commands on a linux system. as its name suggests, the command can find files on a linux pc based on a variety of conditions and variables you set.
- How to use the which command in Linuxthe which command in linux determines the executable binary, which will execute when you issue a command to the shell. if you have different versions of the same program on your computer, you can use which to find out which shell will use.
- The dd command in Linux, How to use the dd commanddd is a command line utility for unix-like and unix operating systems, with the main purpose of converting and copying files.
- The Cat command in Linuxthe cat command (short for 'concatenate') is one of the most frequently used commands in operating systems like linux / unix. the cat command allows users to create one or more files, view file contents, join files, and redirect output in a terminal or file.
- The basics of Cisco Switch Management - Part 1in the command-line interface cli (command-line interface) you can perform any type of configuration. so you can use the ios command line interface.
- 5 free websites and online games to learn about the Linux command linelinux is popular for its reliability and many practical applications. if you want to know more about linux, here are 5 websites that will help you learn it interactively.
- 20+ essential Linux security commandshere are some of the most important security commands for everyday work on linux systems. if you're interested in security issues on your linux system, don't ignore these helpful security commands.