Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
My notes on how I survived the transition to Linux
Source : https://www.pexels.com/photo/blur-bright-business-codes-207580/
Switching from Windows to Linux can be really scary. But if you can survive the first few months the returns are exponential. Here is how I survived.
TLDR
- Though I just an amateur in Linux, I was able to survive the transition and indeed benefit from it. So these are my notes for somebody facing similar situation.
- Pick Ubuntu to start with. Choose other flavours once you know better and can decide for yourself.
- Get comfortable with following commands ssh, pwd, ls, cd, mv, cp, scp, grep, find, rm . Tip you can use https://tldr.ostera.io/cp to get comfortable with most frequently used options of these commands.
- Learn to use the | symbol. Using this you can pass the output of one command as an input to the next command.
The long version
In my first company we were using windows extensively, whether it was desktop machines we used for development or the servers on which we deployed our code. So when I moved to my second company which was all in on OSS and using linux was a given but a herculean task for me. For the first month or so it was a nightmare for me.
Having gone through that nightmare and survived it, I am making this list which can help others like me who are trying to make this transition.
New Environments
In general transitions are hard. New environments can be scary. If you are a windows user who has never used the command line much then transition to Linux can be really scary. Don’t fret because that is generally the experience of many people who are making this transition for the first time.
Two main reasons I personally feel that makes transitions difficult are Lack of familiarity and Fear of screwing up.
Lack of familiarity
To address the issues of familiarity I started using linux on my office laptop as well as personal laptop. I started reading up blogs about Linux and followed some interesting linux related accounts on twitter. I reached out to people who were good in linux. I would walk up to their cubicles and ask them to show me their command history. I have learned a lot from this. Most of the times since it is in their muscle memory they can’t explain it. But their history is a treasure trove.
I would recommend running the following command. You will get many insights about what are the commands you use frequently.
history | awk ‘{ $1=””; print $0 }’ | sort | uniq -c | sort -nr | head -20
Run the command on the terminals of top linux gurus in your office. Ask them about the commands you are not familiar about and you should be able to learn a lot more than what couple of books could teach you. Don’t forget that these are battle tested commands and hence much more valuable than standard examples in blogs.
Fear of screwing up
I have been using linux for couple of years but I still have this fear. This fear was multi-fold when I started. One thing that helped me a lot was I spoke to Linux pros in my company and made a black list. List of commands that I should never use or use with caution. sudo rm -rf was the top in the list. If you are anxious like me you can use https://github.com/nivekuil/rip on your local machine. When I was going through this stage of “Fear of screwing up” https://twitter.com/chakri_iiith and https://twitter.com/tuxnani were of grea help. Find your angels and they will help you face your fears.
Now that your fears are addressed let us get started.
Why you should learn Linux
There are countless reasons why you should learn Linux. You can ready the following posts What are the benefits of learning Linux, Why you should switch to Linux and Is it worth my time to learn Linux while learning programming. Just a google search can fetch you multiple articles about why you should learn Linux. But here are my top two reasons why you should learn.
- Linux is Ubiquitous : Linux is everywhere. So with or without your knowledge there is a high probability that you are already using linux. So understanding the basics of Linux can come handy in many situations. If you are a programmer then that chance is very high. A fair number of applications are deployed on Linux servers. So learning it can be a lifesaver.
- Linux is Versatile : Both Linux and MAC are built on UNIX. So if you are comfortable with Linux terminal you should be able to use most of the commands in MAC terminal as well. Android uses the Linux kernel. Raspberry Pi uses Linux. Many embedded devices use Linux.
Why did you start learning Linux?
There can be many reasons for you to learn Linux. But if you are a programmer there is a fair chance that you fall into one of the two following categories.
- You read up about the cool things that Linux can do or you heard from a friend who just can’t stop raving about Linux. Hence you wanted to get your hands dirty with linux.
- Your laptop or desktop has a non-unix OS. But your application/website is deployed on a Linux server. Hence you want to get comfortable with Linux or rather survive using Linux.
If you fall under Category 1, you have all the time in the world. So take your sweet little time. If you fall under Category 2, then there is a fair chance that you are running against a deadline.
Man command is your friend? Or is it?
One of the first tips you get when you want to learn Linux is “Use man command, it is your friend”. While there is certain truth to it, it can be overwhelming for many first time users. All you generally needs is the options for the most frequently used scenarios of the command and that is what is precisely missing form man pages. This is exactly the gap that TLDR project is trying to fix.
Just compare the outputs of these two commands to know what I mean.
First, output from man pages.
Now the output from TLDR project.
Do you see the difference? TLDR is like the notes about commands I would have written for myself. I find it very handy. I installed the TLDR using nodejs command sudo npm i -g tldr If you have not installed nodejs I suggest you do it, as there are many node packages that are very handy. You can install nodejs using this installation manual by Digitial Ocean.
I thought of sharing my notes on all the commands in this post. But I came across a post by Andrew where he converts 101 bash commands
https://dev.to/awwsmm/101-bash-commands-and-tips-for-beginners-to-experts-30je#whereis-which-whatis
He has categorised all the commands and has good examples as well. I cannot do a better job than that. So I am leaving you with the link here which you can read.
Learn about bash profiles
I found bash config files are bash profiles to be handy. If you want to know the differences and how they work check out https://stackoverflow.com/a/415444/493742
One rule of thumb I follow is to add all my configs to .bash_profile and also make sure to load .bashrc within the .bash_profile file. I add my favorite aliases to this file. I keep a basic version of my .bash_profile in my private gist and I download the raw version of that on the servers that I need.
Learn to use Emacs
One thing that I look for these days is commonality. Most of the commands used in emacs can also be used in Linux shell. For example you can use CTRL/CMD+A to go to the beginning of the line both shell and emacs. There are many such commands which work in both shell and emacs. I think this is a huge advantage.
Since it is a command line editor you can install it easily on any server. On every server where I am root I generally install Emacs. I am not sure if this is a good practice but I generally find it very convenient. Yes I have decided not to learn Nano or Vim. Roast me for it if you want to.
PIPE it
Pipe command in Linux lets you use the output of one command as the input of the next command. This can be really helpful once you get a hang of a few linux commands like grep, sort, awk, uniq, head and tail. Piping along with these commands is immensely powerful. For example I never remember what are the options in ls for showing only text files. I just do
ls -l | grep txt
I know this is quick and dirty but it works in most of the scenarios.
For example if we look at the history processing command we used in the first section
history | awk ‘{ $1=””; print $0 }’ | sort | uniq -c | sort -nr | head -20
We are taking the output of the history command, we are passing it to awk to remove the line numbers from the output. Then we are passing the output so that we can sort it. Then we are passing the output to filter out only unique lines along with the number of occurrences. Then we are passing it to sort command to the sort command to sort it in reverse order. Then we are passing it to head command to list only the top 20 of most frequently used commands that are present in our history.
How cools is that? I was impressed when I learnt it for the first time. What is beautiful is that you pretty much modify the above command to get insights in most of the day do requirements from command line.
GREP it
If you are used to SDKs and GUI editors GREP this might seem little limited. But most of the times the differentiator is that you can chain the output of the grep command that is very handy. Most of the times I am not really worried about the performance of the grep queries. Only when the performance of the grep query matters I spend time on it. In all other cases I find it better to beat the heck out of grep and chain in multiple times.
So for example when I wanted to check the list of services that were loaded I quickly looked at the pattern and used the following command.
systemctl list-units --all | grep service | grep loaded
So here what I have done is I have reduced the result set to those lines that contain the word service , from that result set I am again filtering for the lines that also contain loaded . Let us in addition that you want to remove the lines that contain exited then you can modify the query to
systemctl list-units --all | grep service | grep loaded | grep -v exited
Piping grep with grep is very handy.
Before we close
For me the primary criteria while working on Linux was not to get overwhelmed by command line and the learning curve. I designed my learning path to suit my requirements. Do let me know if this works out for you. If you are also a user who has successfully transitioned from other OS into linux do share you notes.
Linux Survival Guide for Beginners was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.