Basic Linux Commands

Linux's users, in comparison to Windows' users, should know that using this operative system will lead, sooner or later, to the use of a Terminal. Maybe because you're reading a tutorial on the internet, or because you are trying to learn how to use it, you will need to type some commands on the command line some day. Here, I will make a list of the most basic commands that I use on a daily basis, and I believe everyone should know about.

GNU-Linux Image
Source


Current working directory - pwd

This simple command will show us the full path (also know as absolute path) of the current working directory.


Change directory - cd

This command will allow us to move through all the directories in our computer. In order to use it, we need to provide the name of the directory or the route we want to be placed in. If we don't specify a route, the command will move us to our home directory by default: ~ or /home/<user_name>.

cd use
If the use pwd we can see as we move through the directories

Moving to the parent directory - cd ..

If we want to move to the parent directory (that is, one folder above), we can use cd ... Every folder in our system has two special directories: . which refers to the current directory, and .. which refers to the parent directory, so we won't need to memorize the full path if we want to talk about the current folder, or the parent folder.

cd ..
Here we can see the use of both . and ..


List all the files and folders in the current directory - ls

With ls we can obtain a list of all the files and directories that are located in the current directory.

Also, we can add some options to this command, so it can be more useful:

Show the result in a list - ls -l

Show all the files, even the hidden files - ls -a


In Linux, the hidden files and directories start with a dot in their name

Combining the options - ls -la



Preview the content of a file - more

If we provide to more a filename (or a route to a file) we can see a preview of the content of such file.

If the content of the file is very large, we will see only a chunk of the content, and we can see the remaining part by hitting the Enter key. If we don't want to see the preview anymore, we can exit the preview with the key q.


Clear the screen - Crtl + l

Actually this is not a command, but this combination of keys is very useful too. As we use the Terminal, we will see how the screen is filled with more and more lines that maybe, we won't need anymore. Sometimes, these lines might be confusing or annoying. By hitting Crtl+l, the screen will scroll up automatically, so we will get a clear one. We still can access the old lines by scrolling up the window in case we need them again.


Before


After


Reset the Terminal - reset

This command works just like Crtl+l, with the only difference that we won't have access to the old lines. When we type reset, all the information will be cleared and the Terminal will be just as we have opened it for the first time.


Copy a file - cp

This command receive two arguments: the first one if the file we want to copy, and the second one is the directory where we want to copy the file. If in the second argument we specify a name different to the original, the file will be copied with this name we typed.

If we want to copy a folder, then we need to add the option -r to the command: cp -r.


Delete a file - rm

There is not much to say about this command. We specify the name of the file we want to delete, and it will do its work.

If we want to delete a folder instead, we need to use the option -r: rm -r foldername.


Do you use Linux? Which commands would you add to this list?

If you have a question, leave it in the comments section

If you liked this post, don't forget to Upvote, Resteem it and follow for more content

All the screenshots were taken by me

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center