Prevent a directory in /tmp from being deletedParitioning Scheme: Arch Linux server & laptopWhat are correct permissions for /tmp ? I unintentionally set it all public recursivelyWhat can go wrong if /var/tmp is on a temporary filesystem?Small RAM-based /tmpDo Links to /tmp files get deleted?Moving /tmp folder to different location. Problems with /tmp not being emptiedFolder in /tmp won't delete despite the computer being restartedis /tmp guaranteed to exist?tmp directory for development that gets cleared regularly?When are files from /tmp deleted?

How can I make my BBEG immortal short of making them a Lich or Vampire?

What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)

How do you know if an analog film camera is still working?

Japan - Plan around max visa duration

Modeling an IPv4 Address

Service Entrance Breakers Rain Shield

Dragon forelimb placement

can i play a electric guitar through a bass amp?

In Japanese, what’s the difference between “Tonari ni” (となりに) and “Tsugi” (つぎ)? When would you use one over the other?

Email Account under attack (really) - anything I can do?

Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?

Can a German sentence have two subjects?

Is the month field really deprecated?

How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?

How is it possible to have an ability score that is less than 3?

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

Why not use SQL instead of GraphQL?

strToHex ( string to its hex representation as string)

What is the offset in a seaplane's hull?

Approximately how much travel time was saved by the opening of the Suez Canal in 1869?

Type 1 Error & Type 2 Error's pregnancy test analogy: is it legit?

Shell script not opening as desktop application

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

Creating a document with mixed languages



Prevent a directory in /tmp from being deleted


Paritioning Scheme: Arch Linux server & laptopWhat are correct permissions for /tmp ? I unintentionally set it all public recursivelyWhat can go wrong if /var/tmp is on a temporary filesystem?Small RAM-based /tmpDo Links to /tmp files get deleted?Moving /tmp folder to different location. Problems with /tmp not being emptiedFolder in /tmp won't delete despite the computer being restartedis /tmp guaranteed to exist?tmp directory for development that gets cleared regularly?When are files from /tmp deleted?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I often use the /tmp directory on my Linux machine for storing temporary files (e.g. PDFs from a site that wants me to download it first etc.) and I often create a directory with my username. But at every startup it (including all files) gets deleted. Now I know I can put it in /var/tmp, but I want all its contents to be deleted, but for the directory itself to be kept.
So:



tmp
|- me # this should stay
| |- foo1 # this should be deleted...
| |- bar1 # ...and this as well
|- other stuff...


Is there any way to do this? Maybe with permissions or with a special configuration?










share|improve this question









New contributor




Linux4win is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • As a workaround, you might put some code into your shell's login files to "test & mkdir" as needed.

    – Jeff Schaller
    1 hour ago






  • 1





    If the files are not temporary, don't store them under /tmp. If you want, create a $HOME/tmp directory and store them there instead.

    – Kusalananda
    1 hour ago

















2















I often use the /tmp directory on my Linux machine for storing temporary files (e.g. PDFs from a site that wants me to download it first etc.) and I often create a directory with my username. But at every startup it (including all files) gets deleted. Now I know I can put it in /var/tmp, but I want all its contents to be deleted, but for the directory itself to be kept.
So:



tmp
|- me # this should stay
| |- foo1 # this should be deleted...
| |- bar1 # ...and this as well
|- other stuff...


Is there any way to do this? Maybe with permissions or with a special configuration?










share|improve this question









New contributor




Linux4win is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • As a workaround, you might put some code into your shell's login files to "test & mkdir" as needed.

    – Jeff Schaller
    1 hour ago






  • 1





    If the files are not temporary, don't store them under /tmp. If you want, create a $HOME/tmp directory and store them there instead.

    – Kusalananda
    1 hour ago













2












2








2


1






I often use the /tmp directory on my Linux machine for storing temporary files (e.g. PDFs from a site that wants me to download it first etc.) and I often create a directory with my username. But at every startup it (including all files) gets deleted. Now I know I can put it in /var/tmp, but I want all its contents to be deleted, but for the directory itself to be kept.
So:



tmp
|- me # this should stay
| |- foo1 # this should be deleted...
| |- bar1 # ...and this as well
|- other stuff...


Is there any way to do this? Maybe with permissions or with a special configuration?










share|improve this question









New contributor




Linux4win is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I often use the /tmp directory on my Linux machine for storing temporary files (e.g. PDFs from a site that wants me to download it first etc.) and I often create a directory with my username. But at every startup it (including all files) gets deleted. Now I know I can put it in /var/tmp, but I want all its contents to be deleted, but for the directory itself to be kept.
So:



tmp
|- me # this should stay
| |- foo1 # this should be deleted...
| |- bar1 # ...and this as well
|- other stuff...


Is there any way to do this? Maybe with permissions or with a special configuration?







tmp






share|improve this question









New contributor




Linux4win is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Linux4win is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 25 mins ago









ctrl-alt-delor

12.4k52661




12.4k52661






New contributor




Linux4win is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 hours ago









Linux4winLinux4win

112




112




New contributor




Linux4win is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Linux4win is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Linux4win is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • As a workaround, you might put some code into your shell's login files to "test & mkdir" as needed.

    – Jeff Schaller
    1 hour ago






  • 1





    If the files are not temporary, don't store them under /tmp. If you want, create a $HOME/tmp directory and store them there instead.

    – Kusalananda
    1 hour ago

















  • As a workaround, you might put some code into your shell's login files to "test & mkdir" as needed.

    – Jeff Schaller
    1 hour ago






  • 1





    If the files are not temporary, don't store them under /tmp. If you want, create a $HOME/tmp directory and store them there instead.

    – Kusalananda
    1 hour ago
















