DEV Community

Cover image for Intro To Linux [For Beginners]
Ishan Sharma
Ishan Sharma

Posted on • Edited on • Originally published at blog.ishandeveloper.com

Intro To Linux [For Beginners]

One of the most important tools for a programmer is the Operating System, it runs your whole device and it's important to choose the one that suits you the best!

In this post, I'll be sharing why Linux could be the best choice for your 'Developer' workflow.

Have never heard about Linux ? Don't worry, I'll explain everything. But first, allow me to share a quick fact with you, whether you know it or not,

YOU USE LINUX EVERYDAY.



Yes, you read that correct. Over 850,000 Android Phones running Linux are activated every single day. Meaning, about 100 devices came online, since you started reading this article 😉. Nearly 700,000 Televisions running Linux are sold every day. 8 out of 10 Financial Trades are powered by Linux. 9 out of 10 World's Supercomputers run Linux. Most of the websites you visit (Even this!) are powered by Linux. Hell, even most of the Satellites in the space, are powered by Linux!

That's the sheer scale, versatility & power of Linux!

and that is also one of the most important reasons that you should learn to use Linux, using Linux you'll be able to command such a huge variety of devices.

Let's get started.

What Is Linux?

Linux is actually a kernel.

The Linux kernel is the main component of a Linux operating system (OS) and is the core interface between a computer’s hardware and its processes. It communicates between the two, managing resources as efficiently as possible.

The Linux kernel is world's largest open source project in the computing history! It's available here.

Many Operating systems are based on this including Ubuntu, Kubuntu, Debian, Fedora, PopOS, Kali Linux etc. These are called Linux distributions.

When someone says to you that they use linux, what they actually mean is that they use some distribution of Linux.

I hope this is insightful and encourages someone else to make the jump into Linux for doing development work, I have enjoyed the OS so much that I'm actually taking courses on Linux administration and working on becoming a power user. Something I never felt inspired to do on Windows.

What's So Special About Linux?

  1. Open source.
  2. Flexibility
  3. It's Free.
  4. High Security.
  5. Highly Customizable.

1. Open Source

Linux is great for the open-source benefits, which encompass not only the freedom of the software but also that a lot of the open-source projects do not track and sell user data like closed-source projects have been known to do. The customization of Linux is a second-tier factor, but still super imperative for users like you and I. I love to be able to use different shells, the package management solutions, the wide array of software to choose from, and the community support offered by the service. With Windows 10, so many trackers come on the system now, I would say privacy is a big win for Linux right now.

2. Flexibility

Linux is flexible. Linux is used in a lot of different types of computers. From smart toasters and refrigerators, IOT devices, internet routers, Android smartphones to satellites in the space. You can install Linux on your laptop or desktop today and be up and running with little set up! This flexibility is possible because a Linux operating system is designed to be the sum of many different tools that do one job and do it well. You could piece together a version of Linux that works for your device and is optimized for your needs.

3. It's Free

Linux is free. Free in multiple ways, you don't need to pay to use Linux and you're free to view, edit, and distribute the source code. When you buy a computer with Windows or mac-OS, the cost of creating and maintaining these operating systems is included in the price.

4. High Security

Linux is an open operating system, the codes which can be read by everyone. So there are far better chances that when thousands of contributors are collaborating over the same software, it is less probable for any bug or security loopholes to exist, even if they do, they'll usually be fixed in a short amount of time. Also, the ground up design of the Linux distributions is made to be redundant, users have a lower access rights, and, theoretically, even if a virus gets installed, the virus can only access local files and folders, and the system will remain safe.

5. Customization

If you know your way around the Linux system and you can customize every single corner of it, the whole project code is open-source, therefore you can modify the code to customize the OS and even distribute it as a distribution of your own.

So, Which one should I choose?

There are hundreds of Linux distributions to choose from.\

As the kernel is open source, it allows basically anyone to use it and build their own custom operating system. According to Wikipedia, there are over 600 Linux Distributions, you can check the facts here.

But for the general usage, Ubuntu, Fedora, Debian are much popular. For penetration testing, Kali Linux is a popular choice and also CentOS for enterprise grade.

Linux Distributions

