The silver drawer

Useful bash commands

sudo -v

sudo journalctl --update-catalog
sudo journalctl --flush
sudo journalctl -rxb -p 0..3

sudo kbdrate -r 24 -d 750

ssh -T git@github.com
eval $(ssh-agent -s) ; ssh-add

___[ GNOME ]____________________________________________________________________

gsettings set org.gnome.shell disable-extension-version-validation "true"

gsettings set org.gnome.shell disable-extension-version-validation "false"

___[ USB ]______________________________________________________________________

lsusb
for X in /sys/bus/usb/devices/*; do echo "$X"; cat "$X/idVendor" 2>/dev/null ; cat "$X/idProduct" 2>/dev/null; echo; done
sudo sh -c "echo 0 > /sys/bus/usb/devices/1-1.2/authorized"
________________________________________________________________________________

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gedit /etc/fstab

___[ UBUNTU ]_________________________________________________________________

 sudo sh -c 'echo " touch /forcefsck ; systemctl reboot
 set +o history
 sed -i "s/NoDisplay=true/NoDisplay=false/g" /etc/xdg/autostart/*.desktop
 journalctl --update-catalog ; journalctl --flush
 journalctl -rxb -p 0..3
 systemd-analyze critical-chain ; systemd-analyze
 systemd-analyze blame
 ssdtrim
 apt-key del
 apt-key list
 aptitude install
 expurge
 update-grub
 prgoldkrnls
 afterdistupgrade ; upall
logclr ; clean ; exit" > /root/.bash_history'


 ubuntu-support-status --show-all

___[ ARCH ]_____________________________________________________________________

 sudo sh -c 'echo " set +o history
 touch /forcefsck ; systemctl reboot
 systemctl enable
 fc-cache -fv
 sed -i "s/NoDisplay=true/NoDisplay=false/g" /etc/xdg/autostart/*.desktop
 journalctl --update-catalog ; journalctl --flush
 journalctl -rxb -p 0..3
 systemd-analyze critical-chain ; systemd-analyze
 systemd-analyze blame
 archun
 update-sys -g
 yup
clean ; exit
" > /root/.bash_history'


--------------------------------------------------------------------------------

sudo pacman -Scc --noconfirm
sudo pacman-db-upgrade
sudo pacman-optimize

rm -Rfv /var/lib/pacman/sync
pacman-key --init && pacman-key --populate archlinux

___[ FSCK ]_____________________________________________________________________

 blkid

 sudo sh -c 'umount /dev/sdf1 ; ntfsfix -bd /dev/sdf1'

 sudo sh -c '
umount /dev/sdb2 ; umount /dev/sdb4 ; fsck.ext2 -yvf /dev/sdb2 ; fsck.ext4 -yvf /dev/sdb4
umount /dev/sda1 ; umount /dev/sda3 ; fsck.ext4 -yvf /dev/sda1 ; fsck.ext4 -yvf /dev/sda3
umount /dev/sdb1 ; umount /dev/sdb3 ; fsck.ext4 -yvf /dev/sdb1 ; fsck.ext4 -yvf /dev/sdb3
umount /dev/sdc2 ; umount /dev/sdc4 ; fsck.ext2 -yvf /dev/sdc2 ; fsck.ext4 -yvf /dev/sdc4
'


sudo sh -c 'touch /forcefsck ; shutdown -r now'

___[ VIRTUALBOX ]_______________________________________________________________


 sudo sh -c 'echo " update-grub
 prgoldkrnls
 systemd-analyze critical-chain
 systemd-analyze blame
 mount /dev/cdrom /mnt
 sh /mnt/VBoxLinuxAdditions.run
 umount /dev/cdrom
 eject ; reboot
 shutup
updt ; aptclr ; orphclr ; logclr" > /root/.bash_history'


*** sudo /sbin/rcvboxdrv setup ***

___[ CHROOT ]___________________________________________________________________

$ xhost +local:

su -
blkid

mkdir -pv /mnt/arch
umount /dev/sdc{2,4}
umount /dev/sdb4
mount -v /dev/sdc4 /mnt/arch
mount -v /dev/sdc2 /mnt/arch/boot/
mount -v /dev/sdb4 /mnt/arch/home/

arch-chroot /mnt/arch /bin/bash

$ echo $DISPLAY
...in the chroot environment run
# export DISPLAY=:0

exit
cd / ; umount --recursive /mnt/arch/

___[ Vertex GTK3 Icons/Theme ]__________________________________________________

# Vertex Icons
sudo ln -sv $HOME/gitClones/Vertex-Icons/ /usr/share/icons/Vertex-Icons

sudo apt-get install -y autoconf automake pkg-config

____[ ICONS ]___________________________________________________________________

sudo sh -c '
ls -1 /usr/share/icons/*/{.,}icon-theme.cache | xargs -n1 rm -f
ls -d1 /usr/share/icons/*/ | xargs -n1 gtk-update-icon-cache -ft
'

________________________________________________________________________________

sudo sh -c 'ln -sv "$HOME"/.icons/ /root/ ; ln -sv "$HOME"/.themes/ /root/'
________________________________________________________________________________

sudo update-alternatives --config x-cursor-theme
compiz --replace
________________________________________________________________________________

# External IP
curl ipogre.com

___[ LABELS ]___________________________________________________________________

 blkid
 e2label /dev/sdx9 "USBBoot"

 e2label /dev/sdx9 "USBRoot"

___[ VMWARE ]___________________________________________________________________

sudo -H sh -c 'vmware-modconfig --console --install-all'
________________________________________________________________________________

grub-mkfont --output=/boot/grub/fonts/DejaVuSansMono.pf2 --size=16 -v /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
vim /etc/default/grub

________________________________________________________________________________

sudo -E sh -c '
    ln -sfv "$HOME"/.icons /root/.icons
    ln -sfv "$HOME"/.themes /root/.themes
    ln -sfv "$HOME"/.kde4/share/icons /root/.kde4/share/icons
    ln -sfv "$HOME"/.kde4/share/apps/aurorae /root/.kde4/share/apps/aurorae
'

________________________________________________________________________________

sudo e4defrag -c /
________________________________________________________________________________

sudo savscan -v / --stay-on-filesystem
________________________________________________________________________________

amdconfig --adapter=all --initial -f
reboot
clinfo ## should show ALL of your AMD GPUs, and your CPU
amdconfig --adapter=all --odgt  ## should show the temperature of all your AMD GPUs
amdconfig --pxl | while read SPAM_OUT; do notify-send "$SPAM_OUT"; done
or
aticonfig --pxl | while read SPAM_OUT; do notify-send "$SPAM_OUT"; done
________________________________________________________________________________

# man tr
%s/[[:space:]]*$//
%s/[[:blank:]]*$//
________________________________________________________________________________

grep -I "menuentry.*windows" '/boot/grub/grub.cfg'
________________________________________________________________________________

if which git >/dev/null 2>&1; then echo "hi git"; fi
________________________________________________________________________________

apg -m 10 -x 12 -l -M NCLS
________________________________________________________________________________

ssh-copy-id -i ~/.ssh/id_dsa.pub "-p 22 jack@192.168.2.201"
________________________________________________________________________________

diff --brief -r /home/$(whoami)/public_html/ /run/media/$(whoami)/SSDRoot/home/$(whoami)/public_html
colordiff -ru --suppress-common-lines '~/Downloads/cronoconky-master' '~/Downloads/cronoconky-2.1'
________________________________________________________________________________

su -c '
sntp gr.pool.ntp.org
ntpdate gr.pool.ntp.org
'

________________________________________________________________________________

su -c '
update-alternatives --config default.plymouth
update-initramfs -u
'

________________________________________________________________________________

find ~/Dropbox -name ".directory" -exec rm -rfv {} \;
________________________________________________________________________________

#From Arch
sh "/run/media/$(whoami)/Data/Virtual Machines/VB_Machines/clearVBcache.sh"

#From Ubuntu
sh '/media/Data/Virtual Machines/VB_Machines/clearVBcache.sh'
________________________________________________________________________________

sudo vi /usr/share/applications/terminator.desktop
--geometry=960x540+0-0
--geometry=720x405+0-0
________________________________________________________________________________

find . -type f -exec chmod 644 {} + && find . -type d -exec chmod 755 {} +
find . -exec chmod go-rwx {} +
________________________________________________________________________________

cat ~/.config/user-dirs.dir
xdg-user-dirs-update

____[ NO_PUBKEY ]_______________________________________________________________

for key in `cat tmp/NO_PUBKEY.txt`; do
  apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ${key};
done
________________________________________________________________________________

IFS=$(echo -en "\n\b")
________________________________________________________________________________

k=1; for f in *.mp4; do
  echo "${f}";
  if [ $k -lt 10 ]; then
    mv -v "${f}" "0${k}.mp4";
  else
    mv -v "${f}" "${k}.mp4";
  fi
  let k+=1;
done
k=1; for f in *.en.srt; do
  echo "${f}";
  if [ $k -lt 10 ]; then
    mv -v "${f}" "0${k}.en.srt";
  else
    mv -v "${f}" "${k}.en.srt";
  fi
  let k+=1;
done
________________________________________________________________________________

for f in `ls -A *.swf`; do ffmpeg -i "${f}" -vcodec mpeg4 "${f%.*}.mp4"; done
________________________________________________________________________________

for f in *.flac; do flac -cd "$f" | lame -b 320 - "${f%.*}".mp3; done
________________________________________________________________________________

for d in The.*; do mv -v "${d}" "${d#*.},The"; done
________________________________________________________________________________

for beep in /usr/share/sounds/freedesktop/stereo/*.oga; do echo ${beep}; paplay ${beep}; sleep 2; done
________________________________________________________________________________

for cow in /usr/share/cows/*.cow; do cowsay -f ${cow} "I'm the ${cow##*/}"; done
________________________________________________________________________________

