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;
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
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.
add a comment |
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
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/tmpdirectory and store them there instead.
– Kusalananda♦
1 hour ago
add a comment |
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
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
tmp
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.
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/tmpdirectory and store them there instead.
– Kusalananda♦
1 hour ago
add a comment |
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/tmpdirectory 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
add a comment |
2 Answers
2
active
oldest
votes
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.
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
add a comment |
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.
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered 41 mins ago
Kusalananda♦Kusalananda
140k17261435
140k17261435
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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/tmpdirectory and store them there instead.– Kusalananda♦
1 hour ago