Linux_logo_errorbits.comLinux is Everywhere!

(I won’t bother you too much with this introduction because I know how excited I was when I started for the first time to learn Linux. You can find here a small Linux Introduction.)

Linux is a very flexible operating system and as you already may know it can be found in everything from automobiles to rockets, phones, servers, personal computers, watches, TVs, IoE devices and the list continues…

I hope that you will find this tutorial very interesting and you will enjoy it!

What do I need in order to learn Linux?

  1. PC/Notebook (depending on Linux version that you would like to use I recommend: RAM – Min 4GB, CPU – Dual/Quad Core);
  2. Virtualization Software: Oracle VirtualBox (recommended and also free software) / VMWare (paid software);
  3. CentOS DVD image file;

Note: I do not recommend to install Linux (at this moment) as a SecondBoot or as a default operating system of your PC/notebook. What I recommend is to install CentOS on a Virtual Machine.

How to download and install Oracle VirtualBox?
How to install CentOS on Oracle VirtualBox?

Basic Linux Commands and Syntax

This tutorial deals exclusively with the CLI (Command Line Interface). The CLI is a very powerful interface that allows the users to administer small devices, extremely capable cloud computer servers, network devices and everything between them.
A command is a software program and when executed on the CLI, performs an action on the computer.

First of all install CentOS on the VirtualMachine Software, power on CentOS machine, login on the system and open the terminal window.

To execute a command, first type the command, for example ls, and hit Enter.
linux ls command errorbits.com

Note: The commands are case sensitive, so LS will not execute but ls will execute.
linux LS command errorbits.com_

Most of the commands follow a simple syntax: command [options] [arguments]. You have to type the command followed by options and/or arguments and then press Enter. The options usually alter the behavior of commands and arguments.

Arguments

An argument can be used to specify something that the command should act on. For example you can try the following example:

Example: ls /var/log (ls = “list” lists the contents of directory /var/log)
In this example /var/log/ is the argument used with ls command.
linux ls path command errorbits.com

Options.

Options are used to alter the behavior of commands. In the next example we will use -l option with ls command and see what happens.

Example: ls -l (-l = “long display”, means that will give more information)
It will output detailed information about the listed files.
linux ls -l command errorbits.com

Example: ls -r (-r “reverse”, it will reverse the alphabetical order)
linux ls -r command errorbits.com

Options can be used at once, combined or separated, but the output will be the same. Order of the options does not matter.

Example: ls -r -l (separated)
linux ls -r -l command errorbits.com
Example: ls -lr (combined)
linux ls -lr command errorbits.com

Printing Working Directory

To discover where we are located within file-system, we can use pwd command. We will use the term “Print” not to send information to a physical printer, but to send the information to be printed to the screen.

pwd [options]
linux pwd command errorbits.com_

Changing Directories

Directories are type of file used to store other files, they also provide hierarchical organization structure. To navigate the filesystem you can use the command cd (Change Directory).

cd [options] [path]
linux cd command errorbits.com

Listing files

The ls command is used to list the contents of a directory.

ls [options][path]

To get more details about a file, like permissions, ownerships or timestamps, perform a longlisting using -l option with the ls command.

Example: ls -l /var/log
linux ls -l path command errorbits.com

Each line contain the details about every file in the directory. The details are broken into columns separated by spaces.

File Types

The first column contains ten characters, the first character indicates the type of the file and the next nine characters indicates the file permissions:
linux file type errorbits.com
d | directory | A file that contains other files;
| regular file | Readable, images, binary and compressed files;
l | symbolic link | Points to other files;
s | socket | Allows for the communication between processes;
p | pipe | Allows for communication between processes;
b | block file | Used to communicate with hardware;
c | character file | Used to communicate with hardware.

Permissions
Permissions indicate how users can access the files.
linux file permissions errorbits.com

Hard Link Count
This number indicates how may hard links point to the file.
linux file hard link count errorbits.com

User Owner
When a file is created the ownership is automatically assigned to the user who created it.
linux file user owner errorbits.com

Group Owner
Shows which group owns the file.
linux file group owner errorbits.com

File Size
In case of a file the size is displayed in bytes and in case of a directory, multiple of the block size used by the file system.
linux file size errorbits.com

Timestamp
Indicates the time when the file’s content was last modified.
linux file timestamp errorbits.com

Filename
The last field contains the name of the file or directory.
linux filename errorbits.com

Symbolic Links
Symbolic link name will be displayed along with and arrow and the link to the original file.

Sorting
The output of the ls command is sorted alphabetically by filename, but it can be modified by ls options. In the example below ls command will be combined with -l option so the relevant details to be displayed and with the -S option which sorts by size.

The -S option will sort the files by size.
linux ls -l -S command errorbits.com

The -r option will reverse the order of any type of sort.
linux ls -rl command errorbits.com


Useful links:

Linux Directory Map / Structure

Introduction to Linux

Using Help in Linux

Download and install Oracle VirtualBox

How to install CentOS on Oracle VirtualBox