Friday, 16 January 2015

Search pattern using grep command in Linux

You can search word in file using grep command.

Syntax:
grep [options] <pattern> <file(s)>

Examples with different options:
1. grep anil file1
2. To search exact word in file
      grep -w 'anil' file2
3. To search words in multiple files or in directory
      grep -r 'anil' /tmp
4. Case insensitive search
      grep -i "Anil' file3


Note: If you want to discard errors during above commands execution, then redirect errors in /dev/null using below command [/dev/null is the device where anything you send simply disappears].

$ grep -w 'anil' /tmp/ 2> /dev/null

Thursday, 15 January 2015

create an empty file in linux

You can create an empty file using touch commad

Syntax:
touch [options] <filename or path to file>

Examples:
1. touch file1
2. Touch can also create any number of files simultaneously. The following command would create three new, empty files named file1, file2 and file3:
     touch file1 file2 file3
3. touch -t 201212101830.55 file1

Here’s the options for the command:
touch command options

Sunday, 11 January 2015

Copy/Move file in linux

You can copy/move file in linux using cp/mv command.

To copy file:
Syntax:
  • cp [options] <source file> <destination file>
  • cp [options] <source path of file> <destination path of file>
Examples:
  • cp file1 file2
  • cp /tmp/file1 /data/file2


To move file:
Syntax:
  • mv [options] <source file> <destination file>
  • mv [options] <source path of file> <destination path of file>
Examples:
  • mv file1 file2
  • mv /tmp/file1 /data/file2


Note: You can also use mv command to rename file

How to open/edit/close file in linux

You can open/edit file in linux using vi editor
Syntax:
  • vi [options] <file name or path to file> then press 'i' to open in insert[edit] mode

Examples:
  • vi file1
  • vi /tmp/file2
edit file in vi editor


To close opened file, follow below commands of vi editor:
  • To save file, type:
    • :wq<Enter Key>
  • To save file forcefully, type:
    • :wq!<Enter Key>
  • To close file without saving, type:
    • :q<Enter Key>
  • To close file forcefully, type:
    • :q!<Enter Key>



Note: If you are in insert mode and want to close file, then press Esc key first.

Thursday, 1 January 2015

What is Linux

Linux?

Linux is, in simplest terms, an open-source operating system based on UNIX. It is the software on a computer that enables applications and the computer operator to access the devices on the computer to perform desired functions.




The Birth of Linux:

On August 25, 1991, a Finn computer science student named Linus Torvalds made the following announcement to the Usenet group comp.os.minux:

"I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. This has been brewing since april, and is starting to get ready. I'd like any feedback on things people like/dislike in minix, as my OS resembles it somewhat (same physical layout of the file-system (due to practical reasons) (among other things)."

The “Minix” Torvalds referred to is a variant of the UNIX operating system, used as a guideline for his the free operating system he wanted to run on the x86-based consumer PCs of the day. “gnu” refers to the set of GNU (GNU Is Not Unix) tools first put together by Richard Stallman in 1983. UNIX, the operating system that started it all, had its origins in the old Bell Labs back in the early 60s.

Torvalds built the core of the Linux operating system, known as the kernel. A kernel alone does not make an operating system, but Stallman's GNU tools were from a project to create an operating system as well--a project that was missing a kernel to make Stallman's operating system complete. Torvalds' matching of GNU tools with the Linux kernel marked the beginning of the Linux operating system as it is known today.

Why Linux is better(in a nutshell)?

  1. No need to pay $100 for OS
  2. Forget about viruses
  3. Forget about drivers
  4. When the system has installed, why would you still need to install stuff?
  5. Updated all your software with a single click
  6. Enjoy free and unlimited support
  7. No big mess in your start menu
  8. Play thousands of games for free
  9. Let your old computer have a second life
  10. Are you tired of restarting your computer every time?
  11. Don't wait years for bugs to be solved; report and track them down
  12. Need new software, Don't bother searching the web, Linux gets it for you
Future of Linux:
Linux is already successful on many different kinds of devices, but there are also many technological areas where Linux is moving towards, even as desktop and server development continues to grow faster than any other operating system today.

In a nutshell, Install Linux and you will get to know its benefits.