• MYNEWVARIABLE="Hacking is the most valuable skill set in the 21st century"
  • 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




    Download 7,3 Mb.
    Pdf ko'rish
    bet92/125
    Sana14.05.2024
    Hajmi7,3 Mb.
    #232858
    1   ...   88   89   90   91   92   93   94   95   ...   125
    Bog'liq
    linuxbasicsforhackers

    Creating a User-Defined Variable
    You can create your own custom, user-defined variables in Linux by simply 
    assigning a value to a new variable that you name. This may be useful when 
    you are doing some more advanced shell scripting or find you’re often using 
    a long command that you get tired of typing over and over.


    78
    Chapter 7
    The syntax is straightforward: enter the name of your variable, followed 
    by the assignment symbol (
    =
    ) without a space, and then the value to put in 
    the variable, as shown here:
    kali >
    MYNEWVARIABLE="Hacking is the most valuable skill set in the 21st century"
    This assigns a string to the variable 
    MYNEWVARIABLE
    . To see the value in 
    that variable, use the 
    echo
    command and the 
    $
    content symbol with the vari-
    able name, as we did earlier:
    kali >
    echo $MYNEWVARIABLE
    Hacking is the most valuable skill set in the 21st century
    Just like our system environment variables, user-defined variables must 
    be exported to persist to new sessions.
    If you want to delete this new variable, or any variable, use the 
    unset
    command. Always think before deleting a system variable, though, because 
    your system will probably operate much differently afterward.
    kali >
    unset MYNEWVARIABLE
    kali >
    echo $MYNEWVARIABLE
    kali >
    As you can see, when you enter 
    unset MYNEWVARIABLE
    , you delete the vari-
    able along with its value. If you use 
    echo
    on that same variable, Linux will 
    now return a blank line.
    Summary
    You might find environment variables foreign, but it’s worth getting to know 
    them. They control how your working environment in Linux looks, acts, 
    and feels. You can manage these variables to tailor your environment to 
    your needs by changing them, exporting them, and even creating your own. 
    In some cases, they may be useful for covering your tracks as a hacker.


    Managing User Environment Variables

    Download 7,3 Mb.
    1   ...   88   89   90   91   92   93   94   95   ...   125




    Download 7,3 Mb.
    Pdf ko'rish

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    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

    Download 7,3 Mb.
    Pdf ko'rish