30 Basic Linux Commands with Examples

In this blog we are going to see the Linux OS and its important 30 Basic Linux commands you should will need and should remember as an developer.

What is Linux ?

Linux is a open source Operating system developed by Linus Torvalds. Its initial release is dated on 17, September 1997. There are many distributions available for free to use, but the popular distributions are Debian, Fedora and Ubuntu. The different distribution doesn’t effect the command line of Linux (terminal). So lets move to the important commands in Linux.

30 Basic Linux Commands with Examples 1

30 Basic Linux commands to remember with its usage :

1. Linux man command :

The man command is used to see the manual for a particular command. So whenever you are stuck at usage of any command you can just use the man command to checkout the usage of the command.

Syntax :

man <command to checkout>

Example :

man nmap
30 Basic Linux Commands with Examples 2

2. Linux ls command :

The ls command is used to list out the files of the current directory or required directory. So if you just want to check the files in a directory, ls command is good to go.

Syntax:

ls

OR

ls <path of required directory>

Example :

ls

OR

ls /bin
30 Basic Linux Commands with Examples 3

3. Linux cd command :

The cd in cd command stands for change directory. If the user want to move to other directory you are welcomed to use the cd command.

Syntax :

cd <path of the directory to change on>

Example :

cd HS
30 Basic Linux Commands with Examples 4

4. Linux pwd command :

The pwd in pwd command represents Print Working Directory. This command is used to print the directory you are active on right now. So if you are lost somewhere or just want the current directory which you are on you should use pwd

Syntax :

pwd

Example :

pwd
30 Basic Linux Commands with Examples 5

5. Linux mkdir command :

The mkdir command is used to create a new folder in current working directory. Usually mkdir is seen as Make Directory.

Syntax :

mkdir <name of folder to be created>

Example :

mkdir HS
30 Basic Linux Commands with Examples 6

6. Linux rmdir command :

With rmdir command you can delete the required folder. “rmdir” command is marked as “remove directory”.

Syntax :

rmdir <path of the folder/directory>

Example :

rmdir HS
30 Basic Linux Commands with Examples 7

7. Linux mv command :

The mv command is move command for Linux OS, it moves can move folder to the specified path (destination). Want to move a folder? mv command is good to go.

Syntax :

mv <folder name>  <destination folder/path>

Example :

mv HS /home
30 Basic Linux Commands with Examples 8

8. Linux cp command :

This command allows user to copy files/folder to the destination folder/directory.

Syntax :

 cp < folder name>  <destination folder/path>

Example :

cp HS /home
30 Basic Linux Commands with Examples 9

9. Linux xdg-open command :

xdg-open command” is used to open a file in Linux OS.

Syntax :

xdg-open <name/path of the file to be opened>

Example :

xdg-open HS.txt
30 Basic Linux Commands with Examples 10

10. Linux touch command :

The touch command is used to create a empty file with specified extension. If the file already exist in the specified path, then opens the existing file and the timestamp of the existing file is updated.

Syntax :

touch <filename>

Example :

touch HS
30 Basic Linux Commands with Examples 11

11. Linux find command :

The find command is used to search a folder or file in the specified path. If you forgot where you saved your file or where your file got misplace find command can helps you a lot. You can use different flags to get a very specify result, use man command to see the flags.

Syntax :

find <filename>

Example :

find HS
30 Basic Linux Commands with Examples 12

12. Linux gzip command :

With gzip command the user can compress existing file.

Syntax :

gzip <filename>

Example :

 gzip HS
30 Basic Linux Commands with Examples 13

13. Linux alias command :

This command is used to create a shortcut name for the existing command. So if you want to create a shortcut for a command this command can be used.

Syntax :

alias <shortcut_name>=”<command to be executed>”

Example :

alias CD=”cd /home”
30 Basic Linux Commands with Examples 14

14. Linux cat command :

cat command” is one of the most used command by the cybersecurity enthusiast while playing “Capture The Flag” competitions. This command allows user to view output of the file or concatenate files.

