Sunday, March 8, 2020

Introduction to Linux and some basic commands for first time users


Linux is one of the most used operating systems among computer geeks and hackers making it not only special but also a playground full of tools since the ones that use it are mainly advanced users who also code applications. To be correct Linux is a kernel, but I am not going to jump on that topic right now, not in here.
There are many flavors based on Linux giving so almost everyone the right operating system for the job. For example many code writers use Ubuntu as their main development machine because it comes with the right tools for programming, making it easy to setup a development environment in a couple of minutes. This is not the only reason why many developers use Ubuntu. A great community stands behind this Linux distribution offering help for everyone in need. For example If you wake up angry of your old operating system one day and decide to use this distribution the perfect place to ask for help is askubuntu.com. It is really great how fast they will reply to help the one in need with an answer.

Different Linux distributions target different user groups

As I mentioned earlier in the introduction of this post there is a Linux distribution for almost everyone unless you are some crazy alien with mad computer skills. But, I doubt that. Why are you reading my article then?

If you are still in high school or some type of teacher then I invite you to give a try to the great education Linux flavor called Edubuntu. The main focus of this operating system is to provide the right tools for the education system giving every student the opportunity to practise theory on their computers no matter how much money they have. It does not cost anything to install this Linux distribution on your machine.

Or do you have a computer somewhere in the dust that does not load any operating system? I believe the solution to your problem is Puppy Linux which is a Linux distribution with the main focus on restoring old hardware. It gives great speed to your machine saving lots of time to your life. Give it a try if it happens that you have an old machine in your basement. You will be amazed by the speed of this Linux built.

I see many people who are interested in computer security field and they start from Windows as their main operating system for their lab. To be honest there are many Linux builds full of security tools such as KaliBackbox etc. Windows should be in your lab, but just as a target not the main machine. I don't want to be a Windows hater in here, but many experts in the security field share the same opinion.

Not only has Linux happened to be successful for programming and security, but it is also trying to make its own place in multimedia. Now to be honest in here I never used Linux for video editing or audio work, but there are many people who have done and do that. Linux distributions such as Ubuntu Studio target multimedia geeks as well as professionals so feel free to give it a try.

Enough theory, try these commands

If you have a Linux box around you probably know about the Terminal so fire that up because you will need to follow me with some basic commands. We will need these commands in the near future as they will help us to make the work easier. 

It will be a shot in the water to continue learning and using Linux without these simple commands every beginner should master

Now before continuing with each command it is needed on my part to make it clear to you guys how all this command thing works. I am not going to hack the entire thing for you as you are not that advanced yet, but I will try to make the view as clear as possible.

When you make some software operations it is for sure that you make use of the machine's hardware, but the thing is that the software does not directly interact with the hardware. The kernel is the one that is responsible for communicating with the hardware.


Not only the kernel `talks` to hardware, but it also talks to the shell. The shell takes input from the user such as commands for playing music for example and translates this command into some language which the kernel can understand.

It is obvious for the commands to be typed in the Terminal, then a shell is needed to interpret them. Without the shell the commands do not make sense to the machine.
There are many different shells such as the followings:

  • Bourn Shell (sh)
  • Korn Shell   (ksh)
  • C Shell (csh)
  • TC Shell (tcsh)

Because Ubuntu makes use of the Bash Shell known as Bourn Again Shell and I have not been curious to experiment with the other shells, my experience is limited to that.

The following is a screenshot of my terminal which is configured by default to make use of the Bash Shell.


To print out the type of the shell your machine is using type the following command on your Terminal.
echo $SHELL
The output of the above command on my part is shown below.

/bin/bash
I bet you know what the result of the command I ran on my system means. If you don't then I have the obligation to explain it to you: The Bash Shell shell is used on my machine. Simple as that!

Believe it or not if you have followed me carefully you know how to run a command on your Linux machine. To list files inside a directory the ls command is used. It is self explanatory.
ls
I have a file called requirements.txt in the directory I made use of the ls command so the following output is printed out on my console.
requirements.txt
If you like to print the name of the current working directory then make use of the following command.
pwd
And since I am working on my lab the following is printed out.
/home/lostbird/lab
And if you want to remove a file the following command is used.
rm file
Or if you wish to remove the entire directory structure with everything in it the following command will do the job.
rm -r /home/lostbird/lab #this is the directory i want to remove
To create a new directory use the following command.
mkdir newdirectory #newdirectory is the new directory you want to create
If you come from a windows background you probably know that the equivalent command on windows for creating a new directory is the md command. What kind of command should you use when you like to change the name of the directory?
mv newdirectory oldirectory
And if you like to know the type of a specific file use the command file.
file requirements.txt
The above command gives me the following result.
requirements.txt: ASCII text
The above output tells me information on the type of file which in this example is an ASCII file and it can also be viewed as text. An important command that we will use a lot is the cd command which helps the Linux user to navigate through directories.
cd /home/lostbird/Desktop #the path of the directory where you want to go
And the last one but not least is the cp command which can be used to copy files.
cp requirements.txt /home/lostbird/Desktop #copies requirements.txt on Desktop

Combining Linux commands together

Not only you can use single commands to perform different tasks, but you can also combine different Linux utilities together to perform more complex operations or invent new and better ways of doing stuff.

Maybe you have thought about feeding the output of one command as the standard input of another one. This is called piping.

The following creates a pipe for example.
ls | grep requirements.txt
We list the files in the current working directory and feed the output to the grep command which is being used to grep lines of text witch match a regular expression. The following is the output of the above command when executed on my machine.
requirements.txt
This pipe is really useful when the output of the ls command is really long and you want to find if a file does exist in a specific directory. A pipe I really love to use is the one shown below.
ls -l | less
The above pipe is really useful when the output is really long and you want to scroll through it.

Conclusion

You don't have to go really deep with commands to learn about Linux, but for sure you need some solid knowledge especially when it comes to the command line.

I am really sure that the knowledge we went on through this tutorial is enough to get you started with Linux machines.

Make sure to follow our linux page for more wisdom on open source technologies.

0 comments:

Post a Comment