Each of these distributions have their own strengths & weaknesses, so before switching to a distribution, do check out some sources about which one to choose. If you're absolute beginner, my personal recommendation would be using Ubuntu.

Basic Linux Commands

Now that you know what Linux is, why you should consider using it and once you've chosen a Distribution, it's time to dig into the actual OS.

Let's see some basic commands in Linux.

NOTE : Linux commands are case sensitive hence you need to be careful about what you are typing.

1. ls command

It refers to List directory contents. If you know windows you
would know that the command dir is used to list the contents in
a directory. In Linux, the ls command is used to list out files
and directories.

ls -l helps to paginate the output so you can view page by
page. Otherwise the listing scrolls down rapidly.

  ls -l filename|foldername
Enter fullscreen mode Exit fullscreen mode

2. cd command

It helps to change the current directory. In linux, forward slash is used to denote the contents of a directory.

  cd /etc/
Enter fullscreen mode Exit fullscreen mode

3. grep command

It is used to find text in a file. The grep command searches through many files at a time to find a piece of text you are looking for.

The below command will find all of the words in the linux.txt file that matched the word ‘ishandeveloper’.

  grep 'ishandeveloper' linux.txt
Enter fullscreen mode Exit fullscreen mode

It's syntax is : grep PATTERN [FILE].

4. sudo/su command

There are some commands that need elevated rights to run on a Linux system. So you run them as a System Administrator which normal users cannot do.

su command changes the shell to be used as a super user and until you use the exit command you can continue to be the super user

sudo – if you just need to run something as a super user once, you can use the sudo command instead.

  sudo shutdown 5
Enter fullscreen mode Exit fullscreen mode

5. pwd command

To identify the directory you are working in you can use the pwd command.
It displays the current working directory path and is useful when directory changes are often

  pwd
Enter fullscreen mode Exit fullscreen mode

6. touch command

It is used to create a new empty file in the existing directory.

  touch old.txt
Enter fullscreen mode Exit fullscreen mode

It's syntax is : touch [FileName].

You'll notice that a new file 'old.txt' will be created in the current directory.

7. mv move command

It is used to move a file or rename a file.

  mv old.txt new.txt
Enter fullscreen mode Exit fullscreen mode

8. cp copy command

It is used to make a copy of an existing file, with a new name in the same directory or similar name in another directory.

  cp new.txt newest.txt
Enter fullscreen mode Exit fullscreen mode

It's syntax is : cp [SOURCEFILE]  [DESTINATIONFILE].

9. rm command

This command is used to remove files in a directory or the directory itself. A directory cannot be removed if it is not empty.

  rm file.txt
  rm -r directory
Enter fullscreen mode Exit fullscreen mode

rm –r removes all the contents in a directory and the directory as well.

It's syntax is : rm [name of the file]

10. mkdir command

It is used to create a new directory/folder in the current location

  mkdir newFolder
Enter fullscreen mode Exit fullscreen mode

It's syntax is : mkdir [directory name]

11. chmod command [Thanks to @kailyons]
It is used to change the mode of a file system object. Files can have r – read, w- write and x-execute permissions.

It is fairly easy to change the permissions of a file for a quick edit. All you need to do is chmod +/-<permission_char>

To gain executable permissions for a script file you can use :

   chmod +x script.sh
Enter fullscreen mode Exit fullscreen mode

To remove those permissions for a script file you can use :

   chmod -x script.sh
Enter fullscreen mode Exit fullscreen mode

You can refer to this, to learn more about the permission codes in Linux.

12. apt –get command
apt -get is actually a very powerful and free front-end package manager. It is used to install new software packages, remove available software packages, upgrade existing software packages as well as upgrade the entire operating system. Here, apt – stands for advanced packaging tool.

  sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

The above command will update all the packages currently installed on your system.

Linux doesn’t end here. There are several other amazing features including ssh or others, which just can't be covered in a single post. You can learn more about it by reading articles, documentation or explore them on your own by using Linux in your daily life.

That's all for now, catch you guys in the next one 👋🏻.

Originally Published on my Personal Blog.

Top comments (37)

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Nice article, but when you jump into the commands section, you don't really mention that none of that is necessary to start using Linux, which maybe you should add because, even these days, people still shy away from linux because they think you have to do everything on the terminal.

