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

  • SEARCH
  • Home
  • 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 231493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:56:15+00:00 2026-05-11T19:56:15+00:00

I have a script which is running as root, it’s supposed to store it’s

  • 0

I have a script which is running as root, it’s supposed to store it’s cache file (only modified by the script) at /var/lib/varlibfile. However the script does not seem to create the file, and my investigation led me to this:

$ sudo echo "something" >/var/lib/varlibfile
bash: /var/lib/varlibfile: Permission denied
$ sudo echo "something" >varlibfile
$ sudo cp varlibfile /var/lib/

In other words, I am able to create a file called varlibfile at /var/lib, but I’m not allowed to create it using redirection. Only file copy works. It seems very strange to me and I would like to use redirection directly to the intended file instead of creating it somewhere else and then copying it.

Some extra information:

$ ls -ld /var
drwxr-xr-x 14 root root 4096 2009-03-02 14:47 /var
$ ls -ld /var/lib
drwxr-xr-x 51 root root 4096 2009-05-16 19:25 /var/lib
$ ls -la /var/lib/ | head
total 204
drwxr-xr-x  51 root          root          4096 2009-05-16 19:25 .
drwxr-xr-x  14 root          root          4096 2009-03-02 14:47 ..
drwxr-xr-x   2 root          root          4096 2009-03-02 14:22 acpi-support
drwxr-xr-x   2 root          root          4096 2009-03-02 14:39 alsa
drwxr-xr-x   2 root          root          4096 2009-05-14 14:42 apparmor
drwxr-xr-x   6 root          root          4096 2009-05-14 14:42 apt
drwxr-xr-x   2 root          root          4096 2008-04-04 11:56 aptitude
drwxr-xr-x   2 root          root          4096 2008-07-02 12:58 aspell
drwxr-xr-x   2 avahi-autoipd avahi-autoipd 4096 2009-03-05 16:42 avahi-autoipd

Can anyone explain why this is happening? And how to solve the problem, ideally I want to write /var/lib/varfile directly without any previous creation at another location.

  • 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-11T19:56:15+00:00Added an answer on May 11, 2026 at 7:56 pm

    What

    $ sudo echo something >/var/lib/varlibfile
    

    does, is pipe the output of “sudo echo something” to the file. So the file write operation is done as the current user, who doesn’t have permission to write in /var/lib.

    Try something like

    $ sudo sh -c "echo something >/var/lib/varlibfile"  
    

    or

    $ echo something | sudo tee /var/lib/varlibfile
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 115k
  • Answers 115k
  • 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 Use an item event receiver and override the ItemAdded event.… May 11, 2026 at 10:20 pm
  • Editorial Team
    Editorial Team added an answer You could also consider creating custom Membership Provider. May 11, 2026 at 10:20 pm
  • Editorial Team
    Editorial Team added an answer If I remember correctly, Response.Redirect() throws an exception to abort… May 11, 2026 at 10:20 pm

Related Questions

I'm developing on a Ubuntu 8.04 machine using Eclipse Ganymede. I installed Tomcat 5.5
I'm building a python application from some source code I've found Here I've managed
I have a script which will be run interactively by non-technical users. The script
I have written a script that gets data from solr for which date is
I have a web application written using CherryPy, which is run locally on 127.0.0.1:4321

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.