How to Add and Delete Users on Ubuntu 18.04

Ubuntu is also a multi-user operating system like any other Linux distribution. Each user can have various permission levels and unique settings for different command-line and GUI applications.

Understanding how to add and remove users is one of the necessary skills a Linux user should know, as it is the primary task.

In this article, we will explain to you how to add and remove users on Ubuntu 18.04.

To be able to create and remove users, you require to be logged in as root or user with sudo perquisites.

How To Add User in Ubuntu

You can create a new user account in Ubuntu in two ways, which are as follows:

  1. From the command line.
  2. Through the GUI.

Add a New User from the Command Line

Two command-line tools can create a new user account that is useradd and adduser tool in Ubuntu.

Where useradd is used as a low-level utility for adding users, while the adduser a friendly interactive frontend to useradd written in Perl language.

To create a new user account named username using the adduser command, you would run:

$ sudo adduser username

Adding user `username'...

Adding new group `username' (1001) ...

Adding new user `username' (1001) with group `username' ...

Creating home directory `/home/username' ...

Copying files from `/etc/skel' ...

You will be asked a series of questions. The password is required, and all other fields are optional.


Enter new UNIX password: 

Retype new UNIX password: 

passwd: password updated successfully

Changing the user information for username

Enter the new value, or press ENTER for the default

Full Name []: 

Room Number []: 

Work Phone []: 

Home Phone []: 

Other []: 

Is the information correct? [Y/n]

Finally, if you want to confirm that the information is correct then enter Y.

The command will create the new user’s home directory, copy files from the/etc/skel directory to the user’s home directory. Within the home directory, the user can write, edit, and delete files and directories.

By default, on Ubuntu, members of the group sudo are granted with sudo access.

If you want the newly created user to have administrative rights, add the user to the sudo group :

 $ sudo usermod -aG sudo username

Add a New User through the GUI

If you are not satisfied with the command line, you can add a new user account through the GUI also. To do so, you will need to follow the steps given below:

  1. The first step is to search for “users” in the activation screen and then click on “Add or remove users and remember to change your password.”
  2. Then you will need to click on the “Unlock” button and open your user password when mentioned.
  3. After you enter the password, the “Unlock” button will convert to a green “Add User” button.
  4. Then you will need to click on the “Add User” button, and then Add user dialog will arrive:
  5. Then you will need to select whether the new user should be a standard or administrator user and insert information. Once done, then you will need to click on the “Add” button.

How To Delete a User

If the user account is no longer in use, then you can delete it each from the command line or GUI, whichever is preferred.

Delete a User from the Command Line

Two command-line tools can create a new user account that is userdel and deluser tool in Ubuntu. Where useradd is used as a low-level utility for adding users, while the adduser a friendly interactive frontend to useradd written in Perl language and it is more preferred to use.

To delete the user, without removing the user files, run:

$ sudo deluser username

The following command is used if you want to delete the user and its home directory and mail spool, use the –remove-home flag:

$ sudo deluser –remove-home username

Delete a User through the GUI

  1. The first step is to search for “users” in the activation screen and then click on “Add or remove users and remember to change your password.”
  2. Then click on the “Unlock” button, and insert your user password when mentioned.
  3. Then click on the username you want to delete, and you will observe a red “Remove User..” button on the base right corner, which indicated that the user could be removed.
  4. Then click the “Remove User..” button, and you will be mentioned whether to keep or delete the user home directory. By clicking on one of those buttons removes the user that you are willing to do.


In this article, you have learned how to add and remove users in Ubuntu. If you have any queries related to this topic, you can leave comments below.

How to Move Files and Directories in Linux with mv Command

Mv is one of the Linux commands that must be learned. Mv stands for transferring files or directories from one place to another and is primarily used for moving them.

The syntax is similar to the cp command in Linux, but there is a fundamental distinction between these two commands.

The cp command can be called a copy-paste method. The mv instruction, while the cut-paste process can be equivalent.

This means the file or directory is transferred to a different location using the mv command on a file or directory. The source file/directory is no longer there.

mv Command How can you use it?

The mv(transfer) command will move files and directories from place to place. It is also ideal for renaming files and folders.

mv [OPTIONS] source destination
  • The source may be a single file or directory in the above command. The destination is always a single file or directory.
  • When we have several files or folders, it is always a directory destination. Both source files and folders, in this case, are transferred to the directory of the destination. When we have a single source file and a destination directory, the file is transferred to the target folder.
  • One crucial point is that when we transfer files and folders, we will obtain permission refused if we don’t have written permissions both for the source and destination.

