Sunday, January 28, 2024

Linux Command Line Hackery Series: Part 1




In this concise article we will learn some basics of how to use Linux Command line, so lets get started.

Requirements:

1. An open Terminal in your Linux Box. I'm using Kali Linux 2.0
or you can check out this amazing website Webminal

Command:  ls
Syntax:         ls [flag(s)]
Function:      ls is short for list. ls command is used to list the contents of a directory these contents include files, folders, and links. ls has many optional flags as well, some of them are described below
Flags:    -a this flag is used to view hidden files that is those files whose names are preceded                      by a '.'(dot)
               -l  this flag is used to view file permissions, owner of the file, group of the owner, the                        file size, the modification date, and the filename. We'll talk more about it in later                            articles.

Command:  mkdir
Syntax:         mkdir dirname
Function:      mkdir is used to create a directory (or a folder) with the name which is followed by the command

now lets create a directory in our current directory named as myfiles, how would you do that?

mkdir myfiles

which command should we use in order to verify that the directory has been created in our current folder?

ls

this will list all the files and directories in our current folder. Do you see myfiles directory listed?

Command:  cd
Syntax:         cd path/to/directory
Function:      cd is short for change directory. It is used to navigate directories, or to make it clear it does the same thing as what double clicking on a folder do except it doesn't show you contents of the directory :(. In order to navigate or visit another directory we need to provide it's ABSOLUTE-PATH or RELATIVE-PATH you heard that, didn't ya?

Paths are of two types relative path or absolute path (also called full-path). Relative as the name suggests is relative to the current directory, so if you have to navigate to a folder within the current directory you'll just simply type cd directory_name. But what if you have to navigate to a directory which is the parent of current directory? Well it's easy just type cd .. (yes double dots, you noticed that .. and . thing when you typed ls -a, didn't you?). The double dots mean the directory above current directory (i,e the parent directory) and a single dot means the current directory (i,e the directory that I'm currently in). Now if you have to navigate two directories above current directory using relative path navigation you'll type

cd ../.. 

here .. means previous directory and another .. after slash (/) means the previous directory of the previous directory sounds confusing..!

The Absolute Path means full path to the file or folder which starts from root directory. Say I want to navigate to my home folder using absolute path, then I'll type:

cd /home/user

where user is the username
Now think of navigating to the myfiles folder from your home directory using the absolute path, it will be something like this:

cd /home/user/myfiles

Exercise: Create a directory project1 inside your home directory and inside the project1 directory create a file and a directory named index.html and css respectively. Then navigate to the css directory and create a style.css file inside it. At last navigate out of the css directory to home both using the relative and absolute path mechanisms.

[Trick: To get quickly out of any directory to your home directory type cd ~ [press Enter] or simply cd [press Enter]]

