Archive for January, 2012


  1. #——————————————////
  2. #       Color Commands
  3. #——————————————////
  4. if [ -x /usr/bin/dircolors ]; then
  5.     eval “`dircolors -b`”
  6.     alias ls=’ls –color=auto’
  7.     alias dir=’dir –color=auto’
  8.     alias vdir=’vdir –color=auto’
  9.     alias grep=’grep –color=auto’
  10.     alias fgrep=’fgrep –color=auto’
  11.     alias egrep=’egrep –color=auto’
  12. fi

 

 

Ad above code to your bashrc file

Mint Fixer

#!/bin/bash

clear

# Test for UID=0
if [ “$(echo $UID)” != “0” ]
then
echo “You must be superuser to run this program. Try ‘sudo ./fixmint.sh’”
exit
fi

# Add packages you need
echo “install some good packages to have handy.”
apt-get -y install sshfs smbfs irssi vpnc screen vlc mencoder vim moc openssh-server subversion git twinkle curl php5-cli mutt clusterssh html2text autofs vncviewer &> /dev/null

# Turn off guest login
echo “Turning off guest login.”
grep -q “allow-guest=false” /etc/lightdm/lightdm.conf || echo “allow-guest=false” >> /etc/lightdm/lightdm.conf

# Fix dual monitors
echo “Fixing dual monitor mode so that both monitors reflect changing virtual desktops.”
gconftool-2 –set /desktop/gnome/shell/windows/workspaces_only_on_primary –type bool false

# Fix broken login chime
echo “Fixing broken login chime.”
for user in $(ls /home)
do
mv /home/$user/.config/autostart/libcanberra-login-sound.desktop /home/$user/.config/autostart/libcanberra-login-sound.desktop.orig
echo -e “[Desktop Entry]\nType=Application\nName=GNOME Login Sound\nComment=Plays a sound whenever you log in\nExec=/usr/bin/canberra-gtk-play -f /usr/share/sounds/linuxmint-login.wav\nOnlyShowIn=GNOME;Unity;\nAutostartCondition=GSettings org.gnome.desktop.sound event-sounds\nX-GNOME-Autostart-Phase=Application\nX-GNOME-Provides=login-sound” >> /home/$user/.config/autostart/libcanberra-login-sound.desktop
done

# Set the login page wallpaper
echo “Setting the login background to /usr/share/backgrounds/mint.jpg. Copy any background you wish to be the login wallpaper to that file.”
sed -i -e ‘s/^background.*/background=\/usr\/share\/backgrounds\/mint.jpg/g’ /etc/lightdm/unity-greeter.conf

echo “All done. Enjoy!”

First time this happened! A coworker asked me today how to get into his Linux Mint box after he forgot his password. Of course I rattled off the old GRUB way to get things done, but, what?? This is GRUB 2! No so fast there! Turns out it’s quite different.

You hold down the shift key while booting to get to the grub menu.
You hit ‘e’ to edit your boot options.
You change the kernel line options on the very end of the kernel line to read “rw init=/bin/bash”.
You press F10 to boot.

Once booted you are dropped immediately into a shell prompt where you can change your password with the “passwd username” command. Reboot and you’re home free!

Delete Files Older Than x Days on Linux

The find utility on linux allows you to pass in a bunch of interesting arguments, including one to execute another command on each file. We’ll use this in order to figure out what files are older than a certain number of days, and then use the rm command to delete them.

 

Command Syntax

find /path/to/files* -mtime +5 -exec rm {} \;

Note that there are spaces between rm, {}, and \;

Explanation

  • The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. I would recommend using the full path, and make sure that you run the command without the exec rm to make sure you are getting the right results.
  • The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days.
  • The third argument, -exec, allows you to pass in a command such as rm. The {} \; at the end is required to end the command.

This should work on Ubuntu, Suse, Redhat, or pretty much any version of linux.