Ubuntu 10.04 Linux Commands Cheat Sheet

Unzip:

  • sudo apt-get install unzip
  • unzip [file]

Tar:

  • tar -cvvf foo.tar [directory]

Untar:

  • tar -zxvf yourfile.tar
  • tar -xvfz filename.tar.gz
  • tar -xvzf filename.tar.gz [directory]
  • tar -jxvf filename.tar.bz2

Find: find [dir] -type d|f -iname ‘searchstring’

  • find / -type -d -iname ‘python’
  • find ~ -type d -exec chmod +x {} ;

Delete a user account

  • sudo deluser <username>

Add an New user

  • sudo useradd <username>

or

  • sudo useradd -d /home/<directory> -m <username>

( -d specifies home directory, -m makes the folder if it doesn’t exist )

useradd doesn’t add password unless you add -p     …. or you can just set the password later with:

  • sudo passwd <username>

If called with two non-option arguments (see below), adduser will add an existing user to an existing group.

Add an existing user to an existing group

  • sudo usermod -a -G <group> <user>

Set password of new user

  • sudo passwd <username>

Make a new Group: 

  • groupadd <groupname>

To see what groups currently exist:

  • cat /etc/group

To see current users logged in:

  • w

Count lines in file:

  • wc -l <filename>

 

Installing Python MySQLDB on Windows Errors

Well after trying to recompile the entire library, i came across this link.

http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python

A plethora of precompile python libraries.  What a great resource.

Up until i found the precompiled libraries i came across a plethora of errors trying to compile MySQLdb.  Errors I’ve gotten:

File setup_windows.py line 7, in get_config serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])

error: Unable to find vcvarsall.bat

 

Hope this helps you as much as it did me.

Installing NGiNX on Ubuntu 10.04 Lucid Lynx

Add the following urls to your sources.list file:

Close and save the file.  Then run the following commands:

That simple.  Next comes Configuring NGiNX.

Editing Ubuntu sources.list

The sources.list is a text file on a Debian derived Linux distributions.  Aptitude (apt-get) uses this list of servers as locations from which to retrieve software. To add to this you must be logged into a terminal.  Have ready and know how to use a simple terminal text editor such as nano or vi. Open the sources.list file in your text editor.  I prefer nano text editor so the command will look like:

sudo nano /etc/apt/sources.list

You must sudo this command unless you’re already switched to the super user account via: ‘sudo -s’.  Now add or delete any lines you need to, then save.  The next apt-get command you run will now pull from these servers.

Password protecting nginx

Create a Username/Password which will be stored in ‘useraccess’, a file I just made up.

htpasswd -b -c useraccess username password

Now in the nginx config, under:

auth_basic "Message box title of password prompt";
auth_basic_user_file /path/to/useraccess;

How to get around the Wikipedia blackout.

Copy and paste this into your address bar: javascript:$("#content").css("display", "block");$("#mw-sopaOverlay").css("display","none");   To disable blackout on wordpress.com: (this does you no good because the url’s are rewritten) javascript: jQuery("span").removeClass("picture");jQuery(".posttitle").attr("style", "background: #FFFFFF ! important");jQuery("small span").attr("style", "background: #FFFFFF ! important");jQuery("span span").attr("style", "background: #FFFFFF ! important");jQuery("span strong").attr("style", "background: #FFFFFF ! important");