The definitive guide to learning how to use the Linux terminal

Posted by Md Khann on March 5th, 2020

  Fear, what leads Windows users to run away from everything related to Linux, due to its extreme CLI-phobia (fear of the Command Line Interface or command-line interface).

That fear ends today. I bring you everything you need to make that dreaded terminal become one of your most useful tools. The most practical and used commands and keyboard shortcuts with which you will almost prefer the Command-Line to the graphical interface (so annoying sometimes ...).

Every time I have done some repair on a computer that already had almost a decade behind them, they asked me the same question: “ What can I do to make it go faster? " My answer is always to try some Linux distribution. In addition, I always respond in the same way: “If you want I can prepare a USB for you to work from it, try Linux and if it does not work, you can continue using your usual Windows, since this method is not intrusive at all with the system from the hard drive. ”

Well, not even with so many facilities, they even agree to try Linux. Few are those who directly tell me no, that they have heard from people who have had many problems when working with Linux. In most cases, they try to reason to me that they are users with little experience and do not know how to work with commands, that that sounds like the terminal but of the airports, that if they are going to delete something unintentionally with the commands ... And as you see the denominator Common is the command line or terminal.

In order to open the eyes to users who say that the terminal is difficult to handle, that there are thousands and thousands of commands that they will have to remember, and to refer to this publication anyone who dares to put me as an excuse The complex use of the terminal, I leave here today a list with the most used commands and the most useful keyboard shortcuts when working with this interface, the Linux terminal. Linux training in Bangladesh

Browsing the directories:

PWD: “Print working directory” (Show the working directory), it will show us the path we are currently in. Very useful if we have been jumping from subfolder to subfolder and the prompt shows us only a short route. ls: It shows us a list with the contents of the current directory (or the one we pass as an argument, for example: “ls/home / user”).

ls –l: Shows a list of the contents of the directory adding additional information of the files or folders, such as permissions, date and time of creation or modification, etc ...

ls –a: Shows a list of all files in the directory, including hidden files or folders.

cd: takes us to the root directory.

cd ..: We will go up one level in the directory tree. If for example, we are in / home/user, with this command we will go to / home.

Examining files:

file: determines the type of a file.

cat: show the contents of a file

less: it shows the contents of a file, and it goes on the page if necessary because it is very extensive.

Manipulating files and directories:

cp: Copy a file or directory.

cp –i: Copy a file or directory and ask before overwriting if necessary.

cp –r: Copy a directory with all its content.

mv: Move or rename a file or directory. In the Linux terminal, instead of renaming a file through an exclusive command, we use the same as to move files or directories, and what we do to rename it is to move it to the same path where it is located and rename it.

mv –i: Moves or renames a file or directory asking before overwriting if this happens.

mkdir: Create a directory.

rmdir: Deletes an empty directory.

rm: Delete a file.

rm –r: Deletes a directory and all it's content.

rm –i: Deletes a file requesting confirmation. It is highly recommended to use it with the –r option to be able to use it with directories avoiding problems.

Keyboard shortcuts:

Ctrl + Alt + Fn (1-6): To open terminals in full screen. Requires authentication with username and password. We will change to the terminal corresponding to the Fn key that we press, corresponding to the order in which we open them. In Linux we can have multiple terminals working simultaneously, by default we will control up to 6 with this key combination. For example, Ctrl + Alt + F1 takes us to the first open terminal.

tty: With this command, in the case of having several terminals open, it will tell us which one we are in.

Ctrl + Alt + F7: It will return us to the graphical environment (if we used any).

Shift (Mayu) + Page Up: We will scroll up in the terminal.

Shift (Mayu) + Page Down: We will scroll down in the terminal.

Tab (Tab): It will complete the command, file name or directory that we are writing. In case of multiple coincidences, with a double press of this key, we will obtain all the possible results found in the directory or system. Direction arrow 'up' and/or 'down': We will move through the history composed of the last commands used.

