Category Archives: Linux

ArchLinux – LXDE

#Install LXDE:

pacman -S openbox lxde gamin dbus   #Lxde and needed dependancies
pacman -S xorg-server xorg-xinit xorg-server-utils   #Xorg
pacman -S mesa xf86-video-fbdev xf86-video-vesa   #Video Drivers
#To use startx, you will need to define LXDE in your ~/.xinitrc file:
echo “exec ck-launch-session startlxde” >> ~/.xinitrc

autologin & autostart LXDE

cp /usr/lib/systemd/system/getty@.service /etc/systemd/system/autologin@.service

Then in /etc/systemd/system/autologin@.service add your login insted of USER:

ExecStart=-/sbin/agetty --noclear -a USER %I 38400

Then:

# systemctl daemon-reload
# systemctl disable getty@tty1
# systemctl enable autologin@tty1
# systemctl start autologin@tty1

Then:

cp /etc/skel/.bash_profile ~/.bash_profile

And then in this file add:

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx

Git repository setup

# Git global setup
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
# Create Repository
mkdir django_kbc_sm
cd django_kbc_sm
git init
touch README
git add README
git commit -m "first commit"
git remote add origin git@192.168.1.202:django_kbc_sm.git
git push -u origin master

Linux Cheat Sheet

PROCESS BASICS

ps auxww -H

All processes, with params + hierarchy

pgrep -fl $PROCESS_NAME

Filtriraj procese

strace -f -p $PID

What is a process doing?

lsof -p $PID

What files does a process have open?

watch 'ps aux | grep $PROCESS_NAME'

Keep an eye on a process

MEMORY

free -m
cat /proc/meminfo

How much mem is free?

vmstat 1

Are we swapping?

ps aux --sort=-resident|head -11

List the top 10 memory hogs

DATABASES

pt-query-digest --processlist h=localhost --print --no-report --user xxxx --password *****

“Tail” all queries hitting mysql. More

ssh -L 3307:localhost:3306 user@hostname -N

Connect to production mysql locally on port 3307 via ssh

DISK/FILES

iostat -xnk 5

Check reads/writes per disk

find . -size +100M

Find files over 100MB

find . -mtime -7

Find files created within the last 7 days

find . -mtime +14 -type f -name '*.gz'

Find files older than 14 days

find *.gz -mtime +14 -type f -exec rm {} \;

Delete files older than 14 days

tail -f file.log | grep 192.168.1.1

Monitor a log file for an IP or anything else

NETWORK

lsof -nPi tcp

TCP sockets in use

ip addr
ifconfig
iwconfig

Get IP/Ethernet info

mtr google.com

Traceroute with stats over time (top for traceroute)

tcptraceroute google.com

Traceroute using TCP to avoid ICMP blockage

iftop

Show traffic by port

netstat -tlnp

Show all ports listening with process PID

Izvor: http://rubytune.com/cheat