espeak -v el -p 50 -s 150 -f ~/Desktop/speakit.txt &
________________________________________________________________________________

dconf reset -f /org/compiz/
________________________________________________________________________________

Prerequisites - Dependencies - Derivative
________________________________________________________________________________

useradd -c "Shares Guest Acount" -M -N -s /bin/false -u 911 smbguest
usermod -G sambashare smbguest
passwd -l smbguest
________________________________________________________________________________

wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip
________________________________________________________________________________

The message tray was really pissing me off so I figured out a hack that works.
1. Open /usr/share/gnome-shell/js/ui/messageTray.j
2. Replace this._traySummoned = true; with this._traySummoned = false;
3. Reboot (or maybe just logout). After that moving the pointer to the bottom of
   the screen will no longer activate the Message Tray.
________________________________________________________________________________

dirsize () {
    du -shx "${1}"/* "${1}"/.[a-zA-Z0-9_]* 2> /dev/null | egrep '^ *[0-9.]*[KMG]' | sort -n > /tmp/list;
    egrep '^ *[0-9.]*K' /tmp/list;
    egrep '^ *[0-9.]*M' /tmp/list;
    egrep '^ *[0-9.]*G' /tmp/list;
    rm -rf /tmp/list;
}
________________________________________________________________________________

ffmpeg -i f.mp4 -q:a 0 -map a f.mp3
#The q option can only be used with libmp3lame and corresponds to the LAME -V option.
________________________________________________________________________________

byzanz-record --duration=5 --display=$DISPLAY --x=1605 --y=50 --width=300 --height=300 ~/Desktop/crono-running.gif
#convert -layers Optimize crono-test.gif s-crono-test.gif
#http://ezgif.com/optimize
________________________________________________________________________________

#This account is currently not available.
grep proxy /etc/passwd
  proxy:x:13:13:proxy:/bin:/usr/sbin/nologin

grep proxy /etc/passwd
cat /etc/shell
chsh -s /bin/sh proxy
________________________________________________________________________________

sudo update-pciid
lspci -nn | grep VGA

How to change Cinnamon desktop icon text color

  1. Create a file named gtk.css in your ~/.config/gtk-3.0 directory.
  2. Put the following text in that gtk.css file:
  3. .nemo-desktop.nemo-canvas-item {
      color: #fff;
      text-shadow: 1px 1px #000;
    }

    .nemo-desktop.nemo-canvas-item:selected {
      background-color: alpha(#d64a38, 0.9);
      background-image: none;
      color: #fff;
      text-shadow: none;
    }
  4. Alt+F2, type nemo -q and hit Enter
  5. Put the Alt+F2, type nemo -n and hit Enter

Hacks for us

# List only Flat Files:
ls -1Ap | grep -v /$
# List only Directories:
ls -1Ap | grep /$ | sed -e "s/[/]//g" | column
ls -1Ap | grep /$ | cut -d/ -f1
find ~ -maxdepth 1 -name ".?*" -type d | column
find ~ -maxdepth 1 -name "[^.]?*" -type d | column

# Replace space char with underscore from files
find . -type f -iname "*.mp3" -exec rename "s/ /_/g" {} ;

# Convert a/v files
sudo apt-get install ubuntu-restricted-extras libav-tools soundconverter
#avconv -i input.flv -acodec libmp3lame output.mp3
ffmpeg -i video.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 audio.mp3 -or use-

# Screenshots
import –frame myScreenShot.png

# How can I find out my graphics card on ubuntu?
# ATI Cypress XT [Radeon HD 5870]
lspci | grep VGA | sed 's/^.*: //'

# Easy way to concatenate PDF files in Ubuntu Linux
gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf *.pdf

man -t chmod | ps2pdf - chmod.pdf

# For nano to display line, column numbers
echo "set const" > ~/.nanorc

# Install lamp with 1 command in Ubuntu 12.04 LTS Precise Pangolin & LinuxMint13
sudo apt-get install tasksel

# Truncate files to zero length
find ./ -type f -print0 | xargs -0 truncate -s0

# What is the command to list all users|groups?
awk -F: '{ print $1 }' /etc/passwd
awk -F: '{ print $1 }' /etc/group

Ultimate PS1 bash prompt

# BASH customizations should generally be made in your ~/.bash_aliases file, use this file instead of directly editing ~/.bashrc
PS1='${debian_chroot:+($debian_chroot)}[e[0;36m]┌─[[e[0m][e[1;33m]u[e[0m][e[1;36m] @ [e[0m][e[1;33m]h[e[0m][e[0;36m]]─[[e[0m][e[1;34m]w[e[0m][e[0;36m]][e[0;36m][e[0m][e[0;36m][e[0m]n[e[0;36m]└─[[e[0m][e[1;37m]$[e[0m][e[0;36m]]› [e[0m]'

# Πρόβλημα με το τερματικό μου καθώς δεν συμπλήρωνε τα ονόματα των αρχείων με spaces σωστά
sudo apt-get purge bash-completion && sudo rm -rf /etc/bash_completion.d && sudo apt-get install bash-completion

# How do I check fglrx's version?
ls /var/lib/dkms/fglrx/
# New kernel installed?
sudo dkms build -m fglrx -v [-k `uname -r`]

# http://pthree.org/2012/04/27/zombie-proccess-what-they-are-and-how-to-handle-them/
ps -eo pid,ppid,user,args,stat --sort stat

# Remove ATI logo "Test use only"
# DRIVER=/usr/lib/xorg/modules/drivers/fglrx_drv.so
DRIVER=`find / -name fglrx_drv.so -print 2>/dev/null|head -n1`
for x in $(objdump -d $DRIVER | awk '/call/&&/EnableLogo/{print "x"$2"x"$3"x"$4"x"$5"x"$6}')
do
sed -i "s/$x/x90x90x90x90x90/g" $DRIVER
done

# Automount partition
#nano -w /etc/fstab
UUID=1462F65862F63E54 /media/DATA ntfs-3g rw,auto,uid=<username>,gid=users,fmask=0113,dmask=0002,windows_names,locale=en_US.utf8 0       0

watch -tb -n 1 "date | cut -d ' ' -f 5"

ls -d */ | xargs -n1 -l basename
tree -d -L 1
find . -maxdepth 1 -mindepth 1 -type d -printf "%Pn"
find . -maxdepth 1 -mindepth 1 -type d | grep -v "^./[^.]" | xargs -n1 -l basename

/usr/bin/canberra-gtk-play -i "desktop-login" -d "GNOME Login sound"

sudo bash /etc/fonts/infinality/infctl.sh setstyle

sudo cp -r OpenSans/ /usr/share/fonts/ && sudo fc-cache -f -v

cat ~/.config/user-dirs.dirs
xdg-user-dirs-update

espeak -v el -p 50 -s 150 -f ~/Desktop/speakit.txt &

watch -n 1 'cat /proc/cpuinfo | grep MHz'

for cow in /usr/share/cows/*.cow; do cowsay -f ${cow} "I'm the ${cow##*/}"; done | less

echo ${XDG_CURRENT_DESKTOP}

lsmod | sort | less

env | less

find . -type f -exec chmod 644 {} ; && find . -type d -exec chmod 755 {} ;

SSH

ssh-keygen -t ecdsa -b 521 -C "$(whoami)@$(hostname)-$(date -I)"
ssh-keygen -t dsa -C "$(whoami)@$(hostname)-$(date -I)"

ssh-add -l
eval "$(ssh-agent -s)"
ssh-add

sudo vi /etc/ssh/sshd_config
#PasswordAuthentication no
# Keep this so that the ssh-keygen to work

ssh-keygen -f "/home/john/.ssh/known_hosts" -R [192.168.52.2]:2222
ssh-copy-id -i ~/.ssh/id_dsa.pub "-p 321 user@192.168.52.10"

Note that Ubuntu needed the quotes.

genpasswd() {
  local l=$1
  [ "$l" == "" ] && l=20
  tr -dc 'A-Za-z0-9!@#$%^&_' < /dev/urandom | head -c ${l} | xargs
}