mv mv image.png PNG

The current working directory transfers the image.png file to the PNG folder in the current work directory.

The original filename is renamed as the destination file if the destination directory isn’t present.

The image.png file is called PNG if it is not present in the existing working directory.

Transfer several folders and files

Specify the files you want to transfer as the source to move several files and folders. For instance, you would type to transfer file1 and file2 to the directory dir1:

mv File1 File2 dir1

You can also use pattern matching with the mv button. For, e.g., you would like to transfer all pdf files to the ~/Documents directory from the existing directory:

mv *.pdf ~/Documents

Drag a folder inside a separate folder with the mv command
We may use the following command to transfer a directory within another directory:

mv mv abcd abcd_New

It passes the abcd directory to another abcd New directory in our existing working directory.
The source directory is reset to the destination directory if the destination directory is not present.

How to transfer several files to another directory:
All source files and the path to the target directory are defined to transfer several files within a different directory.

mv <source(source)file path 3>

Our current working directory transfers the files 1.jpg, 2.jpg, and 2.png into a separate image directory in the current working directory.

Within a directory, we can transfer multiple files using regular expressions that match the filenames to be transferred.

Mv *jpg JPG

All files with mv backup:
We use the -b option to back up current files. It is intended to create a backup of the overwritten ~ character file with the attached backup file name.

mv -b a.jpg 1.jpg


File rename

The mv command is essential for file renaming. The source file shall be renamed to the target file if you are using an mv command and specify a file name in your destination.
mv source_file target directory/target file

Suppose the target file does not exist in the target directory. In that case, the target file will be generated in the above case.

However, it overwrites without asking if the target file already exists. This means that with the source file’s content, the content of the current target file will be modified.

OverRight file when moving:

The existing file contents would be automatically overridden if a file is transferred and there is already a file with the same name.

In all cases, this might not be optimal. The overwriting scenario is available in a variety of ways.
You may use the -n option to avoid overwriting existing files. So mv will not overwrite the current file.

mv -n source_file target_directory

Forced movement of the file:

If you are shielded from writing the target file, you will be required to check until the target file is overwritten.

mv file1.txt target
Mv: substitute 'target/file1.txt' for 0444 overriding (r—r—r—) mode?

You may use the force option -f to bypass this prompt and overwrite the file immediately.

mv -f File1.txt target

How to Install Python Pip on Ubuntu 20.04

If Python is still new to you, Python is a high-level programming language oriented towards objects that have become increasingly popular over the years. Python is commonly used in software, device management, analyzing scientific and numeric data, and much more.

It is possible to install either Python 2 or Python 3 on Ubuntu 20.04. With Ubuntu 20.04, though, Python 3 is the default version. PIP is a software tool that allows you to install different packages of Python on your device. Packages can be installed from the PyPI Python Package index repository and other index repositories into your framework with the PIP tool’s help.

It is strongly recommended to install the module’s dev package with the apt tool when installing a global Python module. They are checked to function correctly on Ubuntu systems. The prefix for Python 3 packages is python3- and the prefix for Python 2 packages is python2-.

Using Pip to globally install a module only if no deb package exists for that module.

You prefer to use pips only in a virtual world. For a particular project, Python Virtual Environments allows you to install Python modules in an isolated area rather than installed globally. This way, you do not have to worry about other Python projects being affected.

Installing Pip in Python 3

To install the Python 3 pip for Ubuntu 20.04, run the following root, or sudo user commands on your terminal:

sudo apt update sudo apt install python3-pip

All the dependencies needed to construct Python modules will also be installed with the above instruction.

Verify the installation when the installation is completed by reviewing the pip version:

pip3 --version

Install a Python 2 pip

In the repositories of Ubuntu 20.04, Pip for Python 2 is not included. We’ll be using the script to build a pip for Python 2.

Sudo Add-apt-Universe Repository

Update the index for the packages and install Python 2:

sudo apt update sudo apt install python2

To download a script, use curl:

curl --output

You can run the installing script as sudo user with python2 to install Pip for Python 2 once the repository is enabled:

sudo python2

Pips can be installed worldwide. If it is just for your user to install, run the command without sudo. Setuptools and wheels are also installed in the script, enabling you to install source distributions.

Verify installation by the version number of the pip:

pip2 --version

How do you make use of Pip?

Let’s see, a few useful simple commands for pips. With Pip, you can install PyPI, version control, local projects, and delivery file packages. Generally, PyPI packages are installed.

