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 6472425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:20:35+00:00 2026-05-25T06:20:35+00:00

I am writing an installation script, and would like it to install in a

  • 0

I am writing an installation script, and would like it to install in a local directory if the user does not have root access.

specifically, I am looking for the code that goes between the carats (<>)

if [[<do I have root access? = TRUE>]]; then
    .. install .. 
else
    .. install  in $HOME/mylib .. 
fi
  • 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. Editorial Team
    Editorial Team
    2026-05-25T06:20:36+00:00Added an answer on May 25, 2026 at 6:20 am

    For bash, you can use the EUID variable:

    if [ "$EUID" == 0 ] ; then
        ..something..
    else
        ..something else
    fi
    

    For a POSIX-compliant solution, use:

    if [ "`id -u`" == 0 ] ; then
    

    Although be aware that the usual answer to your question is “don’t do that”. You never know when someone will decide to run your code in an environment you did not expect… So in general, instead of “check permissions then do something”, a better approach is “try to do something and then detect if it fails”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application throws 'Access denied' errors when writing temporary files in the installation directory
I am currently writing a script that will basically ‘install’ a codeigniter installation automatically.
I am writing installation script for my program, which is supposed to run on
Let's say I am writing installation script for the program which contains executable file
I have a quite simple perl script, that in one function does the following:
I'm writing a Perl script that does date operations that need to take holidays
I am writing a post-install script for Ubuntu in Perl (same script as seen
In a small application, I'm writing, during installation phase, the user must enter detail
Situation:- I have created a installation setup(local) that returns a URL eg:- ved.test.com which
I am not a Unix guy, so I have been trying to install openCV

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.