Linux/Snippets: Difference between revisions
< Linux
No edit summary |
No edit summary |
||
Line 34: | Line 34: | ||
</pre> | </pre> | ||
</blockquote> | </blockquote> | ||
show SMART data | |||
<blockquote> | |||
<pre> | |||
sudo smartctl -a /dev/sd? | |||
</pre> | |||
</blockquote> | |||
check for bad sectors | |||
<blockquote> | |||
<pre> | |||
fsck.ext4 -cDfty -C 0 /dev/sdxx | |||
</pre> | |||
</blockquote> | |||
Revision as of 09:07, 20 August 2013
File system & drives
List directory sizes
clear; for each in $(ls) ; do du -hs "$each" ; done
Measure execution time
START=$(date +%s.%N) command END=$(date +%s.%N) DIFF=$(echo "$END - $START" | bc)
find file with content
grep -iR "$PATTERN" *
show hdd power states
sudo hdparm -C /dev/sd?
show SMART data
sudo smartctl -a /dev/sd?
check for bad sectors
fsck.ext4 -cDfty -C 0 /dev/sdxx
Manual SSD Trim
sudo fstrim -v /
Cron SSD Trim
- /etc/scripts/fstrim.sh:
#!/bin/sh # echo `date +"%d %b %H:%M:%S"` | tr -d '\n' >> /var/log/fstrim /sbin/fstrim -v / >> /var/log/fstrim
- /etc/cron.d/fstrim:
# 0 * * * * root /etc/scripts/fstrim.sh
kernel
remove old kernels
dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get --dry-run remove