Showing posts with label Unix/Linux. Show all posts
Showing posts with label Unix/Linux. Show all posts
Thursday, May 13, 2010

Get Ubuntu 10.4 Free

Go to http://www.ubuntu.com/getubuntu and Request a CD to get your free copy of Ubuntu. It is totally FREE and no hidden cost.

Spread the love for Open Source.

PS: Do not Request for it if you are not going to use it. Let us not waste the resource, please! :)

Monday, May 10, 2010

Practically Useful UNIX Commands

Friends,

Last weekend my FireNookz’ (desktop) HDD crashed and I had a chance to install RHEL 5 in my system. After a long time I was trying to mess with some of the UNIX commands. I am not that expert in SED and AWK however I can survive and I am still learning though… I shall also share a “Practically Useful GREP Commands” as soon as possible but for now… Here are few commands which every UNIX professional may find useful.

______________________________

1. Display specific lines (based on line number) of a file using sed command

Syntax: $ sed -n -e Xp -e Yp FILENAME

sed : sed command, which will print all the lines by default.
-n : Suppresses output.
-e CMD : Command to be executed
Xp: Print line number X
Yp: Print line number Y
FILENAME : name of the file to be processed.

Example: $ sed -n -e 120p -e 145p -e 1050p /var/log/syslog

2. Viewing the content of var/log/cron from line number 101 to 110.

Syntax: sed -n M,Np FILENAME

M – Starting line number
N – Ending line number

Example: $ sed -n 101,110p /var/log/cron

3. Display first N lines of a file using head command

Syntax: head -n N FILENAME

Example: $ head -n 15 /var/log/maillog


4. Ignore last N lines of a file using head command and show only the remaining lines from the top of file.

Syntax: head -n -N FILENAME

Example: $ head -n -250 /var/log/secure

5. Display last N lines of the file using tail command

Syntax: tail -n N FILENAME

Example: $ tail -n 50 /var/log/messages

6. Ignore first N-1 lines of the file using tail command and show only the remaining of the lines.

Syntax: tail -n +N FILENAME

Example: $ tail -n +5 /etc/xinetd.conf

7. View growing log file in real time using tail command

Syntax: tail -f FILENAME

Example: $ tail -f /var/log/syslog

8. Display specific lines (based on line number) of a file using head and tail command

The example below will display line numbers 101 – 110 of /var/log/anaconda.log file

M – Starting line number
N – Ending line number

Syntax: cat file | tail -n +N | head -n (M-N+1)

Example: $ cat /var/log/anaconda.log | tail -n +101 | head -n 10

cat : prints the whole file to the stdout.
tail -n +101 : ignores lines upto the given line number, and then start printing lines after the given number.
head -n 10 : prints the first 10 line, that is 101 to 110 and ignores the remaining lines.

9. Display lines matching a pattern, and few lines following the match.
The following example displays the line that matches “Initializing CPU” from the /var/log/dmesg and 5 lines immediately after this match.
# grep "Initializing CPU#1" /var/log/dmesg
Initializing CPU#1
[Note: The above shows only the line matching the pattern]
 
# grep -A 5 "Initializing CPU#1" dmesg
Initializing CPU#1
Calibrating delay using timer specific routine.. 3989.96 BogoMIPS (lpj=1994982)
CPU: After generic identify, caps: bfebfbff 20100000 00000000 00000000
CPU: After vendor identify, caps:  bfebfbff 20100000 00000000 00000000
monitor/mwait feature present.
CPU: L1 I cache: 32K, L1 D cache: 32K
[Note: The above shows the line and 5 lines after the pattern matching]
PS:
Viewing N lines after the match with -A option.
Viewing N lines before the match with -B option.
Viewing N lines around the match with -C option.

10. Displaying specific bytes from a file.

Display first 40 bytes from syslog.
$ head -c40 /var/log/syslog

Display last 30 bytes from syslog.
$ tail -c30 /var/log/syslog

11. Viewing compressed log files

The following example explains how to display either the top 40 or the last 30 bytes of a file.

# Display the first N lines of a compressed file.
$ zcat file.gz | head -250

# Display the last N lines of a compressed file.
$ zcat file.gz | tail -250

# Ignoring the last N lines of a compressed file.
$ zcat file.gz | head -n -250

# Ignoring the first N lines of a compressed file.
$ zcat file.gz | tail -n +250

# Viewing the lines matching the pattern
$ zcat file.gz | grep -A2 'error'

# Viewing particular range of lines identified by line number.
$ zcat file.gz | sed -n -e 45p -e 52p

Happy Learning!

Thursday, October 1, 2009

Build your own Linux OS from the Scratch

Do you think you can make a better fast-booting, Chrome-focused OS than Google? Do you want to craft a custom Linux system that boots from a USB stick?

SUSE Studio gives you 15 GB to do exactly that, and you do it all online. Even if you don't know all that much about Linux, it's pretty easy to build a system you can boot from a USB stick or live CD/DVD, run inside a virtual machine program, or actually install it—or, heck, even test it out in your web browser.

