L in u X ba sics for h acke rs g e t t I n g s t a r t e d w I t h


Chapter 7 kali >export PS1='C:\w> '


Download 7.3 Mb.
Pdf ko'rish
bet82/115
Sana27.10.2023
Hajmi7.3 Mb.
#1728481
1   ...   78   79   80   81   82   83   84   85   ...   115
Bog'liq
linuxbasicsforhackers

76
Chapter 7
kali >export PS1='C:\w> '
kali >cd /tmp
C:/tmp>
Listing 7-2: Changing the prompt and showing the current directory
Having your prompt show your current directory can be generally 
useful, particularly to a beginner, so it’s something to consider when you 
change your 
PS1
variable.
Changing Your PATH
One of the most important variables in your environment is your 
PATH
vari-
able, which controls where on your system your shell will look for commands 
you enter, such as 
grep

ls
, and 
echo
. Most commands are located in the sbin 
or bin subdirectory, like /usr/local/sbin or /usr/local/bin. If the bash shell 
doesn’t find the command in one of the directories in your 
PATH
variable, it 
will return the error 
command not found
, even if that command does exist in a 
directory not in your 
PATH
.
You can find out which directories are stored in your 
PATH
variable by 
using 
echo
on its contents, like so:
kali >echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
These are the directories where your terminal will search for any com-
mand. When you enter 
ls
, for example, the system knows to look in each 
of these directories for the 
ls
command, and when it finds 
ls
, the system 
executes it.
Each directory is separated by a colon (
:
). Don’t forget to add the 
$
content symbol to 
PATH
. When we put a 
$
before a variable, we are asking the 
system for the content of the variable.
Adding to the PATH Variable
You can probably see why it’s important to know what is in your PATH vari-
able: if you downloaded and installed a new tool—let’s say 
newhackingtool

into the /root/newhackingtool directory, you could only use commands from 
that tool when you’re in that directory because that directory is not in the 
PATH
variable. Every time you wanted to use that tool, you would first have to 
navigate to /root/newhackingtool, which is a bit inconvenient if you want to 
use the tool often.
To be able to use this new tool from any directory, you need to add the 
directory holding this tool to your 
PATH
variable.
To add newhackingtool to your 
PATH
variable, enter the following:
kali >PATH=$PATH:/root/newhackingtool


Managing User Environment Variables
77
This assigns the original 
PATH
variable plus the /root/newhackingtool 
directory to the new 
PATH
variable, so the variable contains everything it did 
before, plus the new tool directory.
If you examine the contents of the 
PATH
variable again, you should see 
that this directory has been appended to the end of 
PATH
, as shown here:
kali >echo $PATH
/usr/local/sbin:usr/local/bin:/usr/sbin:/sbin/bin:/root/newhackingtool
Now you can execute 
newhackingtool
applications from anywhere on 
your system, rather than having to navigate to its directory. The bash shell 
will look in all directories listed for your new tool!
N O T E
 
Adding to 
PATH
 can be a useful technique for directories you use often, but be careful 
not to add too many directories to your 
PATH
 variable. Because the system will have to 
search through each and every directory in 
PATH
 to find commands, adding a lot of 
directories could slow down your terminal and your hacking.

Download 7.3 Mb.

Do'stlaringiz bilan baham:
1   ...   78   79   80   81   82   83   84   85   ...   115




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling