« first day (1809 days earlier)      last day (1239 days later) » 

 
5 hours later…
5:45 AM
@Queen k
@astrosixer it's hard to answer question based on only fragments of information, but it sounds like you are running a Docker image which simply does not install extra tools like sudo; Alpine is particularly stripped-down to be as small as possible
anyway, inside Docker you are root anyway, so you normally do not need sudo
it's not clear if you are running these commands in your Dockerfile, in docker-compose.yml, or interactively inside the container (or maybe even outside); perhaps it would be better to post a question on Stack Overflow proper with all these details if you still need help
not really Bash-related anyway, but of course we are usually fine with general shell scripting questions here as well
 
6:04 AM
@astrosixer it's not clear what you mean by "find the user"; if you created a new Docker user, and put in a USER directive in the Dockerfile to run as that user, then that's what Docker will do; the environment variable $USER will generally tell you which user you are running as, though I haven't checked how reliable this is inside a Dockerfile
the id and whoami commands are also useful
 
 
3 hours later…
8:59 AM
@tripleee : kill -HUP on the bash will have it flush the history to the history file but also has the adverse effect to the the shell to exit with "Hanging up" message
Can I signal it with something else to force bash to flush the history in memory to the history file without the shell actually exiting ?
 
really no immediate idea; perhaps you'd have to review the source code to figure that out
 
well I can produce it if you want ?
test@darkstar:~$ ps
PID TTY TIME CMD
1416 pts/1 00:00:00 bash
1427 pts/1 00:00:00 ps
test@darkstar:~$
now from root:
root@darkstar:~# kill -HUP 1416

and this is what I see on the test user terminal:
test@darkstar:~$ ps
PID TTY TIME CMD
1416 pts/1 00:00:00 bash
1427 pts/1 00:00:00 ps
test@darkstar:~$ Hangup
root@darkstar:~#

It quit and went back to root (I did a su - test from root)
 
9:16 AM
oh I mean if there are other signal handlers related to history handling, they are not documented
 
upon better reading what I showed is actually documented
well maybe history built-in should support -u like cron so that you can force -a on someone elses history from root
 
 
4 hours later…
1:28 PM
Hire's what I came up to stop it from happening again (the history thing) ... and to satisfy a user request to change the prompt if a command fails:
#allways append commands immediately to history file
shopt -s histappend
export PROMPT_COMMAND="history -a;$PROMPT_COMMAND"

#to also change the promt color if command exits with error
alias resetps1color="export PS1=\"${PS1/$/'\\'$}\""
alias setps1color="export PS1=\"\e[0;31m${PS1/$/'\\'$}\e[m\""
export PROMPT_COMMAND='[ $? -ne 0 ] && setps1color'"${PROMPT_COMMAND:+";"}${PROMPT_COMMAND}"
 
1:47 PM
and to have the timestamp in the history:
export HISTTIMEFORMAT="%F %T "
 

« first day (1809 days earlier)      last day (1239 days later) »