Check SUSE Studio for more details

Wednesday, April 15, 2009

Choosing the right Linux distribution

Have you got a laptop or a PC at home? It is the right time for you to try your nasty hands on some of the Linux distributions. Linux is not windows but you sure will get everything in Linux which you get in Windows… the GUI, Play Games, Listen to mp3, Chat, watch videos, even use windows inside Linux, ... you name it!

Try Linux at your home today…

Take The Quiz to find out which distribution suits you the best. The exciting part is, you get Live CDs too so you can experience Linux even without installing it in your system.

Thursday, April 9, 2009

SliTaz - The 30 MB OS

When you are bored at home and got nothing better to do, download SliTaz Live CD & experiment it!

To brief on it, SliTaz is the GNU/Linux OS sizing less than 30 MB. It boots very fast and contains many daily applications. You can also install it on HD or run it on USB key. SliTaz is NOT a brand new OS. It’s been around for more than 6 months. I got lucky enough to try it only now…

Check out More About SliTaz

The title says it all :)

Check out SMS (Slack Mini Server) Project. Check What SLAMP is, if you are not aware.

Saturday, January 24, 2009

What is Linux?

In my earlier post, we saw what is UNIX. In this article, we will be discussing about Linux.

UNIX & Linux - Sounds so rhyming, Isn’t it?

Well, are Linux and UNIX one and the same?
If not, in what ways do they differ?
Why should they be different at all?
Is Linux free?

Slow down, we will surely be discussing all about this shortly…

The UNIX days

Let’s first see how Linux came into existence. As we discussed in my other post, UNIX already had a strong position in the server market and was especially strong in universities during 1990. Most universities, computer science students wanted to run UNIX on their own computers as well. Unfortunately, by that time, UNIX had become commercial and rather expensive.

OS Exposed

MINIX appeared to be a solution and also a cheap alternative. It however could not be called as a totally perfect flawless operating system. It can not be, as it was created for students. Andrew S. Tanenbaum, who wrote MINIX from the scratch has even wrote a book Operating Systems: Design and Implementation'. If you ever get to have a copy of that book, you sure will also be having 12,000 lines of code, written in C and assembly language. As you guessed, this book has dragged the attention of all the computer students who aspire to know the in and outs of an operating system. Linus Torvalds is one amongst.

Linux born


Linus Torvalds was using UNIX at his university of Helsinki and he wanted something similar to Unix at his home PC. As UNIX wasn’t free, he started out with Minix. He still felt that he wanted something more powerful than Minix and sooner started the project of writing down his own OS and named it Linux (I read somewhere that Linus initially was planning to name his OS as Freax. I wonder why).

GNU Linux

Linux however itself was only the kernel of an operating system. If in case you are not sure what a Kernel is, the kernel is the part that makes all other programs run. It implements multitasking, and manages hardware devices, and generally enables applications to do their thing. All the programs that the user (or system administrator) actually interacts with are run on top of the kernel - CLI (or shell) is an example.

Linus did really not write these programs all by him. He adopted the existing versions of the application and integrated them all. From time to time he was also updating his kernel to support a wide variety of new applications/programs.

Most of the critically important system software, including the C compiler, came from the Free Software Foundation's GNU project. GNU expands out to GNU is NOT UNIX was started in 1984 (the year when I was born, I am glad Lol). The main objective of the GNU project was to develop a complete Unix-like operating system which is completely free. GNU's kernel wasn't finished (now GNU have their own kernel as well) and so GNU is used with the kernel Linux. To credit, GNU, most of the people refer Linux as GNU/Linux.

Development of Linux

During the 1992 and 1993, the Linux kernel collected many of the useful and critical features to make it a better replacement for UNIX. That included TCP/IP networking, a GUI (called as the X system), etc. The version 1.0 of Linux kernel was released by March 1994. Since then, the kernel went through a number of updating and enhancement which made it further stable.

Various flavors of Linux

Like Unix, Linux also have various flavors. Red Hat Linux, IBM’s AIX, Sun Microsystems’ Solaris, Debian, Mandrake, SUSE, well they really are a lot. Even though there are various flavors you will find a lot of similarities. Every one is not specialist to compile the kernel and start everything from the scratch to get their OS up and ready for running. That is when these vendors came into picture. Vendors like Red hat, Sun Microsystems will do all the necessary basic things for you and get the OS up and ready in the .iso format which you can directly burn onto a CD and install in your system. They also provide updates and support which obviously is not going to be free. :)

Actually, I wanted to give a brief overview on what Linux is & history and I very well know that I have not mentioned many of the great contributors without whom the Linux would not exist today. If you are too keen, you can check out the Detailed Linux History. If you would like to hear it from the author, check out the mails chains from Linus Torvalds. You would get nothing technical there, I mind you. :)

