Today I've learned: Changing Shell Prompt Name/PATH importance (Environment variables)

Search for a command to run...

No comments yet. Be the first to comment.
Intro IoT nowadays is everywhere. Now there’s about 20 billion IoT devices. In 2031 there will be around 35 billion IoT devices connected to the internet. Interesting information about IoT devices & other stuff When more network devices we have and m...

Intro When I was learning cybersecurity topics in the past year, I’ve grasped lots of different tools and techniques. Some of the most iconic for me were: CAN BUS (controller area network) Radio Frequency Cryptography I was lucky to have an oppo...

What is Enumeration? It is one of the most important parts of Penetration Testing process. It is identifying all of the ways we could attack a target. We must do our best in this phase. Long story short - enumeration is collecting as much information...

Transferring files During any penetration testing exercise, it is likely that we will need to transfer files to the remote server. There are few options for this: One method is running a Python HTTP server on our machine and then using wget or cUR...

Privilege Escalation Once we gain initial access to a box, we want to thoroughly enumerate the box to find any potential vulnerabilities we can exploit to achieve a higher privilege level. There are checklists for privilege escalation online. A goo...

Cyber Journey
41 posts
Usually terminal in Kali looks like this
(username@hostname)-[current_directory] #
When you work as a root you see:
(root@kali)-[current_directory] #
There’s a PS1 Environment variable which is responsible for names in the shell. By default it changes the username of the Shell prompt. For example:
(root@kali)-[/home] # PS1="Powerful friend #"
Powerful friend #
It’s a nice functionality when you have multiple terminals. Keep in mind that it is valid only for the session. Of course we could do the export PS1 to make it permanent.
It has few options that can be changed (by default it changes the name):
\u - The name of the current user
\h - The hostname
\w - The base name of the current working directory
PATH is one of the most important variables. It holds the directories in which the terminal will look for the commands that you enter. For example cd, ls, pwd and so on.
You can see the content of PATH variable by writing:
echo $PATH
Keep in mind that we write $PATH and not PATH.
$ symbol is very important. It means that we ask for the content of the variable.
For example you download a new tool from Github. You want to use it in the terminal often. You’ll have to change your terminal directory to the folder where the tool is located. Here’s where adding to the PATH variable comes in.
For example:
Your tool is stored in this directory → /root/amazingtool . To use it everywhere you can add to the PATH variable by doing so:
PATH=$PATH:/root/amazingtool
Important:
Keep in mind that we use $PATH. We append the new value.
Congratulations, now you can use your amazingtool everywhere in the system, because PATH will know where to search. You can check it again by writing:
echo $PATH
Of course try not to add too many directories to the PATH variable. It’ll slow your system down.
We can create our own variables with names that we’d like. It’s useful when you have long terminal commands or you just want to have some extra “features” to flex about. Hehe.
For example let’s create a new variable called CYBRBLOG.
CYBRBLOG="Hacking is very cool"
And now let’s call it using echo and content symbol - $:
echo $CYBRBLOG
Hacking is very cool
Environment variables are indeed very interesting part.
You can change the behavior of your system by changing those variables.
PATH is really important part
It’s very important to use $(content) symbol when for example adding a new directory to the PATH variable.
It’s cool that you can create your own variables
Upcoming section is - Bash scripting.
I’m really excited about it. I already made one basic script to turn off my Kali laptop when finished learning.
cat first-script
#! /bin/bash
# This is my first script
echo "Hello, my friend, your system will shutdown. Bye!"
sleep 3
echo "Sleep well :)"
sleep 1
shutdown -h now
I’ll execute it using:
bash first-script
See ya later
I’m learning using this book:
Linux Basics For Hackers by OCCUPYTHEWEB (MASTER OTP)