Ubuntu Shell and Command Line Interface

Ubuntu Shell and Command Line Interface

Introduction and List of Basic Commands

Jul 5, 2021ยท

3 min read

๐Ÿ“ฑ The Shell - CLI vs GUI

Generally, a shell is the outermost layer of an operating system. It exposes an interface that allows a user to communicate with the kernel. This can be a graphical user interface (GUI) like a desktop environment, or a command line interface (CLI).

With some experience, the CLI is a much quicker way to navigate your operating system and perform any actions like opening an application or installing software. You're also not dependant on which parts a particular GUI exposes to you, or where to find the button you're looking for.

Ubuntu (like all Linux distributions) comes with the Bash Shell. Per Bash convention, the command prompt for a non-root user has the form


The ~ shows what the default working directory is (for a regular user, that's the /home directory), the $ indicates that the logged in user has no root priviliges. The root user would see a # instead.

Within a command, the # character marks a comment, everything that follows will be ignored. Using it makes little sense unless you write a shell script with multiple lines.

๐Ÿ“ฑ General Commands

# clear the terminal window

# list the last 500 commands

# enter the most recent command into command line

# print user manual for a command
man <command>

# list all processes

# list information about hardware and kernel (see uname --help for options)

๐Ÿ“ฑ Files and Directories


# list all files and folders in the current directory

# detailed list
ls -l

# include hidden files and folders
ls -a

# list all files and folders in any directory
ls </absolute/path/to/directory>

# print current working directory

# go to root directory
cd /

# go to home directory
cd ~

# locate the binary that is executed for a command
which <command>

# locate the binary, source and manual-page for a command
whereis <command>

Handling files and directories

# open file manager with *root* priviliges
sudo nautilus

# create directory
mkdir <dirname>

# create file
touch <filename>

# rename and/or move a file
mv <oldPath/oldFilename> <newPath/newFilename>

# copy file
cp <filename> <filenameOfCopy>

# remove file
rm <filename>

# remove directory
rmdir <dirname>

# recursively remove non-empty directory
rm -R <dirname>

Reading and writing to text files

# add text on a new line to a textfile
echo <your-text> >> <filename>

# display text content of file
cat <filename>

# join two text files and put the content in a third file
cat <filename1> <filename2>><filename3>

๐Ÿ“ฑ Network

# display the computer's hostname

# display IP address instead of hostname
hostname -i

# list network properties

# ping another computer
ping <ipaddress>
ping <domain>

# display nameserver records for a domain
nslookup -type=ns <domain>

# download a file from the internet to the current directory
wget <file_url>

๐Ÿ“ฑ Resources

Basic Bash Shell Commands

35 Linux Basic Commands

๐Ÿ“ฑ Thanks for reading!

If you find any errors or have additions, questions or just want to say hi, please leave a comment below, or get in touch via my website jsdisco.dev or Twitter.
Keep calm & code ๐Ÿ‘‹