If you are a M$ users, keep your windows out and let the air in. Try Linux once. You might like it. I am NOT advertising or trying to pull M$ users to Linux. Windows has it's own advantages and so is Linux. Also, It is not that Linux will gain popularity only if you start using it. Let's face it... Linux already is booming and been recognized as one of the most secured and best operating system. Almost every institution and industry has started to adopt Linux. So, Use it if you want to experience it. Get to know yourself why is Linux so popular and you know what? GNU/Linux is user friendly. It just is picky about who its friends are :)

Saturday, December 27, 2008

What is Unix?

I already have decided that I should post some articles on Unix/Linux. As I was wondering what and where shall I start from, I decided to start my posting from Introducing what Unix is. There really are a bunch of tutorials over the Internet to know about Unix, I am not denying the fact. This however is my way of writing what I learnt from others and other resources. That makes me happy :)

Okay, now enough with the stories, let's get down to the work straight away...


UNIX - as an Operating System

Unix is an operating system rather a specification. As many of you might be thinking, UNIX (pronounced YEW-nihks) is NOT an acronym. Unix is said to be a pun of Multics. Wondering what a Multics is? Well, Multics is a large multi-user operating system developed at Bell Labs shortly before Unix was created in the early '70s. (Brian Kernighan is credited with the name).

UNIX - as a Specification

Unix became the first open or standard operating system that could be improved or enhanced by anyone. A composite of the C language and shell (user command) interfaces from different versions of Unix were standardized under the auspices of the IEEE as the Portable Operating System Interface (POSIX). In turn, the POSIX interfaces were specified in the X/Open Programming Guide. These interfaces are also known as the "Single UNIX Specification" (SUS). The trademarked "UNIX" is now owned by the Open Group, an industry standards organization, which certifies and brands Unix implementations.

Brief History on Unix:

I did really not wanted to explain the History of Unix as there already are awesome links. I would suggest you to go through the below links to know more about the History of Unix.

A very brief look at Unix history
Levenez’s UNIX History
Unix History and Timeline from Unix.Org
A Brief History of Unix by Charles Severance

These links will recite you enough story about the History of Unix. If you still are striving for more, feel free to Google!

The Unix Impact:

Unix had real significant impact on the other Operating systems. Unix made the fact, "Assembly Language is necessary for systems implementation (on early computers)" a myth as Unix was written in high level language. Unix had drastically simplified file model compared to many contemporary operating systems. Yeah, everything in Unix is treated like a file, as simple byte arrays. The file system hierarchy contained machine services and devices (such as printers, terminals, or disk drives), providing a uniform interface. Unix is a stable, multi-user, multi-tasking system for servers, desktops and laptops. One fact about Unix is that it has less downtime, but has a higher learning curve

Unix Advantages

  • Unix is a real multitasking OS. Multiple users can run multiple programs each at the same time without interfering with each other or crashing the system. Isn't that cool?
  • The way how virtual memory is handled in Unix is very efficient and hence numerous numbers of programs can run with a decent amount of physical memory.
  • The security and access controls are handled in the best manner ever when compared to the competing Operating systems.
  • Unix has a powerful and unique file system. Like I said earlier, Everything is a file. Let it be a data, programs, or even all those physical devices, they all are considered as a file. Entire file system appears as a single large tree of nested directories regardless of how many different physical devices (disks) are included.
  • A lean kernel that gives you complete freedom - Yeah Unix kernel does the basics for you but doesn't get in the way when you try to do the unusual.
  • Unix is one Portable OS i.e., it's available on a wide variety of machines.
  • Optimized for program development, and thus for the unusual circumstances that are the rule in research.
Unix Disadvantages

All the Unix beginners complaint about are the below:
  • It's hard to install - I am telling you, it really is not that hard until you learn it. Unix does not follow the "I AGREE->NEXT->NEXT->FINISH" kind of process. Learn to get the hang of it. I know you can :)
  • I hate this terminal thingy - Why even try it if you hate it that much. The traditional command line shell interface (CLI) is not for the ones that are so used to the GUI environment. The CLI (or terminal) is designed for the programmer, not the casual user. Unix has it's own GUI, use it and quit complaining Lol

Various Unix flavors:

As you know (pardon me, if you don’t Lol), Unix is not a single operating system. It has many flavors i.e., variants, types, or you can even say it as implementations. Even though, it is based on a core set of Unix commands, different flavors have their own additional unique commands and features, and designed to work with different types of hardware. To be honest, no one knows exactly how many Unix flavors are there, but it is safe to say that if including all those that are obscure and obsolete, the number of Unix flavors is at least in the hundreds. You can often tell that an operating system is in the Unix family if it has a name that is a combination of the letters U, I, and X.

To mention a few, AIX by IBM, Solaris by Sun Microsystems. If you are so eager to know more, check the Unix Flavors Page

Also, go through 2008 Server OS Reliability Survey at leisure. Worth a read!