*************** * Linux stuff * *************** --------------- | chmod table | --------------- value read write execute 0 no no no 1 no no yes 2 no yes no 3 no yes yes 4 yes no no 5 yes no yes 6 yes yes no 7 yes yes yes chmod a+x file - file executable to all chmod u-w file - remove file write permission from user chmod g+r file - file readable to all users in the same group ** practical ** --------------- Find [string] from unknown file: find . -name "*.*" | xargs -L1 grep -H [string] Find [file], but don't print errors: find -name [file] 2>/dev/null Run graphical [program] on (f.e. remote) computer's display: DISPLAY=:0 [program] Sort du output: du -hs * | sort -h ** system ** ------------- Set swappiness (default 60): echo [0-100] > /proc/sys/vm/swappiness To make it permanent edit /etc/sysctl.conf and add: vm.swappiness = [0-100] Remove CLI beeps. Edit /etc/inputrc and set: set bell-style none Set [scheduler] for a [block device]: echo [scheduler] > /sys/block/[block device]/queue/scheduler To make it permanent add kernel option: elevator=[scheduler] Good generic fsck flags to fix filesystem problems: (p=no questions f=force v=verbose D=optimize directories) fsck -pfvD /dev/[partition] ** rescue ** ------------ Simplify HDD settings (useful to perform before trying to rescue data): hdparm -A0 -B255 -c0 -d0 -n0 -M128 -r1 -W0 /dev/[disk] Try to rescue what is left on HDD (target could be f.e. sda6): myrescue -b1024 -B bitmap -S -r1 /dev/[disk] /dev/[target] PS. Check also ddrescue. ** dd ** -------- Send USR1 signal to dd to print out progress: (dd if=/dev/random of=/dev/null bs=1K count=100 &); watch -n 1 killall -USR1 dd ** mutt ** ---------- Send mail with attachement. mutt -s "this is the post subject/title" user@doma.in -a "~/attachement.png" < mail.txt ******************* * Debian specific * ******************* ** dpkg ** ---------- Get status of package: dpkg --get-selections [package] Set [package] on hold: echo "[package] hold" | dpkg --set-selections Show which packages are on hold: cat /var/lib/dpkg/status | grep -B1 Status | grep -B1 hold List contents of deb file: dpkg -c [package.deb] List all the files installed by [package]: dpkg -L [package] Backing up package status in [file]: dpkg --get-selections > [file] Replicating status in [file] and installing packages as it instructs: cat [file] > dpkg --set-selections apt-get dselect-upgrade ** APT ** --------- Install from specified repository (-t flag): apt-get -t [repository] install [package] Location of packages stored (cached) by apt: /var/cache/apt/archives/ Cleaning (removing) all stored packages from cache: apt-get clean Cleaning (removing) not currently installed packages from cache: apt-get autoclean Package extended states (auto-installed or manually installed) are stored in: /var/lib/apt/extended_states