Main Page

From Wiki
Revision as of 08:41, 3 May 2014 by Knyaz (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Useful commands

Finding packages for downgrading

Put needed lists of packages from /var/log/apt/history.log to /tmp/history and run this command:

cat /tmp/history | sed "s/), /\n/g" | sed "s/ (/:/g" | sed "s/, /:/g" | awk -F: {'print $1,"=",$3," "'} | sed "s/ = /=/g" | tr -d "\n"

How find broken links

# find /path -type l | while read link; do [ -e `readlink $link` ] || echo $link; done

Remove broken links:

# find /path -type l | while read link; do [ -e `readlink $link` ] || echo $link; done|xargs rm -f

or

# find /path -type l | while read link; do [ -e `readlink $link` ] || rm -f $link; done

Move broken links:

# find /path -type l | while read link; do [ -e `readlink $link` ] || mv $link /dest_path; done

Fix the time:

# /etc/init.d/ntp stop ; ntpd -q ; sleep 100s ; ntpd -q; /etc/init.d/ntp start
This stops NTP, forces it to sync the clock (to “prime the pump”), sleeps for 100 seconds, forces a second clock sync, and restarts NTP. It produces output like this:
Stopping NTP server: ntpd.
ntpd: time set +12.262938s
ntpd: time set +2.623381s <— drift per 100s
Starting NTP server: ntpd.
The second "time set" – +2.623381s – is your 100s drift. Take that drift, (as a proportion of the current ticks), add (use the sign of the drift – if the sign on the drift is "-", you'd subtract ticks) it to the adjtime adjustment, and repeat 'til satisfied, like so:
# adjtimex -p
[...]
tick: 10000
[...]
# # add (+2.62s / 100s) * 10000 = 262 ticks
# adjtimex -t 10262
# /etc/init.d/ntp stop ; ntpd -q ; sleep 100s ; ntpd -q; /etc/init.d/ntp start
Stopping NTP server: ntpd.
ntpd: time set +3.044932s
ntpd: time set -0.259021s
Starting NTP server: ntpd

Generate PRT records in vim

:r! for i in `seq 0 255`; do echo -e $i'\t'IN'\t'PTR'\t'host$i.g1.domail.com.; done

Resume rsync file transfer

rsync -av --partial --progress --rsh=ssh /path/to/file username@server.name.com:/path

nscd clear host cache

nscd --invalidate=hosts

fsck

fsck  -vycf /dev/sdaX

where, v - verbose mode, y - answer "yes" on all questions, c - check bad blocks, f - force check.