Collapse
 
ishandeveloper profile image
Ishan Sharma

Appreciate the suggestions, man. That's a very valid point. But, I actually didn't mention anything like that, because I wanted this post to be more focused towards Developers, and most of them are comfortable with command line already.

Even if they're not, I felt that it would give them a mere motivation to actually see that using these commands are not hard at all and It gives one the sense of that immense power and how using these tools and basic commands can have a huge impact on their workflow.

Collapse
 
kailyons profile image
Loralighte

As a Linux user for 2 years, I am glad to say I left the Windows ecosystem. Now my use cases for my computer isn't the same for everyone else, but I can safely say my life has improved when switching to Linux. I actually cannot switch back to Windows 10, as there is a severe learning curve that is bigger than getting into Linux when I was a Windows 10 user. I appreciate this article, but some tidbits. First, amazing choice picking Ubuntu as the recommendation. 2nd, in CHMOD, when wanting to do quick changes to a file it is easily all you need to do is chmod +/-<permission_char> so to give something like my ever-so-lovely sass.sh file permissions to execute it is chmod +x sass.sh, and to remove said permission is chmod -x sass.sh. With updating and installing software, another tidbit, apt-get is being replaced for apt, which is the same game different name. Another tidbit, to copy directories, do cp -r origDirectory newDirectory! I have also learned with that same cp -r trick, you can do it to the directory you are in by doing cp -r . newDirectory, the dot is one of the most useful tools in Linux. Lastly, the tilda. Always remember the tilda (~) means your HOME directory. Meaning if you do rm ~/random-file for example, it will delete /home/thisuser/randomfile, will make life a heck of a lot easier.

Collapse
 
knav2013 profile image
knav2013

Does cp -r preserve directory timestamp or does it restamp with current date/time? Using GUI didn't preserve (was using Ubuntu 16.04.8 lxde desktop). Now I've started using tar to compress then extract with preserve timestamps switch

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️ • Edited

I just tried it out and no, apparently it doesn't.

EDIT: man cp and a quick search for timestamp reveals that when copy is called with the -p option, it should preserve timestamps. Not sure if this is a GNU thing though, but even busybox seems to support his flag.

Collapse
 
kailyons profile image
Loralighte

That is a question I do not know the answer to

Thread Thread
 
knav2013 profile image
knav2013 • Edited

A unix and linux forum had the answer (unix.stackexchange.com/questions/4...

cp -r --preserve=timestamps SOURCE DESTINATION

No need to tar compress then tar extract with preserve time stamp switch.

I tested the above 'cp -r --preserve=timestamps SOURCE DESTINATION' command and it works like a dream.

Thread Thread
 
pgronkievitz profile image
Patryk Gronkiewicz

You also can use rsync

Collapse
 
ishandeveloper profile image
Ishan Sharma • Edited

Thank you, man! Really appreciate your suggestions.

After reading your comment, I really felt that I hadn't done proper justice to the chmod command, and made it somewhat fearful for new users to try out. I have made a few changes to the post, regarding the same.

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Name checks out

Collapse
 
webreflection profile image
Andrea Giammarchi

I'm on ArchLinux, btw, and even there, I don't need to type commands all the time, only those needed to program something. GNOME, with its Adwaita Dark theme since 2014 or before, is pretty entry-level friendly, and with ArchLinux, you get always latest stable software ;-)

P.S. with Steam Play you can play pretty much everything that runs DX11 these days, including Townscaper, Journey, Quake Champions and many others, and if you're OK with Nvidia blob driver on Windows, you can use the blob driver on Linux too: it works well (but I prefer AMD mesa integration, which works even better).

Collapse
 
ishandeveloper profile image
Ishan Sharma

Thank you for taking the time to read this post and I really appreciate your feedback! 😄

Surely, you can easily do most of the things without ever coming across these commands at all. But I wanted this guide to be more developer focused. And as a developer, you can't achieve that same productivity in your workflow without at least some basic commands.

Collapse
 
webreflection profile image
Andrea Giammarchi

then you missed echo, cat, pipe operator |, environment variables DEBUG=true, and dare I say sed too, but I guess a follow up might come sooner or later 😉