To display the list of all options and pip commands, type:

pip3 --help

Using Pip <command> –help, you can get more information about a particular command. To get more information about the install order, for example, type:

pip3 install –help

Using Pip to install Packages

If you want to install a scrapy kit used to scrape data from websites and extract it.

You must run the following command to install the latest version of the package:

pip3 install scrapy

To install a particular version of the append == package, and the version number after the name of the package:

pip3 install scrapy==1.5

Download the requirements.txt packages:

Requirements.txt is a text file that includes a list of versions of the pip packages needed to run a particular Python project.

To install a list of requirements listed in a file, use the following command:

pip3 install -r requirements.txt

Installed Packages listing

Use the following command to list all the installed pip packages:

pip3 list

Upgrade with Pip a Kit

To update the kit that is already installed to the new version, enter:

pip3 install --upgrade package_name

Uninstalling Pip Packages

To uninstall a running package:

pip3 uninstall package_name


Here you have learned about installing pip on your Ubuntu operating system and using pips to handle Python packages.

How to Install Plex Media Server on Ubuntu 18.04

In the following write-up, we will try to get ourselves acknowledged how to get the Plex media server installed on Ubuntu 18.4 and create a Media library.

What is Plex?

Plex is considered the server used for streaming different kinds of media like video, music, and photo slideshow. The part about Plex that makes it the most unique is that you can stream through it from anywhere and everywhere you want to.

Point to remember

One thing that should be noted is to be able to install different servers on Ubuntu. You should be logged in as a user.

Let’s get started with the installing procedure of the Plex Media Server.

One can easily manage the Plex media server on Ubuntu by using the official repository by Plex. This procedure does not need you to be technically efficient and help you limit 20 minutes by installing and configuring the Plex media server.

The steps mentioned below will help you with the process of installing Plex media server in Ubuntu,

  • the first step will be to import the repository’s GPG key and use the below-mentioned command,
$ curl | sudo apt-key add -
  • Secondly, you will have to add your system software repository list with Plex APT repository:
$ Echo deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
  • when you are done with enabling the blacks repository, you are now ready to install the Plex media server in the latest version,
$ sudo apt install apt-transport-HTTPS

$ sudo apt update

$ sudo apt install plexmediaserver
  • Verification of the proper functioning of flex service can be done by the command below,
$ sudo systemctl status plexmediaserver

You will receive a output mirroring exactly the below mentioned,

  • plexmediaserver.service – Plex Media Server for Linux

Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)

Active: active (running) since Mon 2018-06-25 10:42:28 PDT; 35min ago

Process: 2544 ExecStartPre=/bin/sh -c /usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" (code=exited, status=0/SUCCESS)

Main PID: 2556 (sh)

         Tasks: 56 (limit: 2321)

CGroup: /system.slice/plexmediaserver.service

Plex Media Server Configuration

Follow the steps below to configure the Plex media server,

  • the first step in configuring the Plex media server is creating directories, which will further help store media files.
sudo mkdir -p /opt/plexmedia/{movies,series}

The location of the media files does not matter but remember to provide the proper ownership.

sudo chown -R plex: /opt/plexmedia
  • Finally, we reached the server configuration step where, on typing the browser search bar with, http://YOUR_SERVER_IP:32400/web, aired, and aired in a screen popup with a Plex media sign up.

Methods describing how to sign in on Plex Media Server

Keep the steps below in mind to sign-in on the Plex media server,

The first step to bring in use the Plex media server is to get yourself an account created.

Account creation is no big deal. You will have to fill in the information on Google, Facebook, or email about yourself and if you are a fan of premium, then get yourself a Plex Pass.


When undergone, the procedure of signing up an informative page will pop-up regarding the working of Plex.

From here, to move ahead, you will have to press the button flashing “Got it.”

  • Secondly, you will be given an option to decide the media’s access to your server when outside the home (server’s home box). After putting a check on it, you will go for the “Next” button. In this procedure, you will also find yourself naming your Plex server.

The check procedure follows with you to the creation of a Media library. You will have to press down on, “Add Library” button, and voila!

You can have your selected movies and library type mentioned. This step is again followed by pressing on the “Next” button.

  • Another step involved making a media folder path directed, which will lead you to the media files easily. We had the path directed as,

/opt/plex media/granule/movies.

  • To increase the number of libraries, you have to click the “Add” button simultaneously and then the “Add Library” one.
  • Following a click on the “Next” button, and after a click on the button displayed as “Done,” and you will reach the Plex Web dashboard.
  • Once you are done setting up everything, you can now feel free to explore Plex media and the different options.


