Linux Basic Commands With Practical

Hacking Truth
3

 

Linux Basic Commands With Practical

 

LINUX COMMANDS INTRODUCTION TO LINUX:


If you too are fond of using the internet and you like to know about technology and the world of internet and hacking, then you have probably heard about Kali Linux but do you know what happens next and then What are the advantages and disadvantages of using Kali!!


  • Linux is a Unix-like operating system that was designed to provide personal computer users a free or very low-cost operating system comparable to traditional and usually more expensive Unix systems.
  • Linux has a reputation as a very efficient and fast-performing system.
  • Linux's kernel (the central part of the operating system) was developed by Linus Torvalds at the University of Helsinki in Finland.
  • To complete the operating system, Torvalds and other team members made use of system components developed by members of the Free Software Foundation for the GNU Project.





What is Kali Linux and what is its use ?


Kali is a Linux operating system that you can download and use for free from the Internet. It is a dispensed version, specially designed for Security Testing Testing Security Research, can install windows on your computer and laptop. And you can use it, this is your work, which you can install and use in your work, now many people use Kali Nan For good deeds we call whiteheads and some people use this operating system for the wrong deeds we call black hat hackers.

Red hat linux And there is some good work , which we call White Hat Hacker. Now you must be thinking that in the end, Kali goes to Linux to learn hacking, then why do you use it because the carpet has you in it but already kali linux and windows 7 dual boot You will be able to create a lot of code, that is, you will not have to write much code in Kali Linux and you will get many hacking tools already made for free, which will save your time and And you can learn hacking at an advanced level, hacking so people love Kali Linux operating system very much, besides this opening system is completely free. You can download this operating system for free from the official website of Kali Linux.



BASIC LINUX COMMANDS -


1. bc COMMAND:


bc command is used for command line calculator. It is similar to basic calculator. By using which we can do basic mathematical calculations

First You need to install bc in linux. 

command sudo apt-get install bc


Linux Basic Commands with practical



 

SYNTAX: The Syntax is bc [options]

For ex you want to convert Decimal to Hexadecimal or Decimal to octa or Decimal to binary or Hexadecimal to Decimal or Binary to Decimal.

 

┌──(hackerboy㉿KumarAtulJaiswal)-[~]
└─$ echo 'obase=16;10'| bc
A
┌──(hackerboy㉿KumarAtulJaiswal)-[~]
└─$ echo 'obase=8;10' | bc
12
┌──(hackerboy㉿KumarAtulJaiswal)-[~]
└─$ echo 'obase=2;10' | bc  
1010
┌──(hackerboy㉿KumarAtulJaiswal)-[~]
└─$ echo 'ibase=16;A' | bc
10
┌──(hackerboy㉿KumarAtulJaiswal)-[~]
└─$ echo 'ibase=8;12' | bc
10
┌──(hackerboy㉿KumarAtulJaiswal)-[~]
└─$ #www.hackingtruth.org      
┌──(hackerboy㉿KumarAtulJaiswal)-[~]
└─$ 
  

 

Linux Basic Commands with practical




2. ls COMMAND:


ls command lists the files and directories under current working directory.

SYNTAX:

The Syntax is ls [OPTIONS]... [FILE]


┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux]
└─$ ls
bc-hackingtruth.png  hackingtruth.in  hackingtruth.org  hackingtruth.png  hackingtruth.txt  wcalc.png
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux]
└─$ 



  


3. mkdir Command:

The “mkdir” (Make directory) command create a new directory. • If directory already exists, it will return an error message “cannot create folder, folder already exists”.

Syntax

mkdir directory_name

Example: mkdir mcastudent


  
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux]
└─$      
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux]
└─$ mkdir mcastudent
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux]
└─$ ls
 mcastudent
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 


  

4. cal Command

cal command is used to display the calendar

Syntax:

cal [options] [month] [year]


  
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux]
└─$ cal  
   February 2022      
Su Mo Tu We Th Fr Sa  
       1  2  3  4  5  
 6  7  8  9 10 11 12  
13 14 15 16 17 18 19  
20 21 22 23 24 25 26  
27 28                 
                      
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux]
└─$ cal Feb 2023
   February 2023      
Su Mo Tu We Th Fr Sa  
          1  2  3  4  
 5  6  7  8  9 10 11  
12 13 14 15 16 17 18  
19 20 21 22 23 24 25  
26 27 28              
                      
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux]
└─$             
  

Linux Basic Commands with practical


4. clear Command