Collapse
 
joeneville_ profile image
Joe Neville

A point that I don't think you address here is that, for many devs, their code will run on a linux server, so it is wise to develop using linux to avoid the old complaint of "it runs on my machine".
I think it is right that you jump right into the terminal commands. Even beginners should be trying to learn even a few of these commands, they are like shortcuts. If one can write code, I'm pretty sure they can learn 'mv' & 'cp'.

Collapse
 
ishandeveloper profile image
Ishan Sharma

Thanks a lot for valuable feedback! 😄 I Really appreciate it.

There are a lot of pros that I could've written in favour of Linux, but I wanted this to be more friendly towards Beginners.

Also, I think I did tried to give the readers a slight sense of the above point that you mentioned. I'll quote it

Using linux you'll be able to command such a huge variety of devices.

Collapse
 
sumukhesh profile image
Sumukhesh

Great read for beginners like me. Even I recently installed Ubuntu and started using bash cmd line for my dev work. Have to say , my work is smoother now.
Also you can try making a post on 'how to install linux' tutorial for beginners like me.
Cheers!!

Collapse
 
ishandeveloper profile image
Ishan Sharma

Thanks for the appreciation!

I'm glad you liked it! And will surely try to make a post on that in the future.

Collapse
 
amarok24 profile image
Jan Prazak

With the arrival of Google Android it should be clear to everyone why Richard Stallman always insisted on saying "GNU/Linux" operating system instead of simply Linux operating system. Android is so much different than GNU/Linux that I personally don't even think that Android is one of Linux OS distributions.

Collapse
 
rashil2000 profile image
Rashil Gandhi • Edited

Extremely well said!
Android, as it is today, is nothing but a disrespect to whatever principles Linux stands for, especially with the introduction of SafteyNet APIs etc. It's saddening that users have no real choice apart from Google's Android or Apple's iOS when it comes to mobile devices, unlike on PCs where they actually have the freedom to use/run whatever they want.
I really think people should start calling it Google Android instead of just Android. Some might argue that there are custom fully open source ROMS out there for Android devices, but as is clearly evident from Google's attitude towards them, it's becoming more and more difficult to run apps on them that require device and OS verification (examples - finance apps, security apps, banking apps, apps that use the Play Services API etc.).

Collapse
 
amarok24 profile image
Jan Prazak

Exactly. Users of Google Android are not owners of the system and that's a big problem (and vast majority of people is not capable of getting a free smartphone and installing a custom build on it, I've tried it and I failed). They can modify only what Google allows them to modify. This fact alone shows the huge difference between GA and GnuLinux. I don't even want to mention the huge amount of ads in most apps which are at the same time proprietary and not opensource.

Collapse
 
mehdico profile image
Mehdi Mousavi

Linux beginners don't need terminal commands!

Collapse
 
ishandeveloper profile image
Ishan Sharma

Surely, they don't, man. But, this guide is more focused towards Introduction for 'developers' and it is really necessary for a developer to learn at least a few of them for a productive workflow. 😃

Collapse
 
tdp4 profile image
tdp4

No, you usually don't,. And you don't need Ctrl-C or Ctrl-V in Windows, but you use it because its faster when you know it. Same with linux terminal.

Collapse
 
ishandeveloper profile image
Ishan Sharma

@tdp4 Couldn't have said it better than this myself. 😄

Collapse
 
bmw2621 profile image
Ben Winchester

Thanks for being a Linux advocate. I would update the apt paragraph to let readers know it only works in Debian based distros, not Fedora/Red Hat, CentOS (many companies use this for their servers), opens use, Arch based.

Collapse
 
randalvance profile image
Randal Vance Cunanan

I mainly use Linux to host applications and containers, but I am still unsure if I can switch from MacOS/Windows entirely to Linux as my main OS.

Maybe a good follow up article is "Linux for MacOS and Windows users" where you specify the each popular apps in MacOS/Windows and their corresponding replacement in Linux.

Collapse
 
maskedman99 profile image
Rohit Prasad • Edited

When someone says to you that they use linux, what they actually mean is that they use some distribution of Linux.

GNU/Linux :)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.