More on Linux Basics and Commands

Hello there ! Today we are gonna learn basic linux commands and working with it. Most of you would probably have installed a linux distro like Ubuntu, Fedora, Mint, Manjaro, etc and many might also have installed Kali Linux and became 1337 haxxors XD but still don't know how to use linux. Before starting that lets's get brief about what is linux.

What is Linux Kernel?

Well Linux is actually a kernel. But generally speaking we refer to operating systems built upon Linux kernel while talking about linux. Kernel is the most important part of operating system or you can say base on which a whole operating system is built. It is the first thing to load up while booting and manages core features like memory management, user processes, cpu, tcp ip, I/O, etc and acts like bridge between software and hardware. Linux is monolithic kernel written by Linus Torvalds who was frustrated of then operating systems like MINIX. The Linux kernel, MINIX, BSD, Solaris, etc. are all derived from or are clones of UNIX made in 1972 written in C and assembly. Different applications, software packages, drivers and all that stuff with kernel make up an operating system.

Linux Commands

We will see some command line parameters in commands now. I am using 64bit Ubuntu 17.10 here which is Debian based. Most of these commands are found in /bin, /sbin, /usr/bin, in linux directory structure. Let's revise 'ls' with a few parameters this time.


ls basically lists all the files and directories in a directory. So it looks like this.

Note that virtual is my username here and mecha is hostname or the system name. ls -l lists all files in a listing format which shows the file permissions, no. of links, owner, creator, size, date and time of each file and directories.

ls -la The "-a" tag here shows all the files and folders in a directory including hidden ones (usually starting with ' . ').


Yeah man! This will be the most useful command for beginners. Man is an interface to the on-line reference manuals. So basically it's the complete manual for a command and utilities. It contains usage, description, all parameters, author and all info about a command. Whenever you are confused you can take a quick look at man page of the command. Syntax: man <command_name>


According to it's man page it says grep searches for PATTERN in each FILE. So yeah grep can be used to find some specific keyword or pattern in a text. I have saved this article as basic.txt and let's search where the word "linux" appears in it.

And voila! grep has highlighted all the appearings of linux in it. Note that it is case sensitive. Use-itag to ignore case. More info can be found in man page.

Piping in linux

Linux command line provides a great way to redirect output of one command into another and also chaining commands. Pipes are unidirectional. It's symbol is |. It can be found above Enter or Shift key with \ depending on keyboard.

Here output of cat is redirected to grep command which finds the word 'the' in the input it gets. Output of a command can also be directed into a file with > symbol. Single > means it will overwrite the file it's redirected to and >> means it will be written in next line in the file. Contents of file can also be directed to a command with < symbol.


A powerful Stream Editor for filtering and transforming text. It is mostly used for text replacement. According to it's man page- A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). Syntax: sed 's/pattern1/pattern2/g' file.txt. 's' here stands for substitution. This command substitutes pattern1 with pattern2. 'g' is for global so that it replaces all occurences of pattern1, replacing it with number n will replace nth occurence.

Try to figure out how I chained commands in the above screenshot. You can do lot of cool tricks with sed. It has many more options available. Try understanding this - adding parenthesis to first letter of every word. \b marks a word boundary, either beginning or end here.


AWK is another powerful tool for data manipulation according to user defined patterns. According to wikipedia "AWK is a programming language designed for text processing and typically used as a data extraction and reporting tool.". Syntax:awk options 'selection_criteria {action }' input-file
Consider this example. Here-F,tells awk to separate columns by,. Default is space . $3 tells it to print the 3rd column. AWK also has many more features and options.

Command Line Text Editors- Nano and Vim

Nano is a very simple user friendly text editor with quite many features. Just enter nano [options] filename to start editing the file. Ctrl+x can be used to exit nano.

Vim is a very powerful editor specially used for programs with hell lot of features and options. usage: vim [options] filename. Then enter'i'to enter insert mode. Esc and :wq to save and quit vim. Well there's hell lot more tips and tricks to learn about these editors which we can't cover now so you can find them in their man pages and online sources. Well that's all for now. I hope you learnt something and enjoyed. This was just brief intro on commands to make you guys familiar. More detailed guide can be found online. Keep researching. Keep learning. Comment down if you face some problem.


Popular Posts