Trace: » Command Ref » Tips/Tricks
Tips/Tricks
Multiple X
Start multiple X sessions:
startx – :1
Rename Files
Rename Files
for file in `ls .`; do mv “$file” “${file/old/new}”; done
Transfer files
Transfer files (insecurely)
Remote machine
nc -l -p 1234 | uncompress -c | tar xvfp -
Local machine
tar cfp - /some/dir | compress -c | nc -w 3 [destination] 1234
Backup Mysql
Backup Mysql
2 2 * * * root mysqldump -u root -pPASSWORD --all-databases | gzip > /mnt/disk2/database_`data ' %m-%d-%Y'`.sql.gz
Execute the last command as root
Execute the last command as root
$ sudo !!
Non-numeric permissions
Non-numeric permissions
Who
u — file owner g — group member of o — other a — all (u, g, and o)
Permissions
r — read w — write x — execute
Actions
+ — adds the permission - — removes the permission = — makes it the only permission
Find and Replace
VPNC resolve.conf workaround
VPNC resolve.conf workaround
*/10 * * * * root if [ -e /etc/resolvconf/run/interface/tun0 -a “`pidof vpnc`” == ”” ] ; then /sbin/resolvconf -d tun0; fi
utmpdump
utmpdump
View login activity utmpdump /var/log/wtmp
Unonstrain windows to the top of the screen
Unonstrain windows to the top of the screen
gconftool-2 --set /apps/compiz/plugins/move/allscreens/options/constrain_y --type bool 0
Find all files in current directory and sort by size
Find all files in current directory and sort by size – I put this in my .bashrc
dfn () { du --all --max-depth=1 $@ | sort -n | awk '{if ($1>1048576) {print int($1/1048576)"G",$2}else if ($1>1024) {print int($1/1024)"M",$2} else {print $1"K",$2}}' }
Find a 4 character string in line occuring 20 characters in and following "topic"
Find a 4 character string in line occuring 20 characters in and following “topic”
cat file.txt |grep -e "topic"|sed 's/^.\{19\}\(.\{4\}\)\(.*\)/\1/'
winmail.dat
Huh? winmail.dat
ytnef -f . winmail.dat
Reset frozen system
Reset frozen system
(Alt+SysRq)+R+S+E+I+U+B
Directory Tree from Bash
Directory Tree from Bash
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
Clone System
Clone system
On current box dpkg --get-selections > /tmp/dpkglist.txt
New Box. Don't forget to restore configs! (/etc /home ...) sudo dpkg --set-selections < /tmp/dpkglist.txt sudo apt-get -y update sudo apt-get dselect-upgrade
Display Useful Info From Cmd Line
notify-send
notify-send "Process Complete"
CentOS Items
DAG
http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
You are here: Links » Tips/Tricks