Archive for March, 2013

My Linux Tricks (always growing)

2013-03-22 Leave a comment

Here are a few little tricks I’ve used in the past that might be helpful. I use some of them often and others only on occasion and wanted a good reference for if I forgot what it was (an example was setting up a new webdev env and forgot about the g+s part).

Add/Remove a secondary group from a user with out having to copy the whole group list they have assigned to them.

$ gpasswd -a <USER> <GROUP>
$ gpasswd -d <USER> <GROUP>

Set VIM as the default ubuntu editor instead of NANO, this drives me nuts if they change it from vi they should have a prompt at install for which editor. Making NANO the default/recommended but allow others to select one they prefer.

$ sudo apt-get install vim
$ sudo update-alternatives --config editor

A nice little password safe encryption program. xdotools is required if you want it to use auto fill other wise it can be skipped.

$ sudo <System Package Manager> install keepass2
$ sudo <System Package Manager> install xdotool

Surprisingly the sshd didn’t get installed by default with my Ubuntu system. Of course it’s a desktop OS.

$ sudo apt-get install openssh-server

A simple way to watch a directory for any new files created.

$ sudo <System Package Manager> install inotify-tools

Good old Conky for system information.

$ sudo <System Package Manager> install conky

Set all subdirectories to have the setgui bit. The following assumes your current directories is the one you want want all subdirectories to be changed. Just change the path to the directory you want if you’re not currently in it. The setuid/setgui/sticky bits are the “1st” octet of the permissions and numbered 4/2/1 respectively . So g+s would make a 775 file become 2775.

For more information read the chmod man page sections SETUID AND SETGID BITS and RESTRICTED DELETION FLAG OR STICKY BIT.

The stats command shows the octet code of each file in the current directory. I prefer octet codes just because it’s easier for me other wise you can just do an ls -l and you’ll see the file with -rwxrwxr-x will become -rwxrwsr-x.

$ find . -type d -exec chmod g+s {} \;
$ stat -c "%a %n" *

Nice way to tail multiple files in a single console.

$ sudo <System Package Manager> install multitail

Have a terminal always running in the background on your desktop with devilspie.

$ sudo <System Package Manager> install devilspie
$ mkdir ~/.devilspie
## geometry is made of up window size (x1,y1) position(x2,y2) x1+y1+x2+y2
$ vim ~/.devilspie/desktopTerm.ds
        ( if
        ( matches ( window_name ) "desktopTerm" )
        ( begin
        ( set_workspace 1 )
        ( pin )
        ( skip_pager )
        ( skip_tasklist )
        ( undecorate )
        ( below )
        ( geometry "700x1090+1240+0" )
## Make devilspie starts up the -a option has it apply the rules to all  existing windows 
devilspie -a
## I am setting this up with Xubuntu so my desktop is XFCE4 and it's terminal
## -T sets the title of the terminal so devilspie can target it.
xfce4-terminal -T desktopTerm
Categories: Linux

Ubuntu Configuration

2013-03-11 Leave a comment

So I installed Xubuntu a little while ago and started configuring it for one of my main systems instead of quick VMs that I destroy after I’m done testing what I wanted on them. I’m not that use to deb systems and the apt package management. Here are a few of the things I did when configuring my system.

Installed a web services for development. Includes all basic LAMP services apache2, mysql and php5. Note you’ll save yourself some time/stress/headaches if you also include the php5-mysqlnd (native driver) as well. php5-gd is an image library.

$ sudo apt-get install apache2 php5 libapache2-mod-php5 mysql-server php5-mysqlnd php5-gd

## Another nice thing is being able to edit the web root with your user and have the group assigned correctly.
## this example the webroot is /var/www we set the group to www-data what apache will be running as.
## Then we set the sticky bit for the group so all files created under it will be assigned that group.
## Just be sure to either include your user in the group so you have access to it or set the files to your user.
$ sudo gpasswd <USER> www-data
$ sudo chown :www-data /var/www
$ sudo chmod g+s /var/www

To use the most current Nvidia drivers. Make sure you have the source for your kernel before downloading so we don’t get issues.

$ sudo apt-get install build-essential linux-headers-`uname -r`
$ sudo apt-get install nvidia-experimental-310

I was going to install the direct Nvidia drivers and needed to disable the GUI init run levels for a second so I only started with a CLI. I could do it by simply editing the GRUB file.

$ sudo vim /etc/default/grub
## Edit the following line
## becomes
## Run the GRUB2 builder
$ sudo update-grub

Setup wireshark so any user can capture packets (prevents the requirement of running it as root).

## If it's not already installed
$ sudo apt-get install libcap2-bin
## Create a wireshark group so anyone in the group can capture packets, and get the new group rights in your current login session
$ sudo passwd -a <USER> wireshark
$ usermod -a -G wireshark <USER>
$ newgrp wireshark
## Set the group for the dumpcap so only root and the group can execute it.
$ sudo chown root:wireshark /usr/bin/dumpcap
$ chmod 750 /usr/bin/dumpcap
## Set the file up correctly
$ sudo setcap cap_net_raw,cap_net_admin,cap_dac_override+eip /usr/bin/dumpcap
Categories: Linux