This write-up provided above helped you understand the Plex media server’s installing procedure when it comes to Ubuntu 18.4 machine. Also, you got yourself some tricks and tips on serving your own Media Library.

How to Install Nvidia Drivers on Ubuntu 20.04

In this article, you will learn how to install the NVIDIA drivers on Ubuntu 20.04.

If you have an Ubuntu machine with an NVIDIA GPU, you can take between the open-source driver Nouveau and NVIDIA’s exclusive drivers. By default, Ubuntu applies Nouveau drivers frequently much slower than the exclusive drivers and lacks support for the most advanced hardware and software technology.

Installing NVIDIA drivers on Ubuntu is a simple task that can be completed in less than a minute. Ubuntu involves a tool that can recognize the graphics card model and install the relevant NVIDIA drivers. Alternatively, you can download and install the drivers from the NVIDIA site also.

Installing the NVIDIA Drivers Using a GUI

This is the most relaxed and the suggested way to install NVIDIA drivers on Ubuntu Desktop systems.

  1. In the Activities screen, seek “driver” and click on the “Additional Drivers” icon.
  2. The “Software & Updates” window will start to see all available drivers for your graphic card.
  3. Depending on the installed card, you will be offered a list of one or more NVIDIA drivers.
  4. Choose the NVIDIA diver you need to install and then click on the “Apply Changes” button.
  5. The installation process may take a few minutes, so be patient.
  6. Once the drivers and installed, then you will need to reboot your machine.

The new NVIDIA driver will be activated after the system is boot up. If you need to view or change the driver set, begin the Nvidia-settings utility:

$ sudo Nvidia-settings

Later, if you need to update or modify the driver, repeat the same steps.

Installing the NVIDIA Drivers Using the Command-Line

If you favor the command-line interface, you can use the ubuntu-drivers tool.

Open your terminal (Ctrl+Alt+T), and run the subsequent command to get data about your graphic card and open drivers:

$ ubuntu-drivers devices

The output following shows that this system has “GeForce GTX 1650,” and the suggested driver is “Nvidia-driver-440”. You may see various outcomes depending on your system.


== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001F95sv00001028sd0000097Dbc03sc02i00
vendor   : NVIDIA Corporation
model    : TU117M [GeForce GTX 1650 Ti Mobile]
driver   : nvidia-driver-440 - distro non-free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

Usually, it is best to install the suggested driver. To do so, use the apt package manager:

$ sudo apt install Nvidia-driver-440

Once the installation is finished, reboot your system:

$ sudo reboot

When the system is back, you can view the status of the graphic card using the Nvidia-smi monitoring tool:

 $ Nvidia-smi

The command will represent the version of the used driver and other data about the NVIDIA card:


Wed Nov 11 22:45:21 2020
| NVIDIA-SMI 440.100      Driver Version: 440.100      CUDA Version: 11.1     |
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|   0  GeForce GTX 165...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   41C    P3    14W /  N/A |      4MiB /  3914MiB |      0%      Default |
|                               |                      |                  N/A |

| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|    0   N/A  N/A      2323      G   /usr/lib/xorg/Xorg                  4MiB |

Installing the Latest NVIDIA Drivers

Most users should stick with the firm NVIDIA drivers that are available in the default Ubuntu repositories. If you want to live on the edge, you can install the latest drivers from the NVIDIA site or the “Graphics Drivers” PPA.

We will use the PPA method as it is more comfortable to install and update the drivers.

Add the PPA repository using the following command:

$ sudo add-apt-repository ppa:micahflee/ppa

Use the ubuntu-drivers tool to view the available drivers:

$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001F95sv00001028sd0000097Dbc03sc02i00
vendor   : NVIDIA Corporation
model    : TU117M [GeForce GTX 1650 Ti Mobile]
driver   : nvidia-driver-440-server - distro non-free
driver   : nvidia-driver-450-server - third-party non-free
driver   : nvidia-driver-455 - third-party non-free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

Install the desired driver:

$ sudo apt install nvidia-driver-455

Reboot the system to activate the new driver.


In this article, you have learned how to install NVIDIA Driver on Ubuntu 20.04. If you want more information about NVIDIA drivers, then you can contact us now.

How to Install Eclipse IDE on Ubuntu 18.04

