If you’re new to the Linux Command Line, you might be a little intimidated. Coming from the comfort of windows or Mac, the Linux Command Line looks nothing like what you normally use. Not to worry here, I have made a list of 15 basic Linux commands with examples and syntax.
These commands are used in order to navigate within the terminal or throughout the file system. Here you will learn how you can change the ownership of the file, how to copy things and move things and some of the other basic commands.
List of 15 Basic Linux Commands with Examples and Syntax
The change directory command is used to go to a directory. For example, if you are in the root folder, and you want to go to the Documents directory, then you can type in“cd Documents”.If you want to go to a folder which is in Documents. For example, you have a directory inside Documents named “basic commands”.
So what if you want to go back to the Documents directory. Then you just have to type “cd ..” and to go back directly from the music directory to root directory use “cd”.
The print working directory command will show you the current working directory, It gives you the absolute path, which means the path that starts from the root Directory.
The list command is used to show all of the directories filed under a given file system.
You can also see the hidden files or directories by using “ls -a” and “ls -l” it will show you the complete description of the file/directory. This command will show you the permission, size, ownership and it will show you at what time and date the file/folder was created.
The move command enables the users to move a file or directory to a specified location.
Here we have moved InstaBrute Directory to trape.
The make directory command allows you to create new directories. For example, if you want to create a new directory named “commands”. Then you have to type “mkdir ab”.
rmdir stands for remove directory. this command is used to delete an empty directory. If you want to delete a directory containing file use “rm”.
The touch command is used to create a file. It can be an empty text(txt) file or an empty zip file.
The change Mode command is used to change the permissions of the file/directory. Before I show you an example of “chmod”, you need to know something about the permissions of a file. Basically, permissions are divided into there main categories which are the admin, group and public.
For example, we have a text file with permissions “-rw-r–r-“. So the admin has the permission to read and write, the group has read-only permission and the public also has read-only permission. chmod is quite an advanced command to use. So, therefore, you really need to understand how it works. chmod works with so-called permission bits. These bits can be set to a certain level of restrictions.
so, we have the following bits available.
“x” ( execute)=1
Add all these numbers “1+4+2=7”, So “7” is used to read, write and execute. If you want to change the permission to “-rwxrw-r–“. Then “rwx”(1+4+2=7) this will be for admin, “rw”(4+2=6) for the group and “r”(4) for the public. The command will be
“chmod 764 (file/directory name)”
If you want to give read, write and execute permissions to all the categories,
Then “chmod 777(file/directory name)”
The man command shows the “manual” of the command. In some situations, you might need to get more information about the command you are using. The man command shows all the information you need to know about that command.
Use the help command to know more about the command you are using.
The hostname command is used to know your name in your host or network.
The cat command is used to display the contents of the file.
nano is a text editor which is already installed in the Linux command line. It is used to edit text files.
The cp command is used to copy files through the command line. It takes two arguments: The first is the location of the file to be copied, the second is where to copy.
Use ping to check your connection to a server.
use “ctrl + c” to exit ping
Basic Linux commands with examples and syntax
Tips and Tricks for using the Linux command line.
- you can use up and down arrow keys to use the last commands.
- use TAB to fill up in the terminal. For example, you just need to type “cd Des” then hit the tab button and the terminal will fill the rest up and make it “cd Desktop/”
- use “ctrl+c “to stop any command in terminal safely and use “ctrl+z” for force stop.