Command:  touch
Syntax:         touch filename
Function:      touch is a nifty little function used to create an empty file (actually it's used to change access time of a file but everyone has got bad habits :P ). You can create any type of empty file with the touch command. If you are a bit curious about touch read the manual page of the touch command using the man touch command.

Now lets create a few files inside of our myfiles directory

touch file1 file2 file3

The above command creates three empty files in our current directory named file1, file2, and file3.
How will you verify that it has indeed created these three files in your current directory? I won't answer this time.

Command:  echo
Syntax:         echo Hacker manufacturing under process
Function:      echo is used to display a line of text. By default echo displays a line of text on the terminal which is the standard output device (stdout for short). However we can redirect the output of an echo command to a file using > (the greater than symbol).
Now if we have to echo a line of text to a file, say file1 in our myfiles directory, we will type:

echo This is file1 > file1

The above command will echo the text "This is file1" to file1.

Command:  cat
Syntax:         cat filename [anotherfilename...]
Function:      cat stands for concatenate (not that puny little creature in your house). The main function of cat is to concatenate files and display them on your terminal (or in geeky terms stdout). But its also used to display the contents of a file on your terminal.

Let's display the contents of file1 in the myfiles directory that we echoed to it using the echo command, for that we'll type:

cat file1

Awesome I can see on black screen contents of my file (what if your terminals background is white?), looks like I'm becoming a hacker. In case you don't see it then I suggest you should give up the thought of becoming a hacker. Just kidding you might have missed a step or two from the above steps that we performed.

Now lets say that we want to add another line of text to our file using the echo command should we use the same greater than (>) symbol? No, if we want to add another line (which in geeky terms is to append a line) to our file using the echo command we have to use >> (two greater than symbols) like this:

echo Another line of text >> file1

now to check the contents of file1 we'll type:

cat file1

OK we wrote two lines inside of the file1.
Does it mean we have to add three greater than symbols to write third line? Oh! I didn't thought you'd be such a genius.

A single greater than symbol (>) means redirect the output of the preceding command to a file specified after the > symbol. If the file exists then overwrite everything that's in it with the new contents and if the file does not exist then create one and write to it the output of the preceding command. So if you had typed

echo Another line of text > file1

it would have overwritten the contents of the file1 with "Another line of text" and the line "This is file1" would no longer be present in the file.

Two greater than symbols (>>) mean that append (remember the geeky term?) the output of the previous command to the end of file specified after >>. Now if you want to add another line of text to file1, you won't use >>> rather you'll use >> like this:

echo Third line in file1 >> file1

This is it for today. But don't worry we'll learn more things soon.

More info

  1. Hacking Tools Windows 10
  2. Pentest Tools Tcp Port Scanner
  3. Pentest Tools List
  4. Growth Hacker Tools
  5. Pentest Tools For Windows
  6. Hacking Tools Usb
  7. Pentest Tools Apk
  8. Pentest Tools Subdomain
  9. Hacking Tools Mac
  10. Pentest Tools Find Subdomains
  11. Hacker Tool Kit
  12. Hack Tools Github
  13. Usb Pentest Tools
  14. Hacking Tools Online
  15. Pentest Tools Android
  16. Nsa Hack Tools
  17. Hacking Tools Usb
  18. Hack Tools For Windows
  19. Pentest Tools List
  20. Hacking Tools For Mac
  21. Physical Pentest Tools
  22. Pentest Tools Linux
  23. Hack Tools 2019
  24. Hack Tools For Ubuntu
  25. Pentest Tools Website Vulnerability
  26. Hacker Tools Free
  27. Underground Hacker Sites
  28. Kik Hack Tools
  29. Best Pentesting Tools 2018
  30. Hacker Tools List
  31. Pentest Tools Android
  32. Hack Website Online Tool
  33. Hacking Apps
  34. Pentest Recon Tools
  35. Pentest Box Tools Download
  36. Pentest Tools Kali Linux
  37. Hack Tools
  38. What Is Hacking Tools
  39. Hacking Tools Pc
  40. Hack Tools 2019
  41. Pentest Tools Nmap
  42. Best Hacking Tools 2020
  43. Hack Tools For Games
  44. Pentest Tools Windows
  45. Hack Rom Tools
  46. Hacking Tools For Kali Linux
  47. Hacker Tools For Mac
  48. New Hacker Tools
  49. Github Hacking Tools
  50. How To Make Hacking Tools
  51. Pentest Automation Tools
  52. Pentest Tools Open Source
  53. Hacking Tools Usb
  54. Best Hacking Tools 2019
  55. Pentest Tools Download
  56. Best Hacking Tools 2019
  57. Hack Tools Online
  58. Hacker Tools
  59. Hacking Tools Name
  60. Tools 4 Hack
  61. Hacking Tools Hardware
  62. Beginner Hacker Tools
  63. Hacking Tools For Windows Free Download
  64. Hacking Tools Windows
  65. Pentest Tools Subdomain
  66. Pentest Tools Url Fuzzer
  67. Kik Hack Tools
  68. Hackrf Tools
  69. Hack Tools For Mac
  70. Hacker Tools For Ios
  71. New Hack Tools
  72. Hacking Tools For Games
  73. Pentest Reporting Tools
  74. Hack Tools For Ubuntu
  75. Pentest Tools Tcp Port Scanner
  76. Hack Tools
  77. Hack Tools For Ubuntu
  78. Hack Rom Tools
  79. Hacker Tool Kit
  80. Pentest Tools Github

No comments:

Post a Comment