Random Notes

Table of Contents

Sublime plugins for markdown:

https://github.com/jonschlinkert/sublime-monokai-extended
https://github.com/jonschlinkert/sublime-markdown-extended
https://github.com/math2001/MarkdownLivePreview

RHEL 7 Password reset

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sec-Terminal_Menu_Editing_During_Boot#proc-Resetting_the_Root_Password_Using_rd.break

Test if ssh is setup on host

ssh -q -o "BatchMode=yes" server01 "echo 2>&1" && echo $host SSH_OK || echo $host SSH_NOK

Backend shortcut keys to enable

echo '### Terminal Shortcuts Original file is in /etc/inputrc
"\C-p":previous-history
"\C-n":next-history
"\C-a":beginning-of-line
"\C-e":end-of-line
"\C-l":clear-screen' >> ~/.inputrc &&
cat ~/.inputrc && bash

Curl from sftp

curl -k "sftp://company.com/myfile.txt" --user "<username>" -o /root/myfile.txt

Curl for ftp

curl -u <username> 'ftp://company.com/myfile.txt' -o /root/myfile.txt

Check for stuck deleted files

lsof -nP +L1

cut something out with delimiter ( example delimiter:)

cat file.txt | cut -d: -f2  # cuts all but field 2 or -f2- cuts only fields before 2

Vim Align all columns

%!column -t
or do in visual mode then just :'<,'>!column -t  (<> will appear auto)

Vim fix pasting open .vimrc

let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"

inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()

function! XTermPasteBegin()
  set pastetoggle=<Esc>[201~
  set paste
  return ""
endfunction

Check for immutable flag on files

lsattr -R | grep +i

View network interfaces

ip addr

show established connection on tcp/ip with ports

ss -tan

show eth interface statistics

ip -s link show <interface>

lookup how system looks at hosts info ( networking dns etc)

getent hosts <hostname>

View system journal logs

journalctl

To Install xsosx

curl -Lo /usr/local/bin/xsos bit.ly/xsos-direct
chmod +x /usr/local/bin/xsos

Boot DB in restricted mode

Shutdown immediate;
Startup restrict;

LIST ALL FILESYSTEMS ABOVE 80%

df -Ph | awk '0+$5 >= 80 {print}'

SCP A FILE WHEN THERE IS NO RSA KEY

/usr/bin/scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null file1.txt root@nodename:/tmp

LIST ALL FILES IN DIRECTORY AND SORT BY SIZE

du -hs * | sort -h

rhel 7+ tmux 1.8 config

# rhel 7+ tmux 1.8 config
# config file location > ~/.tmux.conf

# Make mouse useful in copy mode
setw -g mode-mouse on

# Allow mouse to select which pane to use
set -g mouse-select-pane on

# Allow xterm titles in terminal window, terminal scrolling with scrollbar
set -g default-terminal "xterm-256color"
set -g xterm-keys on
set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:"

# Scroll History
set -g history-limit 30000

# Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access.
set -s escape-time 50

CHECK SQL TABLESPACE SIZE 1st number current size 2nd will extend to size

select file_name, bytes/1024/1024/1024, maxbytes/1024/1024/1024 from dba_data_files where tablespace_name='DATA';
select file_name, bytes/1024/1024/1024, maxbytes/1024/1024/1024 from dba_data_files where tablespace_name='DATA';

To test if sql can write to a file on backend

declare
  f utl_file.file_type;
begin
  f := utl_file.fopen ('TEST', 'test.txt', 'w');
  utl_file.put_line(f, 'test');
  utl_file.fclose(f);
end;
/

List all *.c file accessed 30 days ago

find / -iname "*.c" -atime -30 -type f -ls

To see all files accessed on the 25/Sep/2017

find . -type f -newerat 2017-09-25 ! -newerat 2017-09-26 -ls

-newerXY option for find command

find /dir/ -type f -newerXY 'yyyy-mm-dd'
find /dir/ -type f -newerXY 'yyyy-mm-dd' -ls

newer options see above newerat = a t options
a – The access time of the file reference
B – The birth time of the file reference
c – The inode status change time of reference
m – The modification time of the file reference
t – reference is interpreted directly as a time

find and remove files

find /directory/ -type f -mtime +7 -exec rm -f {} \; -print
find / -maxdepth 1 -type f -mtime +1 -mtime -31 -name 'emar*.pdf' -ls -exec rm {} \;
Julius Sidabras avatar
Julius Sidabras
Julius Sidabras's true identity is unknown. Maybe he is a successful blogger or writer.