-
Notifications
You must be signed in to change notification settings - Fork 0
/
RHEL bash shell Tips
82 lines (67 loc) · 3.04 KB
/
RHEL bash shell Tips
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#bash_profile is run for login shells and bashrc is run for noninteractive login shells i.e not a first time login for a user
#to consolidate configuration into one file instead of two:
#Add the following lines to .bash_profile:
#edit: or simply create a symbolic link :p
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
#command logging
#Have a large history file that never gets deleted
export HISTSIZE=100000 # big big history
export HISTFILESIZE=100000 # big big history
shopt -s histappend # append to history, don't overwrite it
##Change the prompt
PS1="[\d \t \u@\h:\w ] $ "
#how to record terminal session data; include the following in bashrc file (continuation of the above)
if [ -z "$UNDER_SCRIPT" ]; then
logdir=$HOME/terminal-logs
if [ ! -d $logdir ]; then
mkdir $logdir
fi
logfile=$logdir/$(date +%B.%Y).log
export UNDER_SCRIPT=$logfile
script -f -a -q $logfile
exit
fi
#-q:quiet
#-t:include times
#-a:append to file
#and then to make sure that the exit command is provided to the prior script command so that all data does infact get written to file
#trap "exit" SIGHUP SIGINT SIGTERM
#or for login shells: dont forget to put "Exit" in the .bash_logout file (the default config files locates at /etc/skel/.bash_logout) - the exit is what writes to file
'
##Changing the /tmp Cleanup Frequency
The default setting that tells your system to clear /tmp at reboot is held in the /etc/default/rcS file. The value we’ll look at is TMPTIME.
The current value of TMPTIME=0 says delete files at reboot despite the age of the file. Changing this value to a different (positive) number will change the number of days a file can survive in /tmp.
TMPTIME=7
This setting would allow files to stay in /tmp until they are a week old, and then delete them on the next reboot. A negative number (TMPTIME=-1) tells the system to never delete anything in /tmp. This is probably not something you want, but is available.
'
#lastcomm , acct, sa/ sar, iostat, mpstat services
yum install psacct, sysstat
systemctl enbale psacct.service, sysstat
systemctl start psacct.service, sysstat
#get the code from github
yum install git
#git clone htttp://blablabla
#start with the python bootstrapping
#verify python version
python -V
#make sure that python package management is installed
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python get-pip.py
#create a virtual environment
sudo pip install virtualenv
virtualenv [name]
source venv/bin/activate
#to deactivate the virtualenv please use the following commands:
#deactive
#install python packages from requirements files
sudo pip install -r ./requirements.txt
#to view all the packages installed by pip
#only works inside the python interpreter
sorted(["%s==%s" % (i.key, i.version) for i in pip.get_installed_distributions()])
#or pip list/pip freeze
#find out cpu usage statistics
#ps -eo pcpu,pid,user,args | sort -r -k1 | less
##USEFUL COMMANDS
lsof #see processes which may be locking a certain file