This is definitely something useful!
How to attach timestamps to the history of the bash commands?
Simple: just set (in the way you like to have your time format) the bash variable HISTTIMEFORMAT
For example to have the format: day/month/year - hours:minutes:seconds" type this:
export HISTTIMEFORMAT="%d/%m/%y - %H:%M:%S: "
and then just run history
That's it!
Source
stackoverflow
My Tips and Tricks for C#, C, C++, MatLAB, Java, LaTeX, Python and more!
Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts
Saturday, October 15, 2016
Saturday, July 16, 2016
How to change bash prompt to red when you are root
To change your bash shell prompt to red when you became root, do the following:
- login as root
- vi ~/.bashrc
- add the this line: export PS1='\[\e[31m\][root]\[\e[0m\] \W\$'
Friday, April 29, 2016
Bash: How to change recursively owner and group of files and dirs
Sometimes comes in hand to change recursively the owner and group for files in a directory. How to do this in bash?
With this command:
For example to change from root to foo of foogroup in the folder /var/lol use the command:
With this command:
find /starting/path -user "original_owner" -exec chown someuser:somegroup {} +
You can omit ":somegroup" if you don't want to change the group of the files/folderFor example to change from root to foo of foogroup in the folder /var/lol use the command:
find /var/lol -user "root" -exec chown foo:foogroup {} +
NOTE: You must be root to change the ownership of a root-owned file!
Source
superuser
Subscribe to:
Posts (Atom)