How to activate SUDO in Ubuntu for a user

The sudo command allows users to run programs with the security privileges of another user, by default, the root user.

First if all, the user should be created in the system if it doesn’t exists yet.

On Ubuntu systems, by default members of the group sudo are granted to sudo command access.

Once the user is created, from root user, or a user with sudo access, you have to execute this command to add the user to sudo group.

sudo usermod -a -G sudo username

After this, the user will have access to sudo command.

To check if it is working, log in the session of the new user:

su - username

and execute the command:

sudo whoami

The output should be “root”, so you confirm the access has been granted successfully.

Create a new user in Ubuntu from terminal

In order to create a new user in a Linux Ubuntu distribution from terminal, you have to use this command.

sudo adduser username

After this, the system will ask you some parameters included the password.

[23:43:24] ubuntu|zoar:~$ sudo adduser yvoictra
Adding user yvoictra' ... Adding new groupyvoictra' (1001) …
Adding new user yvoictra' (1001) with groupyvoictra' …
Creating home directory /home/yvoictra' ... Copying files from/etc/skel' …
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for yvoictra
Enter the new value, or press ENTER for the default
Full Name []: Yvoictra
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
[23:46:40] ubuntu|zoar:~$

And it’s sucessfully created.

Customize Bash Prompt with colours in Ubuntu

There are lot of people that simply like to customize the appearence of the terminal, is my case. When you use a terminal during a lot of time, it usually helps to have a prompt more visible than the default one.

Backup

First of all, you should make a backup of the configuration file in order to fall back in case it is necessary. The file is at the user $HOME, so first step is to go the directory.

cd ~
cp -p .bashrc .bashrc-backup

Adding the new configuration in .bashrc file

Now, is the moment to edit the file .bashrc and add the new configuration to have the customized prompt.

I am used to use the vi editor to modify the configuration.

vi .bashrc

Once open the file, you should go to the end of the file. The way to do it in vi is using the key combination “Shift+G”. Once the cursor is positioned at the end, start edit mode in vi using the “o” key. Add next configuration at the end of the file.

Continue reading Customize Bash Prompt with colours in Ubuntu

How to change your language and local configuration in Ubuntu

Connect with SSH to your machine and execute next command

sudo dpkg-reconfigure locales

After this, you will see a list of languages and countries. You have to select with space bar the language and country you need. In my case, as I live in Spain, I have selected es_ES.UTF-8. It is recommended to choose UTF-8 version.

Finally, Ubuntu will ask you to select the default language to use in the operating system.

After that, you should configure the language in the keyboard with this command:

sudo dpkg-reconfigure keyboard-configuration

Now, we will configure the timezone

sudo dpkg-reconfigure tzdata

I have select the country (Europe) and the city (Madrid) where I live, so the timezone has been updated.

Finally it is recommended to reboot the system to apply the changes.

sudo reboot

How to install Ubuntu in your Raspberry Pi 4 without Keyboard nor screen

To install Ubuntu in your Raspberry Pi 4 what you need is:

  • Raspberry Pi 4
  • USB-C cable
  • Mini SD Card (recommended 16 Gb or more)
  • PC
  • Mini SD Card reader in your PC
  • RJ45 Ethernet cable
  • Switch or Router of your network

The first step is to install Ubuntu software in your SD Card. For this, you shoud go to the Raspberry Pi Downloads page, and download the Raspberry Pi Imager.

Once installer the imager, it is needed to select the Operating System (In our case Ubuntu 19.10.1), and the SD Card.

Continue reading How to install Ubuntu in your Raspberry Pi 4 without Keyboard nor screen

Change hostname in Ubuntu Linux

When we first install a new Operating System one of the typical request of the installation process is to set the hostname.

To change the hostname in Ubuntu Linux system, you can follow different procedures.

Editing system configuration files

1. Edit the file /etc/hostname using the vi editor. Modify the old name and set the new one.

$ sudo vi /etc/hostname

2. Edit the file /etc/hosts and replace any ocurrence of the old name with the new one.

$ sudo vi /etc/hosts

3. Reboot the system to make the changes to take effect.

$ sudo reboot
Continue reading Change hostname in Ubuntu Linux

How to Monitor an Ubuntu Server with Grafana & Prometheus

Grafana is an open source metric analytics & visualization tool which can help us to monitor the system with a nice Dashboard.

Step 1: Installing Grafana

Grafana is available in the APT packages repository, however it could not be the latest version, so we’ll use the official Grafana repository.

First, it is needed to create the file /etc/apt/sources.list.d/grafana.list and add the following into it:

deb https://packages.grafana.com/oss/deb stable main

There is a separate repository for beta releases:

deb https://packages.grafana.com/oss/deb beta main

Then it is needed to add the GPG Key, in order to install signed packages:

$ curl https://packages.grafana.com/gpg.key | sudo apt-key add -

Continue reading How to Monitor an Ubuntu Server with Grafana & Prometheus

Customize our Linux terminal with screenFetch (Ubuntu, Debian, CentOS, Linux Mint…)

screenFetch is a software for GNU/Linx which shows information related to our Hardware and our Operating System, including the logo of the Linux Distro it is being used.

This is the info screenFetch shows:

  • User Name
  • Host Name
  • OS with Code Name
  • Installed Kernel Info
  • System Uptime
  • List of Installed Packages
  • bash Shell Version
  • System Resolution
  • DE (Desktop Environment)
  • WM (Window Manager)
  • WM Theme
  • GTK Theme
  • Icon Theme
  • Font
  • CPU
  • RAM Usage

Here some examples:

Continue reading Customize our Linux terminal with screenFetch (Ubuntu, Debian, CentOS, Linux Mint…)