Skip to content
Step by Step Internet – Guides for learning to surf the Net

Linux shell What is it, what is it for, and how to use commands in it?

Linux has become the operating system commands, so it is very important to be able to know them in their vast majority, since this will greatly facilitate the work in such a system. This is how most of the users who are starting in this terminal usually have some inconveniences at the time of carry out various functions, but to try to solve this you can resort to command interpreters.

When you are starting to use this type of terminal, it is very important to have programs that simplify the user experience, since this is essential to be able to have a very good system management. This is how you can find the shell, a program that takes care of take the commands you type from your keyboard and give them to the OS so that it is in charge of executing them.

This type of tool has become a great help for all users who are starting your experience in Linux and not yet fully mastered these series of codes. Thus, Shells have various characteristics that end up making them unique, that is why here we are going to explain a little more about this tool, what it is for and how to use the commands in them, To do this, follow in detail everything that we will teach you in the post.

What is the Linux Shell and what is this console for?

Also known as command interpreter, this works in a similar way to a compiler, since it takes care of translate human code into machine code, so it can be considered as an interface that interacts with the operating system. In the same way this is a term used in computing, which consists of the interface of traditional users of Linux OSs or their distributions.

As it goes typing the commands in the shell, this program becomes the main responsible for interpret each of them and make them run correctly. So it can be said that it is a kind of tool that takes care of control the operation of the equipment. The commands that are contributed by the interpreters can be used as a script if they are written in executable files called Shell-scripts.

This allows the user that when he has to do use of multiple commands or command combinations with tools, can write on a text file he which will be marked as executable. In this way, line by line, the interpreter will translate to the kernel to run. It is worth mentioning that Shells are not strictly a programming language, to the process of create shell scripts it runs out calling Shell programming or Shell programming in English.

Categories of a SHELL How are these UNIX shells classified?

In this case you can find different types of shell, that is why here we are going to explain each one of them.

To do this, follow everything that we will explain below:

Interactive login shell

In this case the user is in charge of entering the orders in the equipment through the keyboard, this represents the main route by which the user enters or logs in to access the system.

Some examples of these are as follows:

  • Terminals SSH.
  • From a Graphic interface, open terminals are found with key combinations such as “Ctrl + Alt + function key (F1-F6)” or with the key combination “Ctrl + Alt + F7” so the graphical interface is restored.
  • Access to a Bash session with su – username.

No-login interactive shell

For this kind of Shell the user is in charge of entering the orders in the terminal through the keyboard, but actually, it is that a terminal emulator that starts from a graphical environment after user login in the system.

Some example of this is the following:

  • Gnome-terminal, konsole, etc.

Non-interactive and no-login shell

In this case there is no interaction with the user, so that it is not interactive, quite the opposite of the two mentioned above. There is also no login. In this case it is basically the use of scripts, for these cases Bash does not read any boot files.

An example of this would be the following:

  • Scripts to run tasks with cron.

Bash

Bash

Bash it is one of the Shell most recognized by Linux users, so most of operating system distributions usually have Bash as default shell, which is why it is one of the best options for when users are taking their first steps on these machines. Being one of the most popular, certain advantages can be found, and it is that it is surrounded by a great community, so you can find great information about it.

To make use of Bash, the user should associate very well with the TAB key, of Tabulation, which will be the main ally for this. In the same way, it should be mentioned that this tool is essential when having to write long file paths, since Bash incorporates an autocomplete function, this allows that when writing the first letters of the destination and pressing the TAB key completes the rest with what you are looking for.

Zsh

Zsh

This is another Shell, it is considered one of the most powerful for the OS, and which is the main option for replace bash. It is worth mentioning that both Bash and Zsh are supported, so lscripts work correctly for both tools. It also offers an autocomplete that has no complaints whatsoever about it.

In the case of using autocompletion, the user must simply type the first letter and you can automatically see the different options associated with what you want to search for and only those that begin with the letter or letters you have entered will appear as a result. Another great look to highlight from Zsh, is at the time of select a command argument that you want to use, since it will offer very good alternatives and an ease of selection.

Fish

Fish

To end the types of Shell available, we introduce you Fish, considered as the most intuitive of all, count with one syntax coloring what will tell you if the command you have added is correct or not. In the case that you enter the order of a command and it is not installed then it will notify you of it and it will show you the option to install it.

Like the two mentioned above it also has a autocomplete very similar to Zsh, but this time it includes the option to show the history of previously used commands, as if it were a shadow in our text. The only negative part in this case is that it does not support Bash.

