fbpx
Linux 101

Your first Linux commands – Lesson 1 – Introduction

This course mixes screencasts, laborations, and reading material. The laborations are to be completed on a Debian Linux or Ubuntu installation. The course is also tailored to kinesthetic learning, that is, learning by doing. We will use visual learning methodologies with screencasts, screenshots, and graphs, but you do need to type commands and practice what you learn. In addition to the screencasts and reading material, as a learner, you have to complete laborations.

And here they are, your first Linux commands..

ls, pwd, cd, chmod

cp, cat, less, grep

vi, wc, nl, mkdir

who, ps, top, man

ping

Let’s go over some of the Linux commands that we will cover in this course. We will look at a few examples on how to run the commands and what they can do for you.

ls – list the contents of the current directory.

ls /etc – list the contents of the /etc directory.

cd /var – Change the current directory to /var/

vi <filename> – Edit the file named filename. Note that if the file doesn’t exist, it will b created.

wc -l <filename> – Count the lines in the file named <filename>.

mkdir adir – Create a directory named adir in the current directory.

grep <text> <filename> – Find all occurences of <text> in the file named <filename>.

nl <filename> – Show the contents of the file <filename> and number the lines.

ping www.google.com – See if google.com can be reached from the Linux box.

More commands that you will learn

You will need to be able to copy files. This is done with the cp command. When we want to create a package of files, maybe compressed, we can use the tar command.
cp, vi, tar

You will also need to list files in directories. This is done with the ls command.
Directories and Files are associated with user rights, and the rights that can be granted or revoked are Read, Write, and Execute. To change the user permissions on directories and files we use the chmod command. All directories and files also have a user as the owner. To change the owner, we use the chown command.
ls, chmod, chown

One of the most common tasks when working on the Linux commandline, is to search files for text patterns. We have a plenty of commands available for searching in files, but some of the most common are cat – to concatenate or simply display files on the screen. Grep which is used to filter out patterns in text files or data output. And then we have the awk text processing language. This can be invoked on the commandline to do advanced text processing. We will use the basic features of it.
cat, grep, awk

Your Linux box will be running programs, also known as processes. These processes can be listed, for example, to investigate resource usages such as memory or network usage.
To check running processes you can use the top command to show an interactive monitor of all processes running. You can also use ps which will give you a snapshot of processes.
top, ps

Quiz! Check what you learned

Moving on

Okay, so we have now seen some examples of how to use the Linux commands. We have also talked about use cases. Now it’s time to start scripting. We are going to put several commands in sequence and save them in script files, so-called Bash scripts. These can then be run on the Linux command line and Linux will run all the commands in the Bash script in one go! Get ready for lesson two, “Core ideas about Linux that you need to be aware of”.