As a workaround, you might put some code into your shell's login files to "test & mkdir" as needed.

– Jeff Schaller
1 hour ago





As a workaround, you might put some code into your shell's login files to "test & mkdir" as needed.

– Jeff Schaller
1 hour ago




1




1





If the files are not temporary, don't store them under /tmp. If you want, create a $HOME/tmp directory and store them there instead.

– Kusalananda
1 hour ago





If the files are not temporary, don't store them under /tmp. If you want, create a $HOME/tmp directory and store them there instead.

– Kusalananda
1 hour ago










2 Answers
2






active

oldest

votes


















4














I use pam-tmpdir for this: it creates a user-private temporary directory at login. To set it up, add



session optional pam_tmpdir.so


to the appropriate PAM services; the next time you log in, you’ll find a directory under /tmp/user with your user id, and TMP and TMPDIR set appropriately.






share|improve this answer























  • Could you explain what the appropriate PAM services are and how the line can be added to them? What files should be edited?

    – terdon
    31 mins ago


















1














One solution would be to use a @reboot cron job:



@reboot mkdir -p "/tmp/$USER"


Adding this to your crontab with crontab -e would make it execute whenever the machine boots up.



Or, use



mkdir -p "/tmp/$USER"


in your shell's startup file.



In either case, you may also want to use



TMPDIR=/tmp/$USER
export TMPDIR


in your shell's startup file if you want to use that directory as the default temporary directory.






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Linux4win is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511029%2fprevent-a-directory-in-tmp-from-being-deleted%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    I use pam-tmpdir for this: it creates a user-private temporary directory at login. To set it up, add



    session optional pam_tmpdir.so


    to the appropriate PAM services; the next time you log in, you’ll find a directory under /tmp/user with your user id, and TMP and TMPDIR set appropriately.






    share|improve this answer























    • Could you explain what the appropriate PAM services are and how the line can be added to them? What files should be edited?

      – terdon
      31 mins ago















    4














    I use pam-tmpdir for this: it creates a user-private temporary directory at login. To set it up, add



    session optional pam_tmpdir.so


    to the appropriate PAM services; the next time you log in, you’ll find a directory under /tmp/user with your user id, and TMP and TMPDIR set appropriately.






    share|improve this answer























    • Could you explain what the appropriate PAM services are and how the line can be added to them? What files should be edited?

      – terdon
      31 mins ago













    4












    4








    4







    I use pam-tmpdir for this: it creates a user-private temporary directory at login. To set it up, add



    session optional pam_tmpdir.so


    to the appropriate PAM services; the next time you log in, you’ll find a directory under /tmp/user with your user id, and TMP and TMPDIR set appropriately.






    share|improve this answer













    I use pam-tmpdir for this: it creates a user-private temporary directory at login. To set it up, add



    session optional pam_tmpdir.so


    to the appropriate PAM services; the next time you log in, you’ll find a directory under /tmp/user with your user id, and TMP and TMPDIR set appropriately.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 1 hour ago









    Stephen KittStephen Kitt

    180k25409487




    180k25409487












    • Could you explain what the appropriate PAM services are and how the line can be added to them? What files should be edited?

      – terdon
      31 mins ago

















    • Could you explain what the appropriate PAM services are and how the line can be added to them? What files should be edited?

      – terdon
      31 mins ago
















    Could you explain what the appropriate PAM services are and how the line can be added to them? What files should be edited?

    – terdon
    31 mins ago





    Could you explain what the appropriate PAM services are and how the line can be added to them? What files should be edited?

    – terdon
    31 mins ago













    1














    One solution would be to use a @reboot cron job:



    @reboot mkdir -p "/tmp/$USER"


    Adding this to your crontab with crontab -e would make it execute whenever the machine boots up.



    Or, use



    mkdir -p "/tmp/$USER"


    in your shell's startup file.



    In either case, you may also want to use



    TMPDIR=/tmp/$USER
    export TMPDIR


    in your shell's startup file if you want to use that directory as the default temporary directory.






    share|improve this answer



























      1














      One solution would be to use a @reboot cron job:



      @reboot mkdir -p "/tmp/$USER"


      Adding this to your crontab with crontab -e would make it execute whenever the machine boots up.



      Or, use



      mkdir -p "/tmp/$USER"


      in your shell's startup file.



      In either case, you may also want to use



      TMPDIR=/tmp/$USER
      export TMPDIR


      in your shell's startup file if you want to use that directory as the default temporary directory.






      share|improve this answer

























        1












        1








        1







        One solution would be to use a @reboot cron job:



        @reboot mkdir -p "/tmp/$USER"


        Adding this to your crontab with crontab -e would make it execute whenever the machine boots up.



        Or, use



        mkdir -p "/tmp/$USER"


        in your shell's startup file.



        In either case, you may also want to use



        TMPDIR=/tmp/$USER
        export TMPDIR


        in your shell's startup file if you want to use that directory as the default temporary directory.






        share|improve this answer













        One solution would be to use a @reboot cron job:



        @reboot mkdir -p "/tmp/$USER"


        Adding this to your crontab with crontab -e would make it execute whenever the machine boots up.



        Or, use



        mkdir -p "/tmp/$USER"


        in your shell's startup file.



        In either case, you may also want to use



        TMPDIR=/tmp/$USER
        export TMPDIR


        in your shell's startup file if you want to use that directory as the default temporary directory.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 41 mins ago









        KusalanandaKusalananda

        140k17261435




        140k17261435




















            Linux4win is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Linux4win is a new contributor. Be nice, and check out our Code of Conduct.












            Linux4win is a new contributor. Be nice, and check out our Code of Conduct.











            Linux4win is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511029%2fprevent-a-directory-in-tmp-from-being-deleted%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480