Ctrl + r: It will search the history for the last command used according to what we are typing. For example, we used the clear command a few hours ago, if we press Ctrl + r and type cl it will show us the clear command since it has searched the history and is the most recent one that matches.

Ctrl + c: It interrupts any running process immediately and returns us to the prompt.

Ctrl + z: Send the current process to the background. To recover it we will only have to type FG and press Enter.

Ctrl + d: Close the session of the terminal in which we are. If we are using a graphical interface in which we have opened a terminal, it will only close.

Ctrl + w: Deletes the word before the cursor position.

Ctrl + k: Cut everything that is between the cursor situation and the end of the line.

Ctrl + u: Cut the line where we are complete.

Ctrl + y: Paste the copied or cut content with Ctrl + u or Ctrl + k.

!!: Repeat the last command used.

System Information Commands:

date: Shows the complete date and time.

cal: Shows the calendar of the current month.

whoami: Shows the name of the user we are working with.

w: Shows which users are currently connected.

uptime: Shows how long the system has been on, and how many users have used it.

name –a: Provides system Kernel information.

cat / proc / cpuinfo: Display Microprocessor information

cat / proc / meminfo: Displays information from the device memory.

free: Shows the amount of total, used and free memory, as well as the space in the exchange unit.

Administration Commands:

adduser xxxxxx: Where we will replace the x with the name of the user we want to add.

passwd xxxxxxx: Where xxxxxxx will be the name of the user to whom we want to change the password. We will need to know the password already set if we want to change it.

su: Log in as superuser or root from the current session.

exit: Logs off the superuser or root session, returning to the user from which it was started.

Process Commands:

ps: Shows the processes that are currently active in the system.

top: Shows all processes in operation.

kill "PID" (process id): Stops the process assigned to the PID that shows the output of the ps command. bg: Shows all paused or background processes (remember that Ctrl + z established background processes).

FG: Brings back the most recent background process.

Update Commands:

apt-get update: Update the repositories to add new sources that will install the most recent versions of the programs that we indicate. apt-get upgrade: It will update the applications that the 'apt-get update' command has updated if there are more recent versions. pt-get install xxxxx: Where xxxxx will be the package corresponding to the program we want to install. For example, 'apt-get install LibreOffice'.

dpkg –i xxxx.deb: Package installer for deb package managers.

yum, install xxxxxx: Package installer for rpm package managers.

rpm –i xxxxxx.rpm: Package installer for rpm package managers.

Start and shutdown commands:

halt: Stop all processes and turn off the equipment.

shutdown: Schedule system shutdown in 1 minute.

shutdown –r X: Program the system reboot, where X will be the number of minutes in which the device will restart.

shutdown –h now: Turn off the computer by skipping the scheduled wait minute.

shutdown –r now: Restarts the computer by skipping the scheduled wait.

reboot: Restarts the system in the same way as the previous command.

init 0: Turn off the system.

init 6: Restart the system.

start: Starts the graphical interface if it is installed in the system.

Network Commands:

ifconfig: List the IP addresses of all devices on the computer.

ping xxxx: Send a signal that must be returned by the xxxx device to check if it is online or not.

whois xxxxx: Get information about a xxxxx domain, such as www.google.com

wget xxxx: It will download the xxxx file. We must provide you with a complete address such as 

Commands Commands:

man xxxxx: Displays the user manual or configuration program xxxxx.

man –k xxxxx: Shows the manual pages that contain the word xxxxx.

apropos xxxxx: List the manual pages that deal with the xxxxx command.

where is xxxxx: Shows the most likely location for the xxxxxx program.

I hope this information has been useful to you, remember to be aware of Openwebinars courses, because, with this knowledge plus those that you can acquire in the preparation courses for obtaining the LPIC certification, you will get to certify your skills with Linux operating systems, a degree increasingly valued.

Like it? Share it!


Md Khann

About the Author

Md Khann
Joined: August 27th, 2019
Articles Posted: 67

More by this author