Linux Tutorial For Beginners- Part I

Why should you learn Linux?

Linux is an awesome OS to work with. It is very malleable and it is really really fun to work with linux OS. Am not going to elaborate on this. Just read the article published by redhat and You will understand why you should learn Linux.

Read: why should you learn linux

Choosing a distro:

When you start learning about linux , Redhat, Ubuntu, centos , Fedora, suse and mint are names that would be going through your brain. But believe me, there are nearly six hundred different distros of linux. I suggest you to start with Centos ( a derivative of Redhat enterprise linux) and Ubuntu ( a debian based distro). Choosing a distro is of your choice. For more  info on choosing a distro , read this

In this tutorial I will be explaining the important things to do when you start learning the Linux command line. I started learning linu from udemy course. If you are new to linux and you want a good grip on linux, you can subscribe for the online course. It is a really good course for linux foundation.

Course link: Linux tutorials by linux academy

Getting started:

Shell: To run command in Linux we use a command line interpreter called shell. You can virtually do any Linux based operations using the shell.

You can open a shell terminal using the GUI options in your distro or you can user Ctrl + Alt + T shortcut keys to open the terminal.

Also read: Linux shell scripting beginner tutorial

Viewing OS information:

cat command is used to view the contents of a file. The information about the CPU and OS are present inside files under the /etc folder.

1. Command to view the cpu information

cat /proc/cpuinfo

2. Commad to find the OS details

cat /etc/*release*
Adding users and Passwrods:

1. Open the terminal and issue the following command to execute commands as root.

sudo su

2. To Create an user , lets say scriptuser , execute the following command in the terminal

useradd -s /bin/bash -m -d /home/scriptuser -g root scriptuser

the above command creates a user “scriptuser”, create the home directory for the user.
3. Add password for the user.

Passwd scriptuser

4. Only the root user will have all the privileges to execute and modify all the files in the server. Inorder for the user to have certain privileges to executes commands and install softwares, it should have some root privileges. To provide the user root privileges , you should add the user to ther sudoers list. Sudoers file will be present inside the /etc folder. location: /etc/sudoers. Use any one of the foloowing commands to open the sudoers file.

vi /etc/sudoers   (or)

vi is the editor for linux. There are other ediotors like nano.
5. Add the following line to the sudoers file.

scriptuser     ALL=(ALL:ALL) ALL

scriptuser is the username and ALL=(ALL:ALL) ALL will give the user  certain root privileges. After adding this line , press Esc key , w and q to save the edited file. Now you will be able to execute commands using root privileges by using sudo before the command.

Working with directories (folders)and files:

1. Create a directory using the following command

mkdir directory_name

2. Remove a directory

rmdir directory_name

3. You can browse through the directories using cd (current directory) command

cd /dir1/dir2

4. You can find the current working directory using the following command.


vi is the commonly used and a very powerful text editor.

1. Open a file

vi filename

2. Save a file by pressing the following keys consequently.

esc + w +q

3. Exit the file without saving

esc + q

4. Search for a particular word in a file

/keyword + enter

5. Delete a particular line
<pre>use dd by placing the cursor in the line which you want to delete the file.</pre>
6. Undo the action by pressing u
7. Copy and paste and particular line

yy to copy and
p for paste

To create a file you can either use the editor or touch command.

1. If you create a file using touch command, the file size will be zero.

touch filename

2. Creating a file using vi.

vi file name

3. Deleting a file

rm filename

4. Force deleting

rm –f filename

5. To delete all the files in a folder , cd in to the directory and issue the following command.

rm –rf  *

r stands for recursive and f stands for force, * denotes all.
6. To delete a folder with files.

rm –rf foldername

7. Create a hidden file by appending a . operator before the file name.

mkdir .dirname
touch .filename
Listing Files and folders:

1. You can list all the files and folders using the ls command.


2. Use the following command to list all the hidden folders

ls –a

3. List all the files with particular extension.

ls *.png
ls *.sh

4. List all the files with their starting with a

ls a*

5. List all the files starting with letter a to d from a particular folder

ls /folder-name/[a-d]*

kindly share this article and leave a comment for queries.

Other Interesting Blogs

Leave a Comment

Share via
Copy link
Powered by Social Snap