Some selinux notes

ls -Z file1
-rwxrw-r-- user1 group1 unconfined_u:object_r:user_home_t:s0 file1
  • SELinux contexts follow the SELinux user:role:type:level syntax.
  • Use the ps -eZ command to view the SELinux context for processes
  • and id -Z for users
  • seinfo -r (part of setools-console): shows all available user roles: such as guest, unconfined, webadm, sysadm, dbadm, etc.

also see /etc/selinux/targeted/context/users

JConsole over SSH with SOCKS Proxy

This is from here: Create the SSH socks proxy locally on some free port (e.g. 7777):

ssh -fN -D 7777 user@firewalled-host

Run JConsole by specifying the SOCKS proxy (e.g. localhost:7777) and the address for the JMX server (e.g. localhost:2147)

jconsole -J-DsocksProxyHost=localhost \
  -J-DsocksProxyPort=7777 \
  service:jmx:rmi:///jndi/rmi://localhost:2147/jmxrmi \
  -J-DsocksNonProxyHosts=

Some curl tips

  • Show headers with -I and change request type with -X. e.g.
curl -I -X DELETE  http://localhost/blah
  • To add a header in the outgoing request, use -H:
curl --header "X-MyHeader: 123" www.google.com
  • Follow redirects with -l
  • Disable security check with -k
  • Send content with -d:
curl -X POST --header "Content-Type: application/json" -d '{"test": true}' http://localhost/blah

Date filters for the Linux find command

  • find . -ctime -3 # created in the past 3 days
  • find . -ctime +3 # older than 3 days
  • find . -ctime 3 # created exactly 3 days back
  • find . -ctime +3 -ctime -5 # created 3 – 5 days back
  • find . -newer /tmp/somefile # see somefile’s timestamp and show files newer than it
  • works great in conjunction with:
  • touch 0607090016 /tmp/somefile #i.e. 7th june, 9:00 am, 2016
  • find . -maxdepth 1 -type d -ctime +38 -exec rm -rf {} \; delete all folders older than 38 days back.
  • don’t use atime much: every directory access changes its atime, so when find traverses through it, the inode’s atime entry gets updated.

GNU Screen & Tmux notes

GNU/Screen splitting windows

  • C-a V or C-a | split the screen vertically
  • C-a X remove/detach the current split
  • C-a S split horizontally
  • C-a tab cycle between windows

Tmux keybindings

  • Ctrl-b % (Split the window vertically)
  • Ctrl-b : “split-window” (Split window horizontally)
  • Ctrl-b o (Goto next pane)
  • Ctrl-b q (Show pane numbers, when the numbers show up type the key to goto that pane)
  • Ctrl-b { (Move the current pane left)
  • Ctrl-b } (Move the current pane right)

And here’s my .tmux.conf

set -g prefix C-a
unbind C-b
bind C-a send-prefix

set -g default-terminal "xterm-256color"

set -g history-limit 10000
set -g set-titles-string "#T"

unbind %
bind | split-window -h
bind - split-window -v