Linux tips
linux bootstrap hugo
1. Count directories and files
- count directories ignoring . and .. directories
[userA ~]$ls -lA caps_export | egrep -c '^d'
14
- count files
[userA ~]$ls -lA caps_export | egrep -c '^-'
179
2. Remote desktop
rdesktop -b -z -g 90% -a 16 -r sound:off -u domain\\username -p'yourpassword' serverip
3. delete to recycle bin
- Install rmw from slackbuilds.org
- edit /etc/rmwrc
- WASTE=$HOME/.local/share/Trash
- run rmw
- add alias rm=rmw in .bashrc
- edit /etc/rmwrc
4. remove duplicate lines
- You can also use something like:
awk '!seen[$0]++' "${in_file}" > "${our_file}"
5. Disable mouse scroll as in browser it was going to previous page
- Find the mouse id
xinput --list | more
Green Asia Corp PS2toUSB Adapter id=12 [slave pointer (2)]
Green Asia Corp PS2toUSB Adapter id=11 [slave keyboard (3)]
AT Translated Set 2 keyboard id=13 [slave keyboard (3)]
-
Disable the buttons
xinput set-button-map 12 1 2 3 4 5 6 7 0 0
-
script for running at startup. Can be added in xfce settings > startup application > disablemousescroll.sh.
disablemousescroll.sh
#!/bin/bash
# script to disable horizontal scroll in seamonkey.
# scrolling up was going back to previous page in seamonkey.
set -eu
#MOUSE_ID=$(xinput --list | grep Logitech | sed -r 's/.*id=([0-9]+).*/\1/')
MOUSE_ID=12
if [ -n "$MOUSE_ID" ]; then
xinput set-button-map $MOUSE_ID 1 2 3 4 5 6 7 0 0
fi
6. slocate to search filesystem
Script for running the update to slocate.db: slocateData.sh
#!/bin/sh
#Script to update the personal slocate db and exclude some directories
cd
updatedb -l 01 -o ~/slocate.db -U . -v -e ./wc,./code,./.cache,./.config,./.local
- usage eg to search for caps:
slocate -d slocate.db caps
7. slackware ntp settings
- You can shutdown ntpd :
chmod a-x /etc/rc.d/rc.ntpd
echo "/usr/sbin/ntpdate time.nist.gov" > /etc/cron.daily/ntpupdate
chmod a+x /etc/cron.daily/ntpupdate
8. rsync parameters
- Using rsync with exclude
- To copy files from remote to local, maintaining file properties and sym-links (-a), zipping for faster transfer (-z), verbose (-v).
rsync -avz host:file1 :file1 /dest/
rsync -avz /source host:/dest
- Copy files using checksum (-c) rather than time to detect if the file has changed. (Useful for validating backups).
rsync -avc /source/ /dest/
- Copy contents of /src/foo to destination:
- This command will create /dest/foo if it does not already exist
rsync -auv /src/foo /dest
- Explicitly copy /src/foo to /dest/foo
rsync -auv /src/foo/ /dest/foo
- rsync exclude for directory exclusion
rsync -avv /src/foo/ /dest/foo/ --exclude=/tools/
The leading slash / in the exclude is of great importance. It means match only at the base of the source tree. Assume the following:
- tools/
- src/
- program.c
- tools/
So there is the directory tools/ and src/tools/. exclude tools/ should exclude both of those directories named tools, whereas exclude /tools/ will only exclude the former (which is probably more often intended)
9. Slackware basic security