App-Cheats

 view release on metacpan or  search on metacpan

cheats.txt  view on Meta::CPAN

dpkg --print-architecture

# Print allowed foreign architectures (DES,machine)
# When installing packages.
dpkg --print-foreign-architectures

# Error - Could not get lock /var/lib/dpkg/lock (admin)
sudo kill -9 $(sudo lsof | grep /var/lib/dpkg/lock | awk '{print $2}')
sudo dpkg --configure -a

# dpkg: error: dpkg status database is locked by another process (DES,bench)
sudo rm -f /var/lib/dpkg/lock

# Install a package from a file
sudo dpkg -i my.deb

# View packages installed on the system
dpkg -l

# Check if a package is installed on a system
dpkg -l | grep kate

cheats.txt  view on Meta::CPAN

dmesg


#############################################################
## Linux Commands - du
#############################################################

# Get top 20 people using too much disk space
du -ms /* | sort -nr | head -n 20

# Find how much space each locked user is using
a=`sudo passwd -Sa | AND -r "\bL$" | get_nth 0 | while read u; do ls -d1 /net/home*/$u; done 2>/dev/null | col_2_row`
b=`sudo du -scm `echo $a` | sort -nr`
echo "$b" | perl -ple '($u)=m{/([^/]+)$} or ($_=sprintf "%-30s %s", $_,"Password Status (L - Locked)") and next; ($s)=(split " ",`sudo passwd -S $u`)[-1]; chomp $s; $_ = sprintf "%-30s %s", $_, $s'

# Find how much space each locked user is using (compact)
sudo passwd -Sa | AND "\bL$" | perl -aple '$d=qx{sudo du -sm /net/home*/$F[0]}; $d = $? ? "NO HOME DIR" : (chomp $d,$d); $_ = "$d - $_"'


#############################################################
## Linux Commands - eval
#############################################################

# Variable name is stored in another variable
n1=abc
abc=blue

cheats.txt  view on Meta::CPAN

#############################################################
## Linux Commands - rcs
#############################################################

# Unlock a file
co -u file

# RCS error: file is in use
rm -f RCS/,file_name

# RCS error: file locked by pwxxxx
rcs -U file

# RCS: check in a file initially without the prompt message
ci -t-msg tiny2_rcs.tst


#############################################################
## Linux Commands - read
#############################################################

cheats.txt  view on Meta::CPAN

perl -lMthreads -le '$sub = sub{ print "@_" }; @t=map threads->new( $sub, $_ ), 1..3; $_->join for @t'

# Shared and non shared variables example
perl -lMthreads -Mthreads::shared -le '$a=$b=1; share($a); async(sub{$a++; $b++})->join; print "a=$a, b=$b"'

# Thread pitfall. $a can be either 2 or 3 (race condition)
perl -lMthreads -Mthreads::shared -le '$a=1; share($a); $_->join for map async(sub{my $foo=$a; $a=$foo+1}), 1..2; print "a=$a"'

# Allow only one thread to touch a variable at a time
# This will cause a "deadlock" where one thread requires a reourses
# locked by another thread and vice versa
perl -Mthreads -Mthreads::shared -le 'share $a; share $b; push @t, async(sub{lock $a; sleep 20; lock $b}); push @t, async(sub{lock $b; sleep 20; lock $a}); $_->join for @t'
#
# Alternate syntax 1
perl -Mthreads -le 'my $a :shared; my $b :shared; push @t, async(sub{lock $a; sleep 20; lock $b}); push @t, async(sub{lock $b; sleep 20; lock $a}); $_->join for @t'
#
# Alternate syntax 2
perl -Mthreads -le 'my $a :shared; my $b :shared; push @t, threads->create(sub{lock $a; sleep 20; lock $b}); push @t, threads->create(sub{lock $b; sleep 20; lock $a}); $_->join for @t'

# Thread safe queues. Passing data around
perl -Mthreads -MThread::Queue -le 'my $q=Thread::Queue->new; $t=async(sub{ print "Popped $d off the queue" while $d=$q->dequeue  }); $q->enqueue(12); $q->enqueue(qw/A B C/); sleep 1; $q->enqueue(undef); $t->join'



( run in 0.459 second using v1.01-cache-2.11-cpan-49f99fa48dc )