Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 168949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:32:37+00:00 2026-05-11T12:32:37+00:00

It is not totally rigth that I can run a Bash function with 000

  • 0

It is not totally rigth that I can run a Bash function with 000 permissions, but almost. My code is:

#!/bin/bash function hello { echo Hello! } 

The hello-file has permissions:

-r--------  1 UnixBasics hello_file 

Firtsly, I type with the current permissions:

$ . ./hello_file;hello 

The tweak is to change the 400 permissions to 000 right before running the bash script script:

$ chmod 000 hello_file $ . ./hello_file;hello                                             [1] -bash: ./hello_file: Permission denied  Hello! 

It gives one error, but it does not stop running the function. I cannot understand. I now unset the hello-function: ‘unset hello’. I receive the errors:

-bash: ./hello_file: Permission denied -bash: hello: command not found 

Why did I not get them at the first time? Has it something to do with cache, buffer or something like it? Why can I run the Bash script with 000 permissions [1]?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:32:38+00:00Added an answer on May 11, 2026 at 12:32 pm

    You are not running the script, you are sourcing (including) it. In order to source a script, you only need the read permission.

    By the way, functions simply exist, they don’t have permission. Once the file was sourced and the function defined, you can run it as much as you want.


    Update:

    Why did I not get them at the first time? Has it something to do with cache, buffer or something like it?

    Yes, like Pax answered, hello was probably previously defined there from a previous sourcing of the file. You may be confused with what sourcing (‘.’ builtin command) does. Sourcing reads the file and runs all its commands in the current shell, then goes back to the prompt. So, if you run the file once, its functions are defined in the current shell instance, and they stay there until you finish that shell session (or unset them).

    Why can I run the Bash script with 000 permissions [1]?

    You can’t. Note that it presents an error. Quoting your output:

    $ . ./hello_file;hello                                             [1] -bash: ./hello_file: Permission denied  Hello! 

    You executed two commands in a single command-line. The sourcing failed with ‘Permission denied’. The ‘Hello!’ output is from a previous sourcing of the file. You just proved it yourself when you unset it and tried the same command-line again.

    You can’t call that caching… it is how the shell works. You source another file, all its definitions are included in the current shell session and stay there. If you actually run the script (not sourcing) you shouldn’t get any residues in the current session.

    $ chmod +x hello_file $ ./hello_file           # note: executed, not sourced $ hello -bash: hello: command not found 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 95k
  • Answers 95k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Just about any application can be "analysed and injected". Some… May 11, 2026 at 7:03 pm
  • Editorial Team
    Editorial Team added an answer Problem solved. Our build is actually dependent on jdk 1.4.2,… May 11, 2026 at 7:03 pm
  • Editorial Team
    Editorial Team added an answer You want to read up on ostringstream: #include <sstream> #include… May 11, 2026 at 7:03 pm

Related Questions

Everyone remembers google browser sync right? I thought it was great. Unfortunately Google decided
I'm building an app that authors would (hopefully) use to help them, uh.. author
After, reading and understanding Dan Benjamin's post about installing Ruby, Rails, etc. on OSX
I've got a (SQL Server 2005) database where I'd like to create views on-the-fly.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.