For various reasons, most developers begin their journey on Windows. It is a great operating system which has brought computers on the desks of common households. For developers, it is important that they do not limit themselves by the operating system on which they usually work at home or office. A lot of servers on the internet and within the intranets of various organisation run Linux or Unix. The most popular flavours in organisations I have seen so far are: Red Hat Enterprise Linux and FreeBSD.
There is not much of a difference when it comes to using Linux or Unix. The difference lies in the implementation of the kernel. This does not change the user (developer) experience. The applications which run on the kernel are mostly the same on both FreeBSD and RHEL.
Practicing at home
To start practicing using Linux / Unix at home, install LinuxMint. Before you begin the installation, make sure you have a backup of your precious data. As you go through the installation process, you will realise that you can have both Windows and LinuxMint on the same computer. You have an option to choose which operating system you want to use when you boot.
Making friends with command prompt
When you are making a transition to Linux, the most dreaded element is the command prompt. Make friends with it, and you will thank yourself and the makers of various shells for your life.
xterm will bring up the command prompt for you. The first command you need to make friends with is “man“. It formats and displays the manual pages for various commands.
Use the arrow keys to scroll through the displayed “manpage”. To exit, type “q”.
Now try running:
Here is a list of commands I recommend that you know well enough. As you get a hang of it, you can use
man to know more about these commands (even the simple ones of these are very powerful and feature rich):
- vi or emacs
- These two are text editors (and much more). I prefer using emacs. You can choose your poison!
- Look for cheatsheets for these editors on the web.
Showing off your skill with shell scripting and regex
One day, in my office, we wanted to implement a workaround in a production environment, and we wanted it really quick. The top management was worried, and we had to react fast! My boss approached me and said, “Alok, please show us your scripting magic now!” I wrote a command line using a few commands and some regex in our development environment. It worked, and we provided that as a workaround! In no time, the production system was up with the workaround, and that bought us invaluable time to fix the real issue in the code!
Undermining the importance of shell scripting and regex often leads to extra efforts in a developers life. Unfortunately, a lot of people do not even realise this, as they are unaware of the power of these tools.
Did you know that if you run a command, you can send its output as input for other commands? This provides a powerful mechanism which enables us to write very useful scripts. Try using bash for shell scripting.
command1 > output.log
command1 &> output_and_error.log – The stdout and stderr is stored in the log file, which can be viewed later on. This is known as redirection.
command1 | command2 | command3 – The output of command1 becomes the input for command2. This is known as pipelining.
Apart from the ones listed above, here are some commands and functions you will find very useful for your scripting magic!
- sed – This will teach you regex.
Of course, there are more commands, tools, utilities, etc that will make you an advanced user of the Linux / Unix system.
So, fasten your seat belts, as take offs are often rough. But once you are up there, you will enjoy flying high with Linux / Unix!