Ethical Hacking

Linux Commands

Linux Commands

Hello hackers ,

welcome back again….

we have learned about how to install KALI LINUX, now it’s time to learn how it works i.e we need to mostly work on CLI(Command Line Interface) because during hacking and security purposes the command line interface is used more and they prefer it more comfortable…

SO the CLI(Command Line Interface) as its name shows you it will work on Commands… In Linux, the CLI(Command Line Interface) is known “TERMINAL”…

How Kali Linux terminal look likes

Let’s now learn about its commands which will make you work with Terminal….

1. pwd command

Use the PWD(Present Working Directory) command to find out the path of the current working directory (folder) you’re in. The command will return an absolute path. An example of an absolute path is/home/cyberwarrior.

we normally use these commands while we do not have an interactive shell.

2. cd command

It is used to change the running directory.

Let’s say you’re in /home/cyberwarrior/Documents and you want to go to images, a subdirectory of Documents. To do so, simply type the following command: cd images

  • cd .. to move one directory up
  • cd to go straight to the named folder
  • cd- to move to your previous directory

3. ls command

The ls command is used to view the contents of a directory. By default, this command will display the contents of your current working directory.

If you want to see the content of other directories, type ls and then the file path. For example, enter ls /home/cyberwarrior/Downloads to view the content of Downloads.

  • ls -R this will list all the files in the sub-directories as well
  • ls -a this will show the hidden files
  • ls -al this will list the files and directories with detailed information like the permissions, size, owner, when it was saved, etc.

4. cat command

cat is one of the most frequently used commands in Linux. It is used to list the contents of a file usually used for “txt“ file extension on the standard output. To run this command, type cat followed by the file name and its extension.

For eg: i have vulndetox.txt file so i will open it like this cat vulndetox.txt

Here are other ways to use the cat command:

  • cat > filename this will create a new file
  • cat filename1 filename2>filename3 this will join two files and stores the output of them in a new file (3)
  • cat filename | tr a-z A-Z >output.txt this is used to convert a file to the upper or lower case use

5. rm command

The rm command is used to delete directories and the contents within them. If you only want to delete the directory

Guys are careful with these commands because after running these commands there is no option of undoing in Linux.

The whole data will be lost.

6. chmod command

chmod is also a Linux command, used to change the permissions of file or directory like read, write ,execute.

E.G : chmod +x <file> , chmod 777 <file>..

7. cp command

Use the cp command is used to copy files from the current directory to a different directory. For example, the command cp vulndetox.jpg /home/cyberwarrior/images would create a copy of vulndetox.jpg (from your current directory) into the images directory.

8. mkdir command

Use of mkdir command to make a new directory — if you type mkdir vulndetox it will create a directory called vuldetox.

There are extra mkdir commands as well:

  • To generate a new directory inside another directory, use this Linux basic command mkdir vulndetox/hacked.

9. mv command

The use of the mv command is to move files, from one directory to another

The arguments in mv are similar to the cp command. You need to type mv, the file’s name, and the destination’s directory. For example: mv vulndetox.txt /home/cyberwarrior/Downloads

10. touch command

The touch command will help you to create an empty new file through the Linux command line. As an example, enter touch /home/cyberwarrior/Downloads/vulndetox.html to create an HTML file named vulndetox under the Downloads directory.

11. locate command

You will use this command to locate a file or directory using the -i argument along with this command will make it case-insensitive, so you can search for a file even if you don’t remember its proper name.

To search for a file that contains two or more words, use an asterisk (*). For example, locate -i vulndetox*hacked command will search for that file that contains the word “vulndetox” and “hacked”.

12. sudo command

Acronym for “SuperUser Do”, this command enables you to perform tasks that require root permissions.

If you have got some error about permission denied then you need to use this command.

13. diff command

Acronym for difference, the diff command compares the contents of two files. After analyzing the files, it will give output the lines that do not match.

The simplest form of this command is diff vulndetox1.txt vulndetox2.txt

14. ping command

Use the ping command to check your connectivity status to a server. For example, by simply entering ping, the command will check whether you’re able to connect to vulndetox and also measure the response time.

15. wget command

The Linux command line is very useful you can even download files from the internet with the help of the wget command. To do so, only type wget and the download link copied from the URL.

16. uname command

The uname command, Acronym for Unix Name, will give detailed information about your Linux system like the machine name, operating system, kernel, and so on.

17. history command

When you start using Linux for a certain period of time, you’ll quickly notice that you can run hundreds of commands every day. As such, running the history command will show you the list of commands you have recently used.

18. man command

If you don’t know how to use any tool you can easily learn how to use them by using the man command. For example, entering man nmap will show the manual instruction of the Nmap command.

19. echo command

The command is used to move data into a file. For example, if you want to add the text, “Hello, my name is shubham” into a file called vulndetox.txt, you will type echo Hello, my name is shubham>> vulndetox.txt

20. zip, unzip command

Use the zip command to compress your files into a zip archive, and you can use unzip command to extract the zipped files from a zip archive.

21. hostname command

If you want to know the name of your host/network simply type hostname. Adding a -i to the end will display the IP address of your network.

22. clear command

Use the clear command to clean out the terminal if it is getting cluttered with too many past commands.

23. grep command

This Linux command grep is useful in Linux to grep which is to pick out something from a list or txt file(specific terms). It will help you to go through all the files and find that keyword you have put there

To illustrate, cat vulndetox.txt | grep hacked will search for the word hacked in the vulndetox file. Lines that contain the specified word will be displayed there.

That’s all these are some commands you need to remember while working in TERMINAL ..

These are some short tricks you can use while working.

  • Try the TAB button to autocomplete what you are typing. For example, if you need to type Downloads, begin to type a command cd Down and then hit TAB the word will autocomplete itself
  • Ctrl+C and Ctrl+Z are used to stop any command that is currently working. Ctrl+C will stop the ongoing command, while Ctrl+Z will simply pause the command
  • If you accidentally freeze your terminal by using Ctrl+S, simply undo this with the unfreeze Ctrl+Q.
  • You can run multiple commands in one single command by using this “;” to separate them. For example Command1; Command2; Command3. Or use && if you only want the next command to run only when the first one is successful.

OK friends its time say you GOOD BYE for now

Happy Hacking!!

Share this post

About the author

Leave a Reply

Your email address will not be published. Required fields are marked *