• Changing Your PATH
  • Adding to the PATH Variable
  • Chapter 7 kali > export PS1='C:\w> '




    Download 7,3 Mb.
    Pdf ko'rish
    bet90/125
    Sana14.05.2024
    Hajmi7,3 Mb.
    #232858
    1   ...   86   87   88   89   90   91   92   93   ...   125
    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 >

    Download 7,3 Mb.
    1   ...   86   87   88   89   90   91   92   93   ...   125




    Download 7,3 Mb.
    Pdf ko'rish