How can I compile & run assembly in Ubuntu 18.04?

In all currently supported versions of Ubuntu open the terminal and type:

sudo apt install as31 nasm  

as31: Intel 8031/8051 assembler
This is a fast, simple, easy to use Intel 8031/8051 assembler.

nasm: General-purpose x86 assembler
Netwide Assembler. NASM will currently output flat-form binary files, a.out, COFF and ELF Unix object files, and Microsoft 16-bit DOS and Win32 object files.

This is the code for an assembly language program that prints Hello world.

section     .text
global      _start 
_start: 
    mov     edx,len   
    mov     ecx,msg   
    mov     ebx,1   
    mov     eax,4   
    int     0x80   
    mov     eax,1  
    int     0x80   
section     .data
msg     db  'Hello world',0xa  
len     equ $ - msg   

If you are using NASM in Ubuntu 18.04, the commands to compile and run an .asm file named hello.asm are:

nasm -f elf64 hello.asm # assemble the program  
ld -s -o hello hello.o # link the object file nasm produced into an executable file  
./hello # hello is an executable file

Ubuntu comes with as (the portable GNU assembler)

as file.s -o file.out
ld file.out -e main -o file
./file

-o: Tells where to send the output
-e: Tells ld the start symbol