cal command is used to display the calendar

Syntax:

clear


Linux Basic Commands with practical



Also read - Networking primer series Binary to decimaI


5. cd Command

cd command is used to change the directory and cd is stand for change directory.

Syntax:

cd / 

cd /Desktop 

cd /Documents

cd /mcastudent etc


┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux]
└─$ ls  
hackingtruth.org  hackingtruth.png  mcastudent                 
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux]
└─$ cd mcastudent          
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ ls
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 


  



6. cp COMMAND:


cp command copy files from one location to another. If the destination is an existing file, then the file is overwritten; if the destination is an existing directory, the file is copied into the directory (the directory is not overwritten).

SYNTAX:

The Syntax is cp [OPTIONS]... SOURCE and DEST


  
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ cat file1.txt                
hello viewers
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ cat file2.txt
whats going on!!
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ cp file1.txt file2.txt   
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ cat file1.txt         
hello viewers
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ cat file2.txt         
hello viewers
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 

  


Linux Basic Commands with practical



NOTE: don't worry we will learn about cat command..be patience...carry on!


7. date Command

date command is used to print the date and time.

Syntax:

date [options] [+format] [date]


┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ date
Thursday 24 February 2022 02:07:37 AM IST
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$      


  


8. echo Command

echo command is used to print the give input string to standard output.

Syntax:

echo [options] [string]


  
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ echo "Hello Myself Kumar Atul Jaiswal and I am self taught White Hat Hacker"   
Hello Myself Kumar Atul Jaiswal and I am self taught White Hat Hacker
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 


  

9. pwd Command

pwd command is used to print the current working directory/present working directory..

Syntax:

pwd 
 

Linux Basic Commands with practical


9. mv Command

mv command is used to rename any file in linux.

Syntax:

mv SOURCEFILE and DESTINATION-DIRECTORY

mv hello hi

mv file1.txt file2.txt



Linux Basic Commands with practical


10. rm or rmdir Command

rm command is used to remove files and directory in linux.

Syntax:

mv SOURCEFILE and DESTINATION-DIRECTORY

mv file2.txt

mv -rf atul



Linux Basic Commands with practical


NOTE: atul is a directory and file.txt is a file.


10. history Command

history command is used to print the recently used command in linux.

Syntax:

history 


  
  
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ history  
 2089  echo "Hello Myself Kumar Atul Jaiswal and I am self taught White Hat Hacker" 
 2091  pwd
 2095  mv file1.txt file2.txt
 2099  mkdir atul
 2102  rm file2.txt
 2104  rm -rf atul
 2105  ls
 2106  #www.hackingtruth.org
 2107  clear
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 
  



and in case if you want to search particular command with history command in history section.

then, you can use this command -

history | grep "mkdir"


 

 

Linux Basic Commands with practical

 

For more about grep then see in the below section.



11. grep Command

grep command is used to print the recently used command in linux.

Syntax:

grep [OPTION]... PATTERNS [FILE]...

grep all file1.txt



Linux Basic Commands with practical



12. cat Command

cat command is used to create a file with content in linux.

Syntax:

cat [OPTION]... [FILE]...

cat file1.txt


  
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ cat file1.txt
Hello Everyone whats up

https://www.hackingtruth.in
https://www.hackingtruth.org
https://pulwama.hackingtruth.in
https://www.kumaratuljaiswal.in
https://iam.kumaratuljaiswal.in


NOTE: Don't forget to visit these site..
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 


  


Linux Basic Commands with practical


12. touch Command

touch command is used to create a file without content in linux.

Syntax:

touch [OPTION]... [FILE]...

touch file


  
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ touch file2.txt
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ touch file3    
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ ls
 file2.txt  file3
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 

  


13. whereis Command

whereis command is used to locate the source and manual pages of the command in linux.

Syntax:

whereis cat


Linux Basic Commands with practical


14. whatis Command

whatis command is used to get brief information about linux command.

Syntax:

whatis command

whatis cp


Linux Basic Commands with practical



15. which Command

which command is used to locate executables in the system.

It allows user to pass several command names argument to get their paths in the system.

Syntax:

which command

which ls


┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ which script
/usr/bin/script
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ which ls    
ls: aliased to ls --color=auto
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 


  

16. man Command

man command is used to provide documentations for all the possible options with a command and its uses..

It allows user to pass several command names argument to get their paths in the system.

Syntax:

man command

man cat


17. whoami Command

whoami command is used to find out the current user of the terminal in the linux system.

