How to: Introduction to Ubuntu Server CLI

This page will help you guide through Ubuntu Server which might help you to get more used to Ubuntu (Server & Desktop) and its CLI/terminal.



Ubuntu is one of the most popular flavour between Linux distribution. There is a lot of documentation about the said operating system and it’s not only that: there is a whole forum to suggest new features or even get support! If you want to learn about Linux and the flavours of the operating systems I can recommend you to start using Ubuntu. We’re going to use Ubuntu Server. This means we will not use a GUI (Graphical User Interface), but a CLI (Command Line Interface) instead. However, this doesn’t mean this won’t work on Ubuntu Desktop! You can use this how-to for both systems!


I suggest you to use the following:

* You can install Ubuntu Server or desktop as your main operating system, but when something goes wrong it’s more difficult to recover. Therefore it’s recommended to use a virtual machine for now!


Difference between Ubuntu Server & Desktop

You can skip this if you’re not interested in some background information about both versions.

The main difference is that you control the server by using the CLI, which means you use commands to get things done. At the desktop version there is a GUI installed which makes it easier to navigate, but may limit you to get certain actions done in the GUI itself. It’s possible to install a GUI to your server, but it’s not recommended as it may slow down your server and might increase security risks.

When installing the Server edition you will be asked to install server packages like a SSH server or webserver. The desktop version will only ask you to install third-party packages i.e an MP3 player.

Desktop versions are supported for 3 years, where servers are supported for 5 years.



After you finished the installation of Ubuntu Server you will see the following Window.

logging in

This window tells you the following things: You’re running Ubuntu 16.10 on server ‘UX64’ with terminal session tty1. You can log-in with the credentials you created during the installation. As you might notice you won’t see any asterics (‘*’) while typing your password. This is a safety measure so other people can’t see the amount of character your password exists off.

Once logged in you will see a similar window:

logged in

This window notices you the last time you logged in with your account and with the terminal session it used. It also tells you if there are any updates for your operating system or software.

Down below under the security update notification you see your commands line. In the above example it tells you you’re logged in with user ‘rick’ at server ‘UX64’. The ‘$‘ character tells you the user you’re logged in with is a ‘normal user’. When it shows an ‘#‘ it means you have administrator rights.

The administrator on a Linux system has the name ‘root’. You can run commands as an administrator by using the sudo (super user do) command. We will explain this later.


File Structure

If you compare Linux with Windows, Linux uses a different filesystem than Windows does. As you might know Windows occasionally use a ‘C’ or ‘D’ disk or partition to store and identify file paths. It works different in Linux distributions and may even differ between Linux distributions.

file structure linux
Image is taken from:

You can say Linux operating systems works in the other way around compared to Windows. You start with the ‘root’, as the name suggests it’s the root or ‘beginning’ of your file structure. You can dive in several folders en files to navigate through the structure. It’s important to know that everything on this system is ‘registered’ as a file or folder, even the processes in the /proc directory!

Navigating through the system

The commands that you will learn to use may differ between Linux Distributions. We will first learn to navigate through your operating system, because how will you change/create files if you can’t even reach them?

It’s useful to know in which directory you’re currently working. To see so use the following command:


The ‘pwd’ stands for ‘print working directory’.

pwd command output home directory

We will use the ‘cd‘ (change directory) command to switch between directories. An example of  such command is:

cd /

This command changes your directory to the root directory. So if we want to move to our own user folder, we would use:

cd /home/rick

Of course this is in my case, as my account is called ‘rick’. Replace ‘rick’ with your own account name. Also a fast way to move to your home directory is to only use ‘cd‘.

Now we learnt how to navigate around, we want to know which files are located in the directory we’re working in. To do so we use the command:


The command stands for ‘list segments’. An example output of the command can be seen below. You may see different colours in each folder. Here is a list what each colour means:

  • Blue: Directory
  • Green: Executable or recognized data file
  • Sky Blue: Linked file
  • Yellow with black background: Device
  • Pink: Graphic image file
  • Red: Archive file (source)

ls command output

There are several arguments so you can extract or sort your data. To help you on your way I will list a few of them. You can always use the ‘man‘ command to get a manual of the command you want to use. To request the manual for the ‘ls’ command use ‘man ls‘.

In this example I want to have a detailed list where all the hidden files are shown. ‘ls -l’ shows you a detailed list, ‘ls -a’ shows you any hidden files. You can combine to command by using ‘ls -al’. An example output is shown in the image below.

output command ls-al in root directory



To make life easier, you can use the ‘tab’ button on your keyboard to auto-complete directories and paths. An example would be if you type ‘cd /h‘ and press the tab button, it will auto complete to ‘cd /home/‘. This make navigating faster and prevent you from making typo’s! This comes in handy when you need to navigate to files or directories with large files. Sometimes when there are other files with similar names it won’t let you auto-complete.


Creating and removing Files and Folders

Now we know how Ubuntu works and to navigate through it, we’re going to learn to create/delete files & directories!

To create a folder use:

mkdir <foldername>

To delete a folder use:

rmdir <foldername>

To create a file use:

touch <dersiredfilename>

To delete a file use:

rm <filename>

Remember when creating or deleting files or directories you need to be in the directory where the file or directory is located. If you don’t want to move to the location, you could use:

mkdir /home/rick/nameofyournewfolder

mkdir command in user home directory



This is going to be a difficult but important one. Every file and directory has specific permissions per user, user group and ‘everyone’. For example: if you have some pictures of your latest holiday which you rather not share, you want them to be hidden and not viewable by other users.

To get a better view of this, go to a random directory with different files and use the ‘ls -l’ command.

Permission view on /etc directory

You’ve got 3 different rights:

  1. r = Read permission
  2. w = Write permission
  3. x = Execute permission

As you can see, there are a total of 9 placed, for example, directory ‘vim’ has: ‘d rwx r-x r-x’ rights.

This means that the owner of the (‘d’) directory (in this case ‘root’) has ‘rwx‘ (read,write,execute) permissions. The usergroup of that user (also ‘root’) has ‘r-x‘ permissions which means they can read & execute. Last but not least Everyone (everyone besides the said user and usergroup) has ‘r-x‘ permissions. You always read these permission rows from the left to the right.


Changing permissions


Now we have learnt how the permissions work, we also want to know how to change them. To change permissions we’re going to use the command ‘chmod‘, because this command is an administrator command you will need to use ‘sudo‘ to use it.

sudo chmod

We won’t use the template we used above to read the file permissions, instead we will use numbers to indicate the permissions of our chmod command.


Citricks chmod Table
Octal Number Representation Permissions
0 - – - No permission(s)
1 - – x Execute
2 - w - Write
3 - u x Write + Execute
4 r – - Read
5 r – x Read + Execute
6 r w - Read + Write
7 r w x Read + Write + Execute

Being able to ‘execute’ a folder means you have access to the contents of said folder. Being able to ‘read’ a folder means you see the contents of a said folder. Being able to ‘write’ a folder means you you can add and delete contents in a folder.

A few examples:

chmod 644 test.txt

The owner of the file can read+write test.txt. The usergroup of the owner can read test.txt. Everyone can read test.txt.

chmod 777 test1.txt

The owner of the file can read+write+execute test1.txt. The usergroup of the owner can read+write+execute test1.txt. Everyone can read+write+execute test1.txt. As you can see this chmod command would not be a good idea to perform on private files, as everyone can view, edit or even delete the said file!


There are enough cases where you want to change the owner of a file or directory. To do so we use the ‘chown‘ command. An example of the chown command is shown below.

chown root:root /home/rick/test.txt

Like other commands there are many parameters you can use to customize the effect of your command. Before using chmod or chown I recommend to use either

man chmod


man chown

to educate yourself on how to more effectively use the mentioned commands.



If you think you’re missing some essential basics in this page, please let me know by leaving a comment down below. If helps me to maintain quality and help other users. Also don’t be afraid to leave any questions or suggestions on what tutorial/guide/document to make next!