Basic Linux Commands for Beginners With Examples and Syntax

5
240

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

1. cd- 

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”.basic linux commands with examples and syntaxIf you want to go to a folder which is in Documents. For example, you have a directory inside Documents named “basic commands”.

basic linux commands with examples and syntax

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”.

basic linux commands with examples and syntax

2. pwd-

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.

basic linux commands with examples and syntax

3. ls-

The list command is used to show all of the directories filed under a given file system.

basic linux commands with examples and syntax

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.

basic linux commands with examples and syntax

4. mv-

The move command enables the users to move a file or directory to a specified location.

basic linux commands with examples and syntax

Here we have moved InstaBrute Directory to trape.

5. mkdir- 

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”.

basic linux commands with examples and syntax

6. rmdir-

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”.

basic linux commands with examples and syntax

7. touch-

The touch command is used to create a file. It can be an empty text(txt) file or an empty zip file.

basic linux commands with examples and syntax

 

8. chmod-   

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

“r”(read)=4

“w”(write)=2

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)”

basic linux commands with examples and syntax

If you want to give read, write and execute permissions to all the categories,

Then “chmod 777(file/directory name)”

basic linux commands with examples and syntax

 

9. man-

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.

man- basic linux commands with examples and syntax

10. –help-

Use the help command to know more about the command you are using.

basic linux commands with examples and syntax

11. hostname-

The hostname command is used to know your name in your host or network. basic linux commands with examples and syntax

12. cat- 

The cat command is used to display the contents of the file.

basic linux commands with examples and syntax

13. nano- 

 nano is a text editor which is already installed in the Linux command line. It is used to edit text files.

basic linux commands with examples and syntax

14. cp-  

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.

basic linux commands with examples and syntax

15. ping-

Use ping to check your connection to a server.

basic linux commands with examples and syntax

use “ctrl + c” to exit ping

Basic Linux commands with examples and syntax

See Also: THE BEST SCREEN RECORDING SOFTWARE FOR WINDOWS(Free & Paid)

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.

 

 

5 COMMENTS

  1. Everything is very open with a clear description of the challenges. It was really informative. Your site is extremely helpful. Thank you for sharing!

  2. each time i used to read smaller articles which also clear their motive, and that is also happening with this paragraph which I am reading at this time.|

  3. Hey there would you mind sharing which blog platform you’re using? I’m going to start my own blog in the near future but I’m having a tough time selecting between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for something completely unique. P.S Sorry for getting off-topic but I had to ask!|

  4. Awsome info and right to the point. I don’t know if this is truly the best place to ask but do you people have any thoughts on where to get some professional writers? Thanks in advance 🙂

  5. An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!

LEAVE A REPLY

Please enter your comment!
Please enter your name here