Syntax :

 cat <filename>

Example :

cat HS.txt
30 Basic Linux Commands with Examples 15

15. Linux less command :

Another command to view output of the files is the less command. The difference between cat command & less command is that less command allows us to view content of large files. Its better to use less command if you don’t known the size of the file or what content file content.

Syntax :

less <filename>

Example :

less HS.txt
30 Basic Linux Commands with Examples 16

16. Linux wc command :

wc command” or the word count command in Linux is usually used to count number of words or lines in a file. But with some specified flags this command is capable of counting bytes and character also.

Syntax :

wc <filename>

Example :

wc HS.txt
30 Basic Linux Commands with Examples 17

17. Linux grep command :

grep” stands for global regular expression print. This command helps user to search in the files with some patterns of characters.

Syntax :

grep <options>  <pattern>  <filename>

Example :

grep -c “Reaaders” HS.txt
30 Basic Linux Commands with Examples 18

18. Linux chown command :

The chown command is used to change ownership of particular file. OS can have different users, so control the ownership of a file the chown command can be used.

Syntax :

chown <ownername> <filename>

Syntax :

chown hsanon HS.txt  
30 Basic Linux Commands with Examples 19

19. Linux echo command :

This particular command is used to output the strings it is being passed as an arguments.

Syntax :

echo “<string>”

Example :

echo “Hello Readers”
30 Basic Linux Commands with Examples 20

20. Linux chmod command :

This command is used to change access mode of the file.

Syntax :

chmod <argument>  <filename>

Example :

chmod 777 HS.txt
30 Basic Linux Commands with Examples 21

21. Linux ps command :

ps command” play role of task manager in Linux OS. “ps” stands for process status & is used by the user of the system to check the status or information of the processes running in the system.

Syntax :

ps <flags>

Example :

ps ax
30 Basic Linux Commands with Examples 22

22. Linux whoami command :

Another widely used command by the CyberSec enthusiasts. This command shows the active user on the terminal.

Syntax :

whoami

Example :

sudo whoami
30 Basic Linux Commands with Examples 23

23. Linux sudo command :

One of the most important command used in Linux is sudo command. This command is used to run a command as root user.

Syntax :

sudo <command>

Example :

 sudo su
30 Basic Linux Commands with Examples 24

24. Linux nano command :

Nano is a user friendly editor. To access file through Nano editor or create a new file using this editor, nano command is used.

Syntax :

nano <filename>

Example :

nano HSAnon.cpp

25. Linux passwd command :

Want to change password? “passwd command” is the option for you to execute. This particular command changes the password for active user on the terminal, also using different argument you can change password of inactive user.

Syntax :

 passwd <username> <password>

Example :

passwd hsanon **************

26. Linux ping command :

This particular command is used to test the network connectivity between the server and the host. Some time this command is used to check the network connection of the user is active or not.

Syntax :

ping <url>

Example :

ping www.fosstechnix.com

27. Linux clear command :

The clear command is used by the user to clear the terminal.

Syntax :

clear

Example :

clear

28. Linux env command :

The env command sets the environment variable of the current active terminal.

Syntax :

env <option> <name=value> <command argument>

Example :

env -i /bin/sh
30 Basic Linux Commands with Examples 25

29. Linux history command :

history command” prints the history of commands recently executed by the user.

Syntax :

history

Example :

history

30. Linux vim command :

Vim is a user advance level editor popular among programmers. To access file through Vim editor or create a new file using this editor, vim command is used.

Syntax :

vim <filename>

Example :

vim HSAnon.cpp
30 Basic Linux Commands with Examples 26

Related Articles:

Linux Practical Tutorial

Linux Monitoring Commands you should know

Reference:

Linux Official page

Harsh Sangade

Hey tech nerds !!! This is Harsh. Currently pursing B.Tech. in information technology and interested in Cyber Space & Linux. You could expect some blogs on this topics.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap