Table of contents:
First get the port of device:
for dev in $(ls /sys/bus/usb/devices/*/product); do echo $dev ;cat $dev ;done
You'll get a number like 1.1-3 or 3-6 which is the port. To deactivate it:
echo '3-6' | sudo tee /sys/bus/usb/drivers/usb/unbind
To mount it again, just use bind
endpoint instead.
cat /proc/acpi/button/lid/LID0/state
ssh-keygen -f /path/to/private_key -y
Thanks to konstantinbest!
iostat -xdmt 1
will show you extended metrics for every disk in your system, where %util is the utilization in percent, aqu-sz is the io queue where everything above 2 is not good (depending on your disk architecture)
sar -p -d 1
will show you the same with aggregated sum of iops (w and r) in a more readable way plus the wait time for an IO request
List all modules with their parameter values
cat /proc/modules | cut -f 1 -d " " | while read module; do \
echo "Module: $module"; \
if [ -d "/sys/module/$module/parameters" ]; then \
ls /sys/module/$module/parameters/ | while read parameter; do \
echo -n "Parameter: $parameter --> "; \
cat /sys/module/$module/parameters/$parameter; \
done; \
fi; \
echo; \
done
Backup & restore file permissions:
getfacl -R /var/www/myweb > permissions.acl
setfacl --restore=permissions.acl
Calculate whatever total storage files/folders matching a regexp has
find /data/backup -regex '.*.war..*' -print0 | du --files0-from=- -ch | tail -1
(find /proc -type l | xargs ls -l | grep pipe) 2>/dev/null
fuser -v -n tcp 1111
ps --forest -o pid,tty,stat,time,cmd -g <PID>
find -L /path -type l
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Run like: stap -v --all-modules kmem_alloc7.stp dentry
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
awk 'length != 20 { print ; next ; }
{ printf "%s\n%s\n",substr($0,0,10),substr($0,11) }' file.txt
Just the accepted parameters will be listed, either apply via pipe or -i etc.
Multiple stuff can be combined via semicolon.
(Considering they start with #)
'/^[ \t]*#/d'
'/^$/d'
'/mypattern/{x;p;x;}'
'/mypattern/G'
'0~5G' # GNU sed
'n;n;n;n;G;'
Let's say longer than 65:
'/^.\{65\}/p'