---System Utilities and Tweaks---
time for i in {1..100}; do ./customprompt.sh; done; ##run globalbash.sh 100 times and show total time, quick and dirty benchmark
alias commands='vim /home/user/Documents/commands' ##creates an alias for 'commands', by entering 'commands' in bash terminal it will open the file /home/user/Documents/commands with vim, copy code into /etc/profile.d/foobar.sh
PS1="\n[\e[30;1m][[\e[34;1m]\u@\h[\e[30;1m]]-[[\e[34;1m]\j[\e[30;1m]]-[[[\e[32;1m]\w[\e[30;1m]][\e[30;1m]\n-[[\e[32;1m]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | / bin/sed 's/total //')b[\e[30;1m]][\e[0;31m]\$[\e[0;37m] " ##create custom bash prompt $, create foo.sh and copy above code and place in /etc/profile.d directory
echo -n "◀" | hexdump ##this will output UTF-8 hexcode: '97e2 0080', bash format for this character is $'\xE2\x97\x80'
shopt -s nocaseglob ##turn off upper and lower case matching, with this command it will match either when you are changing directories
compgen -c ##show all the commands that can be run
compgen -a ##show all the command aliases
!! ##repeat last command you executed
!!:p ##print the last command you executed
!?mysql?:p ##print last command that contains 'mysql', omit the '?:p' to execute that command
history | awk 'BEGIN {FS="[ \t]+|\|"} {print $3}' | sort | uniq -c | sort -nr | head ##show 10 commands most often used, sorted most to least
uptime ##show system uptime
lspci ##show pci bus hardware
lsblk ##show all hard drives and drive paths
free -h ##show RAM usage, -h human readable format
cat /sys/class/block/sda/device/model ##show model manufacturer for drive 'sda'
cat /proc/cpuinfo ##show processor info
uname -a ##show kernel version
cat /etc/redhat-release ##show Centos/RHEL version
echo -n password | sha256sum | awk '{print $1}' ##pipe 'password' through 'sha256sum' to encrpyt a password with SHA-256, 'awk' strips extraneous characters. 'sha256sum' can be 'sha[1,224,256,384,512]sum'
tar -zxvf bar.tar.gz -C /you/are/foo/bar ##decompress bar.tar.gz file to directory bar
tar -zcvf bar.tar.gz /you/are/foo/bar ##compress 'bar' directory to bar.tar.gz
vim /etc/inputrc ##Add 'Tab: menu-complete' for better tab completion in bash, don't forget to run 'exec bash' after the file is edited
######################################################## ###---Multiple Bash Sessions, Use One History File---### ########################################################
shopt -s histappend # The following line ensures that history logs screen commands as well
PROMPT_COMMAND="$PROMPT_COMMAND;history -a; history -n" # This line makes the history file to be rewritten and reread at each bash prompt
Have lots of history
HISTSIZE=100000 # remember the last 100000 commands HISTFILESIZE=100000 # start truncating commands after 100000 lines HISTCONTROL=ignoreboth # ignoreboth is shorthand for ignorespace and ignoredups