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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:46:45+00:00 2026-06-15T05:46:45+00:00

I am carrying out performance tests on a system where I need to ensure

  • 0

I am carrying out performance tests on a system where I need to ensure I am reading data from the disk, and that it is not just cached (say from earlier tests). I read here that I can drop cache with the command

echo 3 | sudo tee /proc/sys/vm/drop_caches

However, note that even though my account is an admin account (login peter), it still requires my password. I want to be able to run this in a batch script without the requirement to input a password (as this is obviously manual)

More research led me to the sudoers file. My plan was to place the above command into a one line script called dropCache, and edit sudoers so that I could run it without entering a password. So I added the line

ALL ALL=(ALL)NOPASSWD:/home/peter/dropCache

at the end of my sudoers file (using visudo). With my admin account, if I run

sudo -l 

I get

(ALL) NOPASSWD: /home/peter/dropCache

However, if I run my dropCache script I still get asked for my password

./dropCache
[sudo] password for peter: 

Any help with this would be much appreciated. I am running Ubuntu 12.04

Thanks
Peter

  • 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-06-15T05:46:47+00:00Added an answer on June 15, 2026 at 5:46 am

    What I did when I needed this was I wrote a small C program, changed the owner of the compiled file to root, and set the setuid bit.

    Here is the source code:

    #include <stdlib.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <sys/types.h>
    
    extern void sync(void);
    
    int main(void) {
        if (geteuid() != 0) {
            fprintf(stderr, "flush-cache: Not root\n");
            exit(EXIT_FAILURE);
        }
        printf("Flushing page cache, dentries and inodes...\n");
        // First: the traditional three sync calls. Perhaps not needed?
        // For security reasons, system("sync") is not a good idea.
        sync();
        sync();
        sync();
        FILE* f;
        f = fopen("/proc/sys/vm/drop_caches", "w");
        if (f == NULL) {
            fprintf(stderr, "flush-cache: Couldn't open /proc/sys/vm/drop_caches\n");
            exit(EXIT_FAILURE);
        }
        if (fprintf(f, "3\n") != 2) {
            fprintf(stderr, "flush-cache: Couldn't write 3 to /proc/sys/vm/drop_caches\n");
            exit(EXIT_FAILURE);
        }
        fclose(f);
        printf("Done flushing.\n");
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would you model a system that handles permissions for carrying out certain actions
I have just recently started carrying out unit testing for my software written in
Currently, I'm reading 'Object-Oriented JavaScript'. In addition, I've encountered a hiccup while carrying out
I am carrying out a PDA version application from windows version. But found out
I am just carrying out a query, and have started using parameters. And all
Just learning C++, encountered an issue that i'm not really sure why the following
After carrying out a lot of research I have come to the conclusion that
The first operation will be carrying out several calculations and updating the same tables
String input = txtInput.getText(); char[] charArray = input.toCharArray(); char[] flipArray = null; System.out.println(charArray.length); for
I'm carrying out some experiments in theorem proving with combinator logic, which is looking

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.