Eclipse is the most commonly used Java built-in programming environment (IDE). It is easy to use via plugins. Its versions are available for development in other programming language platforms like C++, JavaScript, and PHP.

The Eclipse installation kit (version 3.8.1) included in the Ubuntu repository is out of date. The best way to update the new Eclipse IDE on Ubuntu 18.04 is to use the snappy packaging system.

Install the Eclipse

The new stable edition of Eclipse is Eclipse 2019-03, is available now:

To install Eclipse on your Ubuntu system, follow the following steps:

Java Install

Since Eclipse is an IDE based on Java, you will need the Java Runtime Environment (JRE) to be installed to run it.

Run the commands below to install the Java opensource update.

sudo apt update
Sudo apt configuration default-JRE

Java JRE has to be mounted.

Download and install the Eclipse Snap kit to your machine by typing:

sudo snap install --classic Eclipse

When you install Eclipse successfully, you should see the following output:

eclipse 2019-03 from Snapcrafters installed

Eclipse Manually Install

The steps below should be helpful for those who want to install Eclipse manually. You’ll be using the regular Eclipse installer to install the app.

Firstly, to download the installer, go to the page below.

Or you can use the download and extract commands below.

Run the following commands to remove the downloaded file from your Home Directory Downloads folder.

tar xfz ~/Downloads/eclipse-inst-linux64.tar.gz


~/Downloads/eclipse-installer/eclipse-install installer

You will start the installation wizard with the second instruction.

Pick the tools and language that you want to create.

Eclipse Begins

You can now open Eclipse on your Ubuntu device by clicking on the Eclipse icon (Activities -> Eclipse):

A window like this will appear when you start Eclipse for the first time, asking you to pick a Workspace directory:

The default directory ought to be all right. To proceed, press Launch.


On your Ubuntu 18.04 computer, now you have learned how to install Eclipse. You can start working on your project in Java now.

How to Increment and Decrement Variable in Bash (Counter)

One of the most popular arithmetic operations when addressing Bash scripts is incrementing and decrementing variables. This is most regularly used in loops as a counter, but it can happen elsewhere in the script.

Incrementing and Decrementing center on adding or subtracting a value (usually 1), respectively, from the value of a numeric variable. The arithmetic augmentation can be performed using the double parentheses ((…)) and $((…)) or with the built-in let command.

In bash, there are various ways to increment/decrement a variable. In this article, some are explained.

Using + and – Operators

The easiest way to increment/decrement a variable is by using the + and – operators.



let "i=i+1"


let "i=i-1"

This method enables you to increment/decrement the variable by any value you want.

Here is an example of incrementing a variable within an until loop:


until [ $i -gt 3 ]


  echo i: $i




i: 0

i: 1

i: 2

i: 3

The += and -= Operators

In addition to the basic operators explained above, bash also provides the assignment operators += and -=. These operators are used to increment/decrement the left operand’s value with the value specified after the operator.


let "i+=1"

let "i-=1"


In the example below, we will show how to decrement the I variable’s value by 5.


while [ $i -ge 5 ]


  echo Number: $i

  let "i-=5" 



Number: 20

Number: 15

Number: 10

Number: 5

Using the ++ and — Operators

The ++ and — operators increment and decrement, respectively, its operand by 1 and return the value.



let "i++"

let "++i"


let "i--"

let "--i"

The operators can be used before or after the operand. They are also known as:

  • prefix increment: ++i
  • prefix decrement: –i
  • postfix increment: i++
  • postfix decrement: i–

