The document provides instructions for basic setup of Linux operating systems, including adding a new user and giving them root privileges. It discusses adding a new user and assigning them to the sudo group in distributions like CentOS, Ubuntu, Debian, SUSE, OpenSUSE, FreeBSD and CoreOS. The steps include creating a new user, setting their password, adding them to the sudo or wheel group, and verifying their group membership and ability to use sudo commands.
1. BASIC SETUP FOR LINUX OPERATING SYSTEM
BY
ARSLAN UD DIN SHAFIQ
DIRECTOR & CEO OF WEBSOFT IT DEVELOPMENT SOLUTIONS PRIVATE LIMITED
ALIBABA CLOUD MVP
DZONE MVB
2. Basic Setup for CentOS, Ubuntu, Debian, SUSE Linux,
OpenSUSE, Aliyun, CoreOS, FreeBSD
Purpose & Objectives:
The purpose of this tutorial is to teach you some basic and necessary configurations that you
must do on your Alibaba Cloud ECS. Major objectives of this tutorial are:
Introduction of Linux OS
Advantages of Linux Server
Use of Linux Server
Available Linux distributions in Alibaba Cloud public images
Prerequisites for using Alibaba Cloud ECS
Add a user in different Linux OS distributions
Add user in sudo group to assign root privileges
What is Linux?
Linux is an open source operating system (OS) available for desktop as well as server. In Linux,
you don’t need to pay any cost for License to use Linux Operating System.
Advantages of Linux Server
Linux is much faster and every task is few commands ahead in Linux. Linux is much secure as
compared to other operating systems. Linux is light weight and works smoothly in limited
resources.
Linux is OS, not application. There are endless options of apps that you can install and use on
Linux server. Either you want to host an application or you want to host a game, either you
want to host files or you want to host some media, you can use Linux and install your required
applications with few commands.
Uses of Linux Server
You can use a Linux server as application server, web server, catalog server, computing
server, communication server, fax server, database server, gaming server, file server, mail
server, print server, media server, sound server, proxy server and virtual server. Graphical
user interface (GUI) is optional in Linux. If you are not good with using command line, you
can install GUI via command line and use it. [1]
3. Available Linux distributions in Alibaba Cloud public images
There is a big range of Linux distributions available for various purposes. Alibaba Cloud offers
some public images available for installation that are CentOS, Ubuntu, SUSE, OpenSUSE,
Aliyun, CoreOS, but you can use your own image as well.
Prerequisites:
1. You must have Alibaba Cloud Elastic Compute Service (ECS) activated and
verified your valid payment method. If you are a new user, you can get free $300
credits in your Alibaba Cloud account. If you don’t know about how to setup your
ECS instance, you can refer to this tutorial or quick-start guide.
2. ECS must have at least 1GB RAM and 1 Core processor.
3. A domain name registered from Alibaba Cloud. If you have already registered a
domain from Alibaba Cloud or any other host, you can update its domain
nameserver records.
4. Domain name must be pointed to your Alibaba Cloud ECS’s IP address.
5. You should setup your server’s hostname.
6. Access to VNC console in your Alibaba Cloud or SSH client installed in your PC.
Getting started:
1. After completing the prerequisites, login as root user with your root username &
password via SSH client (e.g. Putty – You can get Putty from https://www.putty.org )
or VNC console available in your Alibaba Cloud account dashboard.
How to add a User with Root Privileges?
In the first step, you will add a new user, then you will give it root privileges by adding it in
sudo group. Sudo privileges will allow this username to make administrative changes on
system when required. This user will be used to login from via SSH for everyday use. Once
you have added this user, to keep your server secure from various attacks, you will disable the
remote root access to root user.
CentOS / Aliyun:
1. To create a new user account, use the following command:
# adduser aareez
4. where “aareez” can be any username of your choice.
2. Now you will need to set password for your added username. To set password, execute
the following commands:
# passwd aareez
Now set your desired password and retype your desired password, then hit Enter key.
To confirm the data is correct, type ‘Y’ and hit Enter key.
3. Now assign username to sudo user’s group to give administrative privileges. For this,
we will check /etc/sudoers file and see whether sudoers group is enabled or not. For
this purpose, we will execute the following command.
# visudo
4. After executing the above command, a file will be opened, find the following lines in
the opened file.
Sometimes by default the second line %wheel ALL=(ALL:ALL) ALL is
commented (starting with hash #), due to which even after adding username to sudoers,
it gives error on using sudo. To prevent this issue, if this line starts with ‘#’ sign, remove
this symbol and save the changes by pressing Esc key, type :x and hit enter.
5. 5. Now you will add your username “aareez” to the “wheel” group by executing the
following command:
# usermod -aG wheel aareez
Your username has been successfully added to sudoers group and it is able to execute any root
command.
Ubuntu / Debian:
1. To create a new user account, use the following command:
# adduser aareez
where “aareez” can be any username of your choice.
2. Now you will be prompted to set password for your added username. Set your desired
password and retype your desired password, then hit Enter key. To confirm the data is
correct, type ‘Y’ and hit Enter key.
3. Now you will be asked to type your name, room no, work phone and home phone.
Provide information as per your choice and type Y and hit Enter key.
6. 4. Now assign username to sudo user’s group to give administrative privileges. For this,
we will check /etc/sudoers file and see whether sudoers group is enabled or not. For
this purpose, we will execute the following command.
# visudo
5. After executing the above command, a file will be opened, find the following lines in
the opened file.
Sometimes by default the line %sudo ALL=(ALL:ALL) ALL is commented
(starting with hash #), due to which even after adding username to sudoers, it gives
error on using sudo. To prevent this issue, if this line starts with ‘#’ sign, remove this
symbol and save the changes by pressing Ctrl+X, then type Y and hit Enter key.
6. Now you will add your username “aareez” to the “wheel” group by executing the
following command:
# adduser aareez sudo
Your username has been successfully added to sudoers group and it is able to execute any root
command
7. FreeBSD:
1. To add a new user with root/admin privileges, use the following command:
# adduser
2. For “Username”, type your selected username and hit Enter key.
3. For “Full Name”, type your full name and hit Enter key.
4. For “Uid”, leave the field empty and hit Enter key.
5. For “Login group”, type wheel and hit Enter key.
6. For “Invite username into other groups?”, leave blank and hit Enter key.
7. For “Login class”, type default and hit Enter key.
8. For “Shell”, type sh and hit Enter key.
9. For “Home Directory”, type /home/your_username and hit Enter key.
10. For “Home Directory Permissions”, leave the field blank and hit Enter key.
11. For “Use password-based authentication”, type yes and hit Enter key.
12. For “Use and empty password”, type no and hit Enter key.
13. For “Use a random password”, type no and hit Enter key.
14. Now you will be prompted to enter password. Type password of your choice and hit
Enter key.
15. Retype the password and hit Enter key.
16. For “Lock out the account after creation?”, type no and hit Enter key.
17. For OK?, type yes and hit Enter key.
18. Now you will be asked to add another user, type no and hit Enter key.
19. New user with sudo/admin rights have been created successfully.
8. Note: “aaree” can be any username of your choice.
20. Now you will need to edit sudoers file to uncomment the line shown in screenshot
below to give sudo rights to wheel group. For this, we will check /etc/sudoers file and
see whether sudoers group is enabled or not. For this purpose, we will execute the
following command.
# visudo
21. After executing the above command, you will see the following lines in the opened
file.
9. Remove the # from its start to uncomment the line. Otherwise, your username will not
be able to execute sudo command.
To remove this, make your cursor on # and press r key and then press spacebar key.
After it type :x and hit Enter key to save changes..
SUSE / OpenSUSE / CoreBSD:
Note: Step 3 & 4 is not for CoreBSD.
1. To create a new user account, use the following command:
# useradd aareez
where “aareez” can be any username of your choice.
2. Now you will need to set password for your added username. To set password, execute
the following commands:
# passwd aareez
Now set your desired password and retype your desired password, then hit Enter key.
To confirm the data is correct, type ‘Y’ and hit Enter key.
3. Now assign username to sudo user’s group to give administrative privileges. For this,
we will check /etc/sudoers file and see whether sudoers group is enabled or not. For
this purpose, we will execute the following command.
# visudo
10. 4. After executing the above command, a file will be opened, find the following lines in
the opened file.
Sometimes by default the second line %wheel ALL=(ALL:ALL) ALL is
commented (starting with hash #), due to which even after adding username to sudoers,
it gives error on using sudo. To prevent this issue, if this line starts with ‘#’ sign, remove
this symbol and save the changes by pressing Esc key, type :x and hit enter.
5. Now you will add your username “aareez” to the “wheel” group by executing the
following command:
# usermod -aG wheel aareez
Your username has been successfully added to sudoers group and it is able to execute any root
command.
How to check to which group your username belongs?
You can verify the membership for that group by executing the following command:
# groups aareez
11. How to switch from one user account to another?
Now, log in by using your new username and password. OR Use the following command to
switch user:
# su - aareez
How to check from which username you are logged in?
You can see that you have been logged in from your new account now. If you want to verify
this, you can use the command below:
# whoami
References
[1] A. u. D. Shafiq, "Linux OS - Why is it better?," Learn Cybers, 13 10 2019. [Online]. Available:
https://learncybers.com/linux-os-why-is-it-better/. [Accessed 13 10 2019].