Introduction
The Linux family of operating systems, while small, are a nonetheless important and integral part of the IT industry. In the IT industry you’ll find Linux systems in use, particularly working as Servers.
As IT professionals it is our responsibility to learn as much as we can about different technologies to facilitate and provide support to both customers and co-workers. The Linux terminal and file system can seem daunting at first. This guide serves to acquaint the worker with a look at some basic terminal commands as well as the naming conventions that differ from windows. We will then create some simple folder structures in the terminal. This is especially useful for Linux distributions that don’t use a GUI as all commands must be done in the Terminal.
For the purpose of this guide, I will be using one of the more popular versions of Linux, Ubuntu Desktop (latest version 20.04.20 LTS). Although there are seemingly hundreds if not thousands of different Linux distributions, they all share the same command line structure and functions.
Accessing the Terminal
On Ubuntu, the terminal can be accessed by going to the search function and typing the start of the words “Terminal”, “Shell”, “Command”, or “Prompt”. The search function on Ubuntu is accessed by left clicking on “Activities” in the top-left corner of the screen.
Alternatively, the terminal can be brought up with the shortcut Ctrl-Alt-T.
Basic Commands
-
pwd – Print Working Directory
The pwd lets us know where we are. It prints out the exact file path or folder for the directory that we are in.
-
ls – List
The ls command is the Linux equivalent of the ‘dir’ function in Windows. It lists the contents of your current directory.
-
cd – Change Directory
The cd command is used to move around changing directories. The ~/ key is shorthand for the local user. For example, to move to the local user’s Downloads folder, type “~/Downloads”.
The blue colouring means that we are now in this directory.
You can also press TAB while typing to autocomplete some words and commands.
-
clear – Clears our terminal screen
This one is self-explanatory, but nonetheless good for when you need to focus or start fresh.
-
mkdir <folder name> – Make a new directory (folder).
-
touch <file name> – Creates a new file.
-
xdg-open <file or folder name> – Open a file or folder in a relevant application.
Let’s combine these basic commands to create some folders on the desktop and create a text document inside them. I want to make a folder on the desktop, two folders in that folder, and one text document in one of the folders.
-
Open up a fresh terminal and type “cd ~/Desktop” to go to the Desktop.
-
Type “mkdir TestFolder1” or whatever you would like to name your folder.
-
Type “cd TestFolder1” to enter that folder.
-
On two separate lines, type “mkdir TestFolder2” and “mkdir TestFolder3”
-
Type “cd TestFolder2” and then “touch TestFile.txt” to create a text file inside TestFolder2.
-
Type “xdg-open TestFile.txt” to open the file.
Other Useful Commands
ls -l – List file permissions for users.
df -m – See available space of different partitions on disk (in megabytes)
cp – Copy files in the terminal. This command requires a destination.
mv – Similar to cp, mv simply moves file rather than creating a copy.
Example to copy our test file to the Desktop:
locate – Helps us locate specific files. This command needs to be installed, which brings up one of the coolest features of Linux.
Linux is fully customizable allowing Operating Systems to be as complex or as simple as desired. When I tried to use the locate command, it wasn’t installed on my copy of Ubuntu. We can install an ‘apt’ (linux version of an .exe) straight through the command line. ‘sudo’ means ‘super user do’ and is the Linux equivalent of running a program as an Administrator and require password authentication.
After installing the locate command, we can now run “locate TestFolder” again and voila!
This is very basic and there are thousands more Linux that can be ran. There are dozens of websites that list basic intermediate and complex terminal commands as well as online videos and an active community of users.
Welcome to Linux!