• Running HelloHackersArise To run our simple script, enter the following: kali > ./HelloHackersArise
  • 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
    bet96/125
    Sana14.05.2024
    Hajmi7,3 Mb.
    #232858
    1   ...   92   93   94   95   96   97   98   99   ...   125
    Bog'liq
    linuxbasicsforhackers

    Setting Execute Permissions
    By default, a newly created bash script is not executable even by you, the 
    owner. Let’s look at the permissions on our new file in the command line by 
    using 
    cd
    to move into the directory and then entering 
    ls -l
    . It should look 
    something like this:
    kali >
    ls -l
    --
    snip
    --
    -rw-r--r-- 1 root root 90 Oct 22 14:32 HelloHackersArise
    --
    snip
    --
    As you can see, our new file has 
    rw-r--r--
    (644) permissions. As you 
    learned in Chapter 5, this means the owner of this file only has read (
    r

    and write (
    w
    ) permissions, but no execute (
    x
    ) permissions. The group and 
    all other users have only read permissions. We need to give ourselves exe-
    cute permissions in order to run this script. We change the permissions 
    with the 
    chmod
    command, as you saw in Chapter 5. To give the owner, the 
    group, and all others execute permissions, enter the following:
    kali >
    chmod 755 HelloHackersArise


    84
    Chapter 8
    Now when we do a long listing on the file, like so, we can see that we 
    have execute permissions:
    kali >
    ls -l
    --
    snip
    --
    -rwx r-x r-x 1 root root 42 Oct 22 14:32 HelloHackersArise
    --
    snip
    --
    The file will also be in green, another indicator of its execute permis-
    sions. The script is now ready to run!
    Running HelloHackersArise
    To run our simple script, enter the following:
    kali >
    ./HelloHackersArise
    The 
    ./
    before the filename tells the system that we want to execute 
    this script in the file HelloHackersArise from the current directory. It also 
    tells the system that if there is another file in another directory named 
    HelloHackersArise, please ignore it and only run HelloHackersArise in the cur-
    rent directory. It may seem unlikely that there’s another file with this name 
    on your system, but it’s good practice to use the 
    ./
    when executing files, as 
    this localizes the file execution to the current directory and many directo-
    ries will have duplicate filenames, such as start and setup.
    When we press 
    enter
    , our very simple script returns our message to the 
    monitor:
    Hello, Hackers-Arise!
    Success! You just completed your first shell script!

    Download 7,3 Mb.
    1   ...   92   93   94   95   96   97   98   99   ...   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