List of the most useful commands you should know to use in the Linux console

If you are a new linux user and you still don’t know what commands you can start using for get the most out of your Linux console and take your first steps in it, so here we are going to show you one list with the most useful commands that are necessary to know.

To do this, follow the list that we will show you below:

Pwd

This command is called Personal Working Directory and is in charge of teaching you the directory path where are you currently located.

Let’s see:

  • $ 1 pwd
  • two/ home / Alejandro / EDteam

Mkdir

It’s called Make Directory and with it you have the opportunity to create new folders with the name you specify:

  • Mkdir (folder_name)
  • $ 1 mkdir_my_folder.

Touch

This command allows you create new files in current directory.

For this you must apply the following:

  • $ 1 touch_my_file.txt
  • $ 2 ls
  • txt.

Mv

Known as Move, and its function is move files or directories from one location to another, in this case its syntax is the following: mv {location / _current} {new / _location}

Let’s see:

  • $ 1 mv my_file.txt ./my_folder/my_file.txt

You also have the option of rename folders and files through this same command, where the syntax is as follows: mv {name /_current} {name /_new}.

As we indicate below:

  • $ 1 mv my_file.txt users.txt
  • $ 2 mv my_courses folder.

Cp

Known as the Copy command, and its main function is copy directories or files from one place to another.

In this case its syntax is the following: cp {origin} {destination}:

  • $ 1 cp users.txt copy_user.txt

In the case that you want to copy directories then you must add –r, being as follows:

  • $ 1 cp –r courses / copy_courses /

Rm and rmdir

Called as Remove command and as its name indicates, its objective is delete files. Its syntax is as follows: rm {name / _of / _file}. Now in the case of rmdir command, what does it mean remove directories, has as function delete folders that are empty.

For this we have the following syntax: rmdir {name / _folder}:

  • $ 1 rmdir empty_folders /

If they love each other remove non-empty directories it will be necessary to use the rm command with the –r option.

Remaining as follows:

  • $ 1 rm –r copy_courses /

Find

Using the Find command and –iname option, you will have the opportunity to find files.

For this command this syntax is used: find {where / _search} –iname {file / _a / _search}:

  • $ 1 find. –Iname “users.txt”
  • /courses / users.txt

Cat

In this case the cat command gives you the possibility to read the content of files:

  • $ 1 cat notes.txt
  • two
  • 3 these are the course notes
  • 4 end of course notes

You can display the lines of the file by applying the –n option:

  • $ 1 cat –n notes.txt
  • two
  • 3 1 these are the course notes
  • 4 2 end of course notes.

Ls

LS allows you to delete or remove files and directories from the current folder:

  • $ 1 ls
  • txt
  • 3my_folder

To show hidden content then you must use flag –a:

  • $ 1 ls –a
  • I am_a_hidden_file
  • txt
  • 4my_folder

If you want to list the detailed content you must use the -1 flag:

  • $ 1 ls -1
  • 2-rw-rw-r — 1 alejandro Alejandro 0 Oct 22 16:46 my_file.txt
  • 3drwxrwxr-x 2 Alejandro Alejandro 4096 Oct 22 16:42 my_folder

CD

Also know as Change Directory and allows you move between system directories. It uses the following path: cd {path / _absoluta / _o / _relativa} You have the opportunity to modify the directory by specifying the absolute path from the root directory or relative from your current location. In the case of Linux the current directory should be indicated using this sign (.) According to this, we leave you the following commands that perform the same action to move to the directory: my folder

Let’s see:

  • $ 1 pwd
  • two/ home / Alejandro / EDteam
  • 3
  • $ 4 cd / home / Alejandro / EDteam / my_folder
  • $ 5 cd ./my_folder
  • $ 6 cd my_folder

In order to return to the previous directory use the following command cd -:

  • $ 1 pwd
  • two/ home / Alejandro / EDteam / my_folder
  • 3
  • $ 4 cd –
  • 5
  • $ 6 pwd
  • 7/ home / Alejandro / EDteam

To move from a directory above your current location, you will need to use the cd command. . or a sequence of. . this will allow you to go up the directory structure.

An example of this can be: to go to the home folder from the current EDteam location the following should be used:

  • $ 1 pwd
  • two/ man / Alejandro / EDteam
  • $ 3 cd. . /. .
  • $ 4 pwd
  • 5/home