Linux tips


linux bootstrap hugo

1. Count directories and files

[userA ~]$ls -lA caps_export | egrep -c '^d'
14
[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

4. remove duplicate lines

5. Disable mouse scroll as in browser it was going to previous page

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)]
#!/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

7. slackware ntp settings

    echo "/usr/sbin/ntpdate time.nist.gov" > /etc/cron.daily/ntpupdate
    chmod a+x /etc/cron.daily/ntpupdate

8. rsync parameters

    rsync -avz host:file1 :file1 /dest/
    rsync -avz /source host:/dest
    rsync -avc /source/ /dest/
    rsync -auv /src/foo /dest
    rsync -auv /src/foo/ /dest/foo
    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