TECHONOLGY

30 Basic Linux commands with examples and syntax

Written by Alex

Introduction

Linux is the most powerful operating system which provides a powerful interface. Many people think Linux is not easy to understand but you can start with some Basic Linux Commands. You should know basic Linux commands with examples and syntax. It’s a very good topic for beginners. By practices, these commands you can go for advanced Linux commands after that. We are here to let you know Basic Linux commands with examples and syntax and how we can run the command.

30 basic Linux commands for beginners

 1. pwd Command

pwd command is used for checking your current working directory.

 2. cd Command

If you need to change your directory. For example, if you want to go your home directory just type in the terminal.

cd /home/username.

You can give another full path of any directory where you want to go. Linux commands are case sensitive however you have to define the proper name.

3. ls Command with examples.

ls is used for view and list the content of your directory also you can view another directory content with giving the full path of the directory with examples.

a. ls /var/www/html : Another help command of ls.

b. ls -l : Similarly will list all the file and directory.

c. ls -ltr : FIle and folder list with date and time.

d. ls -la : Will list and also show hidden file of your directory.

4. cat Command

cat command used to see the content of the file. Its most usable command in Linux you can also create a file with the help of this command

a. cat > filename : to create a blank file

b. cat filename : to view the content of the file

c. cat filename1 > filename2 : to write filename1 data to file2

5. cp Command

cp basic commands use to copy any file and folder from one location to another location.

a. cp filename1 /home/user/  :  copy filename1 to /home/user directory

b. cp -R dir1 /home/user/ :  this command is use for copy dir1 to /home/user recursive

6. mv Command

mv work as its name If we want to move any file and folder to one location to another on the same OS then we will use move command.

a. mv filename1 /home/user/ : Moving file to /home/user/

b. mv dir1 /home/user/ : Moving directory to /home/user

7. mkdir Command

mkdir command to create any directory with any name and any location for example.

a. mkdir dirname : to create directory

b. mkdir -p /home/user/dirname : TO create a directory on another location

8. rm Command

Remove a directory with its content and file from the system.

a. rm -f filename : to delete the file

b. rmdir dirname : to delete the directory

10. touch Command

The primary work of touch is to create a file current directory or any other directory.

11. find Command

As its name find command is used to find file and directory in the Linux operating system For example: Find the file in the current directory for example.

a. find . -type f -name myfile :  To find any file.

b. find . -typed -name dirname : To find any directory.

12. grep Command

Its Linux command is used to find text in the file. Its most usable command in Linux uses below command with syntax.

a. grep “today” filename : To find today keyword in the filename

b. grep -r “today” dir1 : to find today word all in the directory it will search in all the files in the directory.

13. df Command

df command for checking disk space in your Linux machine.

a. df -h : will show disk space in human-readable form

14. du Command

With du command we can check how much space file and folder taking into your Linux machine you can use this command.

a. du -sh dirname : Will show the size of a directory

b. du -csh * : will show the size of all the file and directory

                                       Basic Linux commands with examples and syntax

15. tail Command

One of the basic Linux commands is used for the display content of the file as a line.

a. tail -n 100 filename : will show the last 100 lines of the file.

b. tail -f filename.log : will follow the file and display whatever is writing in the file.

16. tar Command

tar is used for archive many files and folders in one filename.tar Similarly to zip.

a. tar -cvf filename.tar filename : It will archive a single file.

b. tar -cvf filename.tar filename1 filename2: will archive both files into one.

c. tar -cvzf filename.tar.gz dir1: will archive and compress dir1.

17. chmod Commands with examples

Under the Linux os, this is used to change the permission of file and directory it’s a very complicated command we will show you some example. Uses: Each writes, read, and execute permission have the following value.

  • r(read) = 4
  • w(write) = 2
  • x(execute) = 1
  • no permissions = 0

In addition for more clarity: chmod 755 dir1 : It means dir1 have user:rwx  group:rx  other:rx chmod 644 filename: It means filename have  user:rw  group:r  other:r

Basic Linux Commands

18. kill Command

If any unresponsive process running in Linux and not being close then you can use kill command to kill that process. we can use -9 signal to kill process forcefully

a. kill -p processid : To kill specific process id in Linux OS

19. wget Command

Very useful command in Linux, if you need to download a file from any downloadable link with help of this command for instance.

a. wget https://exampl.com/filename.zip: to download filename.zip with wget command.

20. top Command

Its monitoring command of any Linux based OS its default command in Linux and you can run in any Unix variants, in other words, you can run this command in MAcOSx also. Moreover we can check our Linux system hardware utilization for example memory CPU uses. Also, we can check the running process with their PID number.

21. history Command

When you have run multiple commands in a day and want to check what commands you have run Therefore you can check by typing history command.

22. zip and unzip Command

ZIP command is a famous Linux command. In daily routine some time you need to compress multiple file and folder into one file. You can use zip command for compress and uncompress the zip file you can use unzip command. To clarify the use below command.

a. zip -r dir.zip dir1 : To making zip for dir1 you will get dir.zip file after that.

b. unzip dir.zip : to unzip dir.zip

22. hostname Command

hostname command will show the name of your Linux machine. You can also set hostname as per your convenience Use below command to change the hostname.

a. hostnamectl hostname

23. useradd Command

Linux is multiuser platform means you can create multiple users in Linux with this basic Linux command

a. useradd alex : For adding the user name Alex

24. passwd Command

Set the password of the user you need to run this Linux command. For changing the existing user password you will use this command for instance.

a. passwd alex : This command for the change user password.

25. free Command

the free command for checking system memory usage and also show swap memory of the system. Let’s check memory in human-readable also.

a. free -h : will show memory usage.

26. shutdown Command

Most importantly command for shutdown the system.

27. reboot Command

reboot the Linux system.

28. sudo Command

Sudo command we use where our command needs superuser privileges to run. However, we can also change another user password with Sudo command. for example.

sudo passwd user2 : Here we are changing the password of user2 with super privileges.

29. uname Command

uname use to grep some system information like OS distribution version.

30. whoami Command

find who currently logged into the Linux system.

In Conclusion

Congratulation now you are familiar with 30 Basic Linux commands with examples and syntax. Above all commands are good to start for beginners. Start more learning with our other blog link here.

We hope you are like this article and this is useful for you. If you learn more about Linux, AWS Tips, and Tricks Please Bookmark this Website. We are Daily Publish New Article in this Website WWW.BPMTECHGURU.IN and all post on this website is practically tested and 100% Work if you have any Problem Please Drop a Comment we are trying to resolve your problem.

 

About the author

Alex

Leave a Comment