The prefix operators first increment/decrement the operators by one and then return the new value to the operator. On the other hand, the postfix operators return the operators` value before incrementing/decremented the operator’s value.

If you only want to increment/decrement the variable, then there is no difference if you use the prefix or postfix operator. It only makes a difference if the operators’ result is accepted in some other operation or assigned to another variable.

The example below will show how the ++ operator works when is used before and after its operant:



echo x: $x

echo y: $y


x: 6

y: 5


echo x: $x

echo y: $y

x: 6

y: 6

The example below shows us how to use the postfix incrementor in a bash script:



while true; do

  if [[ "$i" -gt 3 ]]; then

    exit 1


  echo i: $i



The downside of using these operators is that the variable can only be incremented or decremented by one only.


In bash, incrementing and decrementing variables can be performed in many different ways. So whatever method you use, the result is the same. If you have any query related to this, please write us.

How to Find the Length of a List in Python

Lists are one of the most commonly used data types in Python and store collections of the same kind.

In this article, we will see how to find the length of a list.

len() Function

If you want to find the length of the given object, then in Python, there is a built-in function len(), giving you the length of the given object (object means a list, tuple, string, dictionary, etc.)

The syntax of the len() function is as follows:


The function allows only one argument. The declared value is an integer that is the number of elements in the list.

Here is an example:

capitals = ['Tokyo', 'Sofia', 'India', 'Budapest', 'America']

list_len = len(capitals)

print("The list has {0} elements.".format(list_len))

The list has 5 elements.

Using Loop

Another way to find the length of a list is to use them for a loop. This works by fixing up a counter and looping through all the elements of the list. On each repetition, the current value of the counter variable is incremented by one.

With the help of the following code, the snippet will get an idea of finding the length of an object using the loop.

capitals = ['Japan', 'America', 'India', 'Budapest', 'Italy']

counter = 0

for capital in capitals:

  counter = counter + 1

print("The list has {0} elements.".format(counter))

The list has 5 elements.

As we cannot trust this method, it favors using the len() function in Python.


In this article, we have seen finding the length of a list in Python list and using the len() function only. If you have any queries related to this len(), then feel free to connect us.

Fdisk Command in Linux (Create Disk Partitions)

Whenever you install a new SSD or hard disk, the first thing you have to do is to partition it. A drive requires to have at least one partition before you can format it and store files on it.

In Linux, there are many tools that you can use to generate partitions, with fdisk being the most usually used one.

In this article, let us see about the fdisk command.

fdisk is a menu-driven command-line utility that enables you to design and manipulate partition tables on a hard disk.

Be aware that fdisk is a severe tool and should be used with absolute caution. Only root or users with sudo privileges can manage the partition tables.

List Partitions

To list the partition table of a project, invoke the fdisk command with the -l option, followed by the device name. For example, to list the /dev/sda partition table and partitions, you would run:

$ fdisk -l /dev/sda

When no device is given as an argument, fdisk will print partition tables of all devices listed in the /proc/partitions file:

$ fdisk -l

Disk /dev/nvme0n1: 232.91 GiB, 250059350016 bytes, 488397168 sectors

Disk model: Samsung SSD 960 EVO 250GB

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: gpt

Disk identifier: 6907D1B3-B3AB-7E43-AD20-0707A656A1B5

Device            Start       End   Sectors   Size Type

/dev/nvme0n1p1     2048   1050623   1048576   512M EFI System

/dev/nvme0n1p2  1050624  34605055  33554432    16G Linux swap

/dev/nvme0n1p3 34605056 488397134 453792079 216.4G Linux filesystem

Disk /dev/sda: 465.78 GiB, 500107862016 bytes, 976773168 sectors

Disk model: WDC WD5000AAKS-0

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Disk identifier: 0x0001cca3

Device     Boot Start       End   Sectors   Size Id Type

/dev/sda1        2048 976771071 976769024 465.8G 83 Linux

The output over shows the current partition tables of all devices that are connected to your system. Generally, SATA device signs follow the pattern /dev/sd[a-z], while NVMe device signs have the following pattern /dev/nvme[1-9]n[1-9].

Creating Partition Table

To start partitioning the drive, run fdisk with the device name. In this example, we will work on /dev/sdb:

fdisk /dev/sdb

The command prompt will vary, and the fdisk dialogue where you can type in commands will open:

Welcome to fdisk (util-linux 2.34).

Corrections will remain in memory only until you decide to write them.

Be careful before using the write command.

Command (m for help):
Corrections you make to the partition table won't affect you until you write them with the w command. You can exit the fdisk dialogue without saving the changes using the q command.

To get a list of all available commands, enter m

(command m for help) m

Fdisk Command in Linux

If you are partitioning a new drive, you need to create a partition table before starting to create partitions. Skip this step if the device already has a partition table and you want to keep it.

fdisk supports several partitioning schemes. MBR and GPT are the two most popular partition scheme standards that store the partitioning information on a drive differently. GPT is a newer standard allowing and has many advantages over MBR. The main points to consider when choosing what partitioning standard to use:

  • Use MBR to boot the disk in legacy BIOS mode.
  • Use GPT to boot the disk in UEFI mode.
  • The MBR standard supports creating a disk partition up to 2 TiB. If you have a disk of 2 TiB or larger, use GPT.
  • MBR has a limit of 4 primary partitions. If you need more sections, one of the preceding sections can be set as an extended partition and hold additional logical partitions. With GPT, you can have up to 128 sections. GPT doesn’t support extended or logical partitions.

In this example, we will use a GPT partition table.

Enter g to create a new empty GPT partition table:

command (m for help) g


Created a new GPT disklabel (GUID: 4649EE36-3013-214E-961C-51A9187A7503).

The next step is to create the new partitions.

We will create two partitions. The first one with a size of 100 GiB, and the second one will take the rest of the disk space.

Run the n command to create a new partition:

command (m for help) n

You’ll be prompted to enter the partition number. Hit “Enter” to use the default value (1):

Partition number (1-128, default 1):

Next, the command will ask you to specify the first sector. Generally, it is always recommended to use the default values for the first value. Hit “Enter” to use the default value (2048):

First sector (2048-500118158, default 2048):

On the next prompt, you’ll need to enter the last sector. You can use an absolute value for the previous sector or relative importance to the start sector, using the + symbol following the partition size. The size can be specified in kibibytes (K), mebibytes (M), gibibytes (G), tebibytes (T), or pebibytes (P).

Enter +100G to set the partition size to 100 GiB:

Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-500118158, default 500118158): +100G

Created a new partition 1 of type' Linux filesystem' and size 100 GiB.

By default, the new partition type is set to “Linux filesystem,” which should be sufficient for most cases if you want to change the type, press l to get a list of partition types and then press t to change the style.

Let’s create the second partition that will take the rest of the disk space:

command (m for help) n
Partition number (2-128, default 2):

First sector (209717248-625142414, default 209717248):

Last sector, +/-sectors or +/-size{K,M,G,T,P} (209717248-625142414, default 625142414):

Once done creating partitions, use the p command to display the new partition table:

command (m for help) p

Disk /dev/sdb: 298.9 GiB, 320072933376 bytes, 625142448 sectors

Disk model: nal USB 3.0

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disklabel type: gpt

Disk identifier: F8365250-AF58-F74E-B592-D56E3A5DEED1

Device Start End Sectors Size Type

/dev/sdb1 2048 209717247 209715200 100G Linux filesystem

/dev/sdb2 209717248 625142414 415425167 198.1G Linux filesystem
If you want to delete a partition, use the d command.

Save the changes by running the w command:

command (m for help) p

The command will write the table to disk and exit the fdisk menu.


The partition table has been altered.

Calling ioctl() to re-read partition table.

Syncing disks.

The kernel will read the device partition table without the need to reboot the system.

Activating the Partitions

Now that the partitions have been created, the next step is to format the partitions and mount them to the system’s directory tree.

We’ll format both partitions to ext4:

sudo mkfs.ext4 -F /dev/sdb1sudo mkfs.ext4 -F /dev/sdb2

mke2fs 1.45.5 (07-Jan-2020)

Creating filesystem with 51928145 4k blocks and 12984320 inodes

Filesystem UUID: 63a3457e-c3a1-43f4-a0e6-01a7dbe7dfed

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done

Writing inode tables: done

Creating journal (262144 blocks): done

Writing superblocks and filesystem accounting information: done

We will mount the partitions to /mnt/audio and /mnt/video directories in this example.

Create the mount points with mkdir :

sudo mkdir -p /mnt/audio /mnt/video

Mount the new partition:

sudo mount /dev/sdb1 /mnt/audio
sudo mount /dev/sdb2 /mnt/video

Partitions will stay mounted until you unmount it or shut down the machine. To automatically mount a partition when your Linux system starts up, define the mount in the /etc/fstab file.

That’s it! You can now use the new partitions to store your files.
fdisk is a command-line tool for creating partition schemes. For more information about the fdisk command, type man fdisk in your terminal.

Chown Command in Linux (File Ownership)

If you want to change the user and/or group ownership of a given file, directory, or symbolic link, the chown command is used. So in this article, we will show you how to use the chown command through practical examples.

Let us see How to Use chown.

Before moving into how to use the chown command, let’s begin by examining the basic syntax.

The chown command expressions take the subsequent form:


USER is nothing but the user name or the user ID (UID) of the new owner. The name of the group ID (GID) or the new group is GROUP. The name of one or more directories, files, or links is FILE(s). Remember, always numeric IDs should be prefixed with the + symbol.

  • USER – If only the user is defined, the defined user will grow the given file owner, the group ownership is not changed.
  • USER: – When the username is succeeded by a colon: and the group name is not given, the user will become the owner of the files, and the files group ownership is transferred to the user’s login group.
  • USER: GROUP – If both the group and the user are defined (with no space between them), the user ownership of the files is transferred to the given user, and the group ownership is transferred to the given group.
  • GROUP – If the User is canceled and the group is prefixed with a colon, only the files’ group ownership is transferred to the given group.
  • : If only a colon: is given, without defining the user and the group, no change is made in it.

By default, on success, chown doesn’t give any output and returns zero.

To find out who holds a file or what group the file refers to, use the ls -l command:

$ ls -l filename.txt

-rw-r--r-- 12 linuxize users 12.0K Apr 8 20:51 filename.txt

Regular users can replace the filegroup only if they own the file and only to a group they are a member of. Administrative users can replace the group ownership of all files.

How to Replace the Owner of a File

If you want to replace the owner of a file, then use the chown command succeeded by the user name of the new owner and the target file as an argument:


For example, the subsequent command will transfer the ownership of a file named file1 to a new owner named linuxize:

$ chown linuxize file1

To transfer the ownership of multiple files or directories, define them as a space-separated list. The command below turns the ownership of a file named file1 and directory dir1 to a new owner named linuxize:

$ chown linuxize file1 dir1

For example, the subsequent command will transfer the ownership of a file named file1 to a new owner named linuxize:

$ chown linuxize file1

To transfer the ownership of multiple files or directories, specify them as a space-separated list. The command following transfers the ownership of a directory with name dir1 and a file with name file1 to a new owner named linuxize:

$ chown linuxize file1 dir1

The alternatively used for the username is the numeric user ID (UID). The following example will transfer the ownership of a file named file2 to a new owner with a UID of 1000:

$ chown 1000 file2

If a numeric owner survives as a user name, then the ownership will be transferred to the user name. To bypass this, prefix the ID with +:

$ chown 1000 file2

How to Replace the Owner and Group of a File

If you want to replace both the owner and the group of a file, use the chown command supported by the new owner and group separated by a colon (:) with no intermediary spaces and the target file.


The subsequent command will transfer the ownership of a file named file1 to a new owner named linuxize and group users:

$ chown linuxize: users file1

If you cancel the group name after the colon (:) the group of the file is replaced to the specified user’s login group:chown linuxize: file1

How to Replace the Group of a File

To replace only the group of a file, use the chown command followed by a colon (:) and the new group name (with no space between them) and the target file as an argument:

$ chown: GROUP FILE

The subsequent command will replace the owning group of a file named file1 to www-data:

$ chown :www-data file1

Another command that you can use to replace the group ownership of files is chgrp.

How to Replace Symbolic Links Ownership

When the recursive alternative is not used, the chown command replaces the group ownership of the files to which the symlinks point, not the symbolic links themselves.

For example, if you try to replace the owner and the group of the symbolic link symlink1 that points to /var/www/file1, chown will change the ownership of the file or directory the symlink points to:

$ chown www-data: symlink1

The possibilities are that instead of changing the target ownership, you will get an error “cannot dereference ‘symlink1’: Permission denied”.

The error happens because, by default on most Linux distributions, symlinks are protected, and you cannot work on target files. This option is defined in /proc/sys/fs/protected_symlinks. One means enabled, and zero means disabled. We suggest not to disable the symlink protection.

To replace the group ownership of the symlink itself, use the -h option:

$ chown -h www-data symlink1

How to Recursively Replace the File Ownership

To recursively run on all files and directories under the given directory, use the -R (–recursive) alternative:


The following example will transfer the ownership of all files and subdirectories under the /var/www directory to a new owner and group named www-data:

$ chown -R www-data: /var/www

If the directory contains symbolic links, pass the -h option:

$ chown -hR www-data: /var/www

Other alternatives that can be used when recursively replacing the directory ownership are -H and -L.

If the argument passed to the chown command is a symbolic link pointing to a directory, the -H option will create the command to cross it. -L tells chown to cross each symbolic link to a guide that is found. Usually, it would be best to use these choices because you might mess up your system or perform a security risk.

Using a Reference File

The -- reference = ref_file option enables you to change the user and group ownership of given files to be the same as those of the detailed reference file (ref_file). Chown will use the target file user and group; if the reference file is a symbolic link.

$ chown --reference=REF_FILE FILE

For instance, the subsequent command will allow the user and group ownership of the file1 to file2

$ chown --reference=file1 file2


The chown is a Linux/UNIX command-line service for developing the file’s user and/or group ownership.

To discover more about the chown command, visit the chown man page or type man chown in your terminal. If you have any questions or feedback, please leave a comment below or contact us directly.