Syntax:

whoami 


Linux Basic Commands with practical


┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ #www.kumaratuljaiswal.in
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ whoami   
hackerboy
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/basiccommandsinlinux/mcastudent]
└─$ 


  


18. df Command

df command is used to report disk usage of file system.

Useful for user as well as System Administrator to keep track of their disk usages.

Syntax:

df


Linux Basic Commands with practical


19. Ps Command

ps process gives the status of running of running processes with a unique ID clled PID (process id).

 

Linux provides us a utility called ps for viewing information related with the processes on a system which stands as abbreviation for “Process Status”. ps command is used to list the currently running processes and their PIDs along with some other information depends on different options.

 

Syntax: ps


Linux Basic Commands with practical


19. kill Command

kill command is used to kill the background process.

 

Syntax: 
 
kill [options] <pid> [...]

 
 
But According to the current situation, i do not want to kill any process right now..
 
go ahead!!!! :-p hahahhha!!
 
 

21. sudo Command

sudo as well as we already know about that in windows and the name is sytem administrator when we install or anything which require the power of a system administrator.

It allows a permitted user to execute a command as the super user or another user.

 

Syntax: sudo /etc/shadow



Linux Basic Commands with practical


22. su Command

It is used to run shell with substitue user and group IDs.

It helps to change login session's owner without the owner having to first logout of that sessions.

 
Syntax:  
 
su user1
su user2


Linux Basic Commands with practical



23. passwd Command

It is used for changing the passwd.

You must know the current passwd for security reason.

 
Syntax:  
 
passwd


24. cmd Command

Compare two files byte by byte in linux

 
Syntax:  
 
cmp [options] file1 file2

cmp file1.txt file2.txt


Linux Basic Commands with practical



25. diff Command

compare files line by line
 
Syntax:  
 
diff [options] file1 file2
diff file1.txt file2.txt



Linux Basic Commands with practical



26. chmod Command

The chmod command is used to change the permissions of a file or directory. To use it, we specify the desired permission settings and the file or files that we wish to modify. There are two ways to specify the permissions.
 
First of all you need to understand about file permission like read, write, executable, etc...
 
as you can see below the image and some kind of drwxr-xr-x ...


Linux Basic Commands with practical



see this also


Linux Basic Commands with practical


Now, if we represent each of the three sets of permissions (owner, group, and other) as a single digit, we have a pretty convenient way of expressing the possible permissions settings. For example, if we wanted to set some_file to have read and write permission for the owner, but wanted to keep the file private from others, we would:

chmod 600 some_file


Value     Meaning

  • 777     (rwxrwxrwx) No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.


  • 755     (rwxr-xr-x) The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.


  • 700     (rwx------) The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.


  • 666    (rw-rw-rw-) All users may read and write the file.


  • 644     (rw-r--r--) The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.


  • 600     (rw-------) The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private



Directory Permissions


The chmod command can also be used to control the access permissions for directories. Again, we can use the octal notation to set permissions, but the meaning of the r, w, and x attributes is different:

  • r - Allows the contents of the directory to be listed if the x attribute is also set.
  • w - Allows files within the directory to be created, deleted, or renamed if the x attribute is also set.
  • x - Allows a directory to be entered (i.e. cd dir).


Here are some useful settings for directories:


Value     Meaning

  • 777     (rwxrwxrwx) No restrictions on permissions. Anybody may list files, create new files in the directory and delete files in the directory. Generally not a good setting.


  • 755     (rwxr-xr-x) The directory owner has full access. All others may list the directory, but cannot create files nor delete them. This setting is common for directories that you wish to share with other users.


  • 700     (rwx------) The directory owner has full access. Nobody else has any rights. This setting is useful for directories that only the owner may use and must be kept private from others.



Linux Basic Commands with practical



27. vim or vi (editor in CLI mode) Command


On Unix-like operating systems, vim, which stands for "Vi Improved", is a text editor. It can be used for editing any kind of text and is especially suited for editing computer programs.
 
 
Syntax:  
 
vim [options] [file ..]
vim [options] -
vim [options] -t tag
vim [options] -q [errorfile]
       
      

For more info click Here - 6 reasons why you can go crazy about Vim



For something is missing we will update soon... so until you can bookmark this webpage.


I hope you liked this post, then you should not forget to share this post at all.
Thank you so much :-)

 

Disclaimer

All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.
 
 
 
 
 

Post a Comment

3 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment
Our website uses cookies to enhance your experience. Learn More
Accept !