Getting Started with Linux Command Line


What is Linux?

Just like Windows and Mac OS X, Linux is an operating system. It is an open source Unix-like operating system.

Although Linux is generally used to refer to the entire OS, Linux is basically the name of the Kernel which was developed by Linus Torvalds. I think this answer explains it all.


Linux Commands

We should have some basic ideas of Shell, Bash and Terminal first if we want to work with Linux Command Line.

Shell

The shell is a program that takes commands from the keyboard and gives them to the operating system to perform. Linux operating system offers several shells such as : bash, sh, csh etc. Although they have many commands in common, each type has unique features.

Terminal

Terminal (or Terminal Emulator) is a GUI which lets us interact with the shell. So, we can type and execute commands from the Terminal Window. There are many different Terminals bundled with different Desktop Environments, such as: gnome-terminal (GNOME), konsole(KDE) etc.


Working With the Terminal

We should easily find Terminal from the menu. The Terminal Window is like the image below

terminal

image source : linuxcommand.org

So, when we open the Terminal, we see something like this :

username@hostname:~$ 

root

In Linux, the root user is the superuser account. this is a special user account that has permission to do any task on a server. So, logged in as root can be potentially dangerous and we should not do that unless we really have to.

Still you need to know how do i login as root, right? you should able logged in as root by using the su - command on your terminal. If you getting any error message, your root account is likely locked. please check this tutorial for more information.

sudo

As we understand, logged in as root can be potentially dangerous and we should try to avoid that. so, how can we execute the restricted commands when needed? the answer is sudo. the sudo command allows a permitted user to execute a command as the superuser or another user.

for example, if we enter apt-get update command in our terminal, we will get the following error,

username@hostname:~$ apt-get update
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

but, when we use sudo in that same command, it works perfectly,

username@hostname:~$ sudo apt-get update
[sudo] password for username: 
Ign http://dl.google.com stable InRelease
Hit http://packages.microsoft.com stable InRelease                             
Hit http://dl.google.com stable Release.gpg  
........

Basic Commands

I think the best site to learn Linux Commands is linuxcommand.org. I am just trying to list some basics points.

Type of Commands

There are four different kinds of Commands :

If we want to know the type of any command, we can use the type command. i.e, type cd

Manipulating Files

We need to understand Wildcards feature in order to make powerful commands.

Current User

Permissions

We should understand Linux Permissions clearly.

Process

We should have clear idea about Linux Processes and Job Control.


Linux Filesystem

It’s useful to understand Linux Filesystem. Below is a image to get a basic idea.

File System

Image Source : http://imgur.com/gallery/1DH0O

To know more details, we can visit this Filesystem Hierarchy Standard page.

Comments

comments powered by Disqus