Introduction To The Linux And Terminal Commands.

Introduction To The Linux  And Terminal Commands.

What is Linux, Terminal Emulator and Shell?

Linux is the open-source operating system which works on the kernel. Kernel is sort of like a bridge between the application and the operating System .

Basically, the terminal emulator is a software application that let us use terminal in graphical way.

In simple word, Shell is the command line interpreter that takes our input (the command that we write ) and tells the operating system what to do.

What is an environmental variable?

An environment variable is a user-definable value that can affect the way running processes will behave on a computer.

When we run the command like :(Make sure git must be downloaded first )

git

The output would be like this:

Now, the question is how the operating system knows that how to execute the given command, which comes into picture PATH VARIABLE.

This command is to see all path variables.

echo $PATH

When you write the git command, the computer checks all path variables and it would execute whenever it hits the respective path.

How to set your own environmental variable?

export my_variable="Something"
#Then run  below command 
echo my_variable

But this variable is temporary it would gone when you close your terminal.

List of Linux and some networking commands

mkdir( make directory)

This command is used to create the folder or directory

mkdir directory_name

cd(change directory)

if you want to switch the directory you can use this cd command

directory_name means to which directory you wanna switch

cd directory_name

pwd(present working directory)

this command shows your current directory

pwd

touch

this command helps to create the file.

if we run the below command it will create the linux.txt file

touch linux.txt

vi(vim editor)

if you want to add the content in the above linux.txt file then you can use the vi command

vi linux.txt

When you run the above command it will show the interface:

Now press the " i " key in order to insert your content. Press esc key you would refer to the initial mode press the Shift+semicolon button and then press x then Enter button you will exit from the editor.

for more commands related to the Vim editor:

Open link

cat

After adding content in the linux.txt file if you wanna see what content i have added in that particular file then you can use cat command

cat linux.txt

ls(list)

This command lists all contents within that directory

ls shows all the files and folders

ls -a shows all the hidden file

ls -al shows more information regarding the permission

ls -R gives a recursive listing, including the contents of all subdirectories and their subdirectories.

ls
ls -a
ls -al
ls -R

man

if you want to know more about any command then you can definitely check this command.

man command_name

Example: man tr, man mv, man ls e.t.c

tr(translate)

This command is used for translation purposes.

if you want to convert the contents of any file into upper-case then use the below command

cat  linux.txt | tr a-z A-z

" | " This symbol acts as the pipeline and the output of the left part is the input for the right part

mv(move)

This command is pretty cool it is used to move your files and directories

mv linux.txt demo

After running the above command linux.txt will move to the demo directory or folder (make sure the demo directory should exist).

You can also rename the file using the mv command

mv linux.txt linux.txt_1

linux.txt is renamed to linux.txt_1

you can also move and rename the file simultaneously

mv linux.txt demo/linux.txt_1

So, linux.txt file is moved to the demo directory and renamed to linux.txt_1

cp(copy)

This command helps to copy all the content of one file to another file

cp linux.txt linux.txt_1

All the content present in linux.txt will copy to linux.txt_1

rm(remove)

rm help to remove the file

rm -r help to remove the directory

rm linux.txt

It removes the linux.txt file

rm -r demo

It removes the demo directory.

df

This command displays the free disk space of your system.

df

df -h command display a free disk in a human-readable format .

find

This command is used to find all the stuff (file , folder and even hidden file) in our respective directory.

" . " mean present working directory

" .. " mean the previous directory

find .
find ..

you can also find only file stuff in pwd then you can use the below command

find . -type f

if you wanna see only directory stuff in pwd use the below command

find . -type d

If you find all the file that ends with .txt then use the below command

find . -type f -name "*.txt"

curl

This command is used to exchange the data to or from a server using respective protocols.

you can see the IP address of your ISP ( internet service provider ) using the below command.

curl ifconfig.me -s

sudo

sudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy. It is used at the beginning of any administrative work.

for example: if you want to switch to the root user you can use sudo

sudo su -

chmod

This command is used to change the file permission

There are 3 groups each having 3 letters.

  1. The leftmost three characters show the permissions for the user who owns the file(file permission)

  2. The middle three characters show the permissions for members of the file’s

  3. groups( group's permission)

  4. The last three characters show the permissions for anyone not in the first two categories (others' permission)

The letters represent:

  1. r: Read permissions. The file can be opened, and its content viewed.

  2. w: Write permissions. The file can be edited, modified, and deleted.

  3. x: Execute permissions. If the file is a script or a program, it can be run (executed

For example: chmod 777 anish.txt means to read, write and execute permission is given to all the 3 groups. 7 = ( 4 + 2 + 1) = ( read + write + excute ) . By default, every file we created has 777 permission.

Now, Change the permission of the anish.txt file to 555. It means 5 = ( 4 + 0 + 1 ) = ( read + no permission + execute) .so we have read and execute for all three groups.

grep(global regular expression print)

This command is used to search for something inside the file.

i created the anish.txt file and added some random name

If you want to search the whole word then you have to put the -w parameter in the grep command.

nslookup

if you want to check the IP addresses of a particular domain then you can use this command.

nslookup google.com

wget

This command helps to download something from the internet.

wget respective_url