Linux from the Command Line

Using Ubuntu Via The Terminal

The basic idea of this page to give you some background on the concepts and tools contained in the document called “Basic Security Checklist – Ubuntu Security Focus”.

Ubuntu is a specific distribution of the operating system commonly called Linux. Most versions of Ubuntu come with a friendly graphical user interface. But many Linux users prefer knowing how to do things from the command line alone. That is the approach taken here.

If you are a complete beginner with the command line, it would probably be best to start with very simple things, like: How do I move around from one directory to another? How do I see a list of files in a directory? The playlist listed below can help with that:

00. Why you MUST use the Command Line (MOTIVATION)
01 covers cd and ls
02 covers cp and mv and rm and mkdir
If you are more of a printed-word style learner, visit and start with the ‘Learning the Shell’ section.

By the way, you’ll be using a rather complex argument with ls later on:
sudo ls -l /proc/aProcessIDnumber/exe


Beyond just getting around in the CLI, you’ll want to know the sudo command, which lets you temporarily act as if you are the SuperUser (root), then DO something with those elevated privileges.

Linux Commands for Beginners (Old Version): 07 – Sudo

sudo apt

One of those things is to use apt, or the Advanced Package Tool, for managing the software packages on your system. Consider the following video very optional–it’s probably way more than you want or need to know just yet.

Debian Package Management #1 – APT Basics

sudo apt-get
sudo apt-get install

Unlike plain old apt itself, you will defintely need to know how to use apt-get, especially apt-get install for … well, installing software …

Linux Terminal 201: Installing and Updating Packages – HakTip 149

So for example: sudo apt-get install …

clamav (per the checklist, do it first)
ufw (if not already installed)
nano ( ” ” )

… also sudo apt-get purge ‘applicationName’ (for removing application ‘applicationName’) …
… and sudo apt-get update … and sudo apt-get dist-upgrade (for updating the whole system)

sudo dpkg
sudo dpkg –get –selections | grep someApplicationName

dpkg is the Debian package manager. Debian is a Linux distribution that is the parent or predecessor of Ubuntu. See the latter half of the HakTip 149 video above (also discussed: apt-cache). Alternatively, type dpkg –help for more options (–help after any program almost always returns a help page for it).

sudo visudo

A simple practical use case for visudo, along with other commands such as su and pwd and ls along the way

Linux: Add user to sudo using the visudo command


In this context, cat to DISPLAY the contents of a file [or more than one]

How to Use Unix Cat Command

You’ll do this for:

cat /etc/group
cat /etc/passwd
cat /etc/shadow (must run with sudo)
cat /etc/cron.d


If we actually want to EDIT a file instead of just showing its contents, we need an editor, and nano is a sweet little CLI text editor.

nano for Text Editing in Ubuntu

You’ll do this for:

sudo nano /etc/sysctl.conf
sudo nano /etc/apt/apt.conf.d/10periodic
sudo nano /etc/init.d/rc.local
sudo nano /etc/login/defs
sudo nano /etc/pam.d/common-password
sudo nano /etc/ssh/sshd_config
sudo nano /etc/lightdm/lightdm.conf

Context-specific commands


sudo freshclam (updates virus signatures)
sudo clamscan –i –r –remove=yes / (scan entire system starting at root [/])


sudo ufw status
sudo ufw status verbose
sudo ufw enable
sudo ufw disable

sudo ufw allow telnet
sudo ufw allow 23 (does the same as above: telnet uses port 23 by default)
sudo ufw deny telnet
sudo ufw deny 23

sudo ufw app list


sudo passwd username (to change user ‘username’s password)
sudo passwd –u username (to enable user ‘username’s account)
sudo passwd –l username (to disable user ‘username’s account)
sudo adduser username (to create user ‘username’s user)
sudo deluser username –remove-home (to delete user ‘username’s home directory)


Use this command to find stuff.
For example: locate *.ogg will find all the .ogg files. The asterisk is called a ‘wildcard’, which means ‘anything’ in the search term. Also, consider running sudo updatedb before running locate … to update the search index first.

a few commands more

sudo netstat –tulnp
sudo kill aProcessIDnumber
sudo chkconfig –list | grep ‘3:on’
sudo service –status-all

Want to know more about the netstat, kill, chkconfig, service, or other commands?
Try ‘man’ (it stands for a ‘manual’ page.) For example, ‘man kill’ returns a description of the command, options that can be used with it (like –list), and examples of how to use it in the wild.