Wednesday, October 28, 2009

Start, stop, restart MySql - Ubuntu 9.04 Jaunty

user@machine:~$ sudo /etc/init.d/mysql [start, stop, restart]

~Fin

Monday, October 26, 2009

Reset root password for MySql 5.* - Ubuntu 9.04 Jaunty

user@computer:~$ sudo dpkg-reconfigure mysql-server-5.0

This will pop a "dialog" in your terminal and advise you to set a root password. Verify, tab to <OK> and try logging in again:

user@computer:~$ mysql -uroot -p<password_you_just_set>
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 5.0.75-0ubuntu10.2 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>


~Fin

Thursday, October 22, 2009

Using Tabs in the terminal - Ubuntu 9.04 Jaunty

Using tabs in the terminal to avoid having several terminals opens saves space and time (how did I not know about this earlier!).

Open a terminal and create a new tab using:

<shift> + <ctrl> + T

To switch between tabs using the keyboard:

<ctrl> + <page down>
(Moves one tab right - will loop through all tabs from left to right.)

<ctrl> + <page up>
(Moves one tab left - will loop through all tabs from right to left.)

~Fin

shred a File - Ubuntu 9.04 Jaunty

Computer files containing sensitive information should also be 'shredded'. There is a command line utility on Linux systems called 'shred' that overwrites the file multiple times with random output. If you simply erase a file with 'rm', this only tells the operating system that this part of your hard disk is free for use, but the information still exists until that space is overwritten. Information from a file that has been deleted can still be recovered unless it has been 'shred', making it nearly impossible to recover.

The following command will shred a file, "zero" it (to hide shredding) and then remove it.

user@machine:~$ shred -zuv sensative.file

~Fin

Wednesday, October 21, 2009

Have more visual fun - Ubuntu 9.04 Jaunty

user@machine:~$ sudo apt-get install compizconfig-settings-manager

Then open in:
System --> Preferences --> CompizConfig Settings Manager

Then:
  1. Draw fire on the desktop
  2. Use the desktop cube
  3. Animate maximize, minimize, and other actions.
  4. Other fun stuff I've yet to play with! w00t!
~Fin

Monday, October 19, 2009

Find files larger than a given size in Linux - Ubuntu 9.04 Jaunty

Using the command line, you can search for files larger than a given file size using:

user@machine:~$ find /path/to/directory -type f -size +1024k

This will search for files larger than 1MB (1024k). Obviously you can adjust this number to suite your search requirements.

~Fin

Wednesday, October 14, 2009

How to Create & Extract tar.gz and tar.bz2 Files in Linux - Ubuntu 9.04 Jaunty

How to create a compressed tar.gz file from a folder or file in Linux?
In order to create a compressed tar.gz archive from a folder/file we need to run the following tar command:

tar czf new-tar-file-name.tar.gz file-or-folder-to-archive

Here is the command explanation:

* tar - the tar command.
* c - create new archive.
* z - compress the archive using gzip.
* f - use archive file.
* new-tar-file-name.tar.gz - the name of the tar.gz to create.
* file-or-folder-to-archive - the name of the folder we want to archive.

How to create a compressed tar.gz file from multiple files and folders in Linux?
In order to create a compressed tar.gz file from multiple files or/and folders we need to run the same tar command we used when we archived a single file/folder and to append the rest of the files/folders' names to it.

tar -czf new-tar-file-name.tar.gz file1 file2 folder1 folder2

How to extract a compressed tar.gz file in Linux?
tar -xzf tar-file-name.tar.gz

Here is the command explanation:

* tar - the tar command.
* x - extract the archive.
* z - uncompress the archive using gzip.
* f - use archive file.
* tar-file-name.tar.gz - the name of the tar.gz to extract.

The tar command will extract all the files/folders in the archive to the current directory.

How to extract a compressed tar.bz2 file in Linux?

Extracting tar.bz2 (bzip2 file) is very similar to the way you extract tar.gz file. Instead of using the -z flag you need to use the -j flag for the bzip2 format
tar -xjf tar-file-name.tar.gz

Here is the command explanation:

* tar - the tar command.
* x - extract the archive.
* j - filter the archive through bzip2
* f - use archive file.
* tar-file-name.tar.gz - the name of the tar.gz to create.

The tar command will extract all the files/folders in the archive to the current directory.

~Fin

Execute/install from a .bundle file - Ubuntu Linux 9.04 Jaunty

sudo sh fileName.bundle

~Fin

Monday, October 12, 2009

Show line numbers in VI - Ubuntu Linux 9.04 Jaunty/Mac OS X

Update - verified to work also with Mac OS X

From within VI
:set number

To make this behaviour the default:
user@machine:~$ cd ~
user@machine:~$ touch .exrc
user@machiner:~$ vi .exrc

Add the following line to the file:
set number
user@machine:~$ . .exrc
user@machine:~$ vi someTextFile.txt

Basically, if the file .exrc does not exist in your home directory create it.
Open .exrc for editing.
Add the line (w/o quotes) "set number"
Save .exrc
Source .exrc
Test to verify function.

Update (as I've had to look this up twice now...)
To turn off line numbers from withing VI
:set nonumber

~Fin

Recursive grep on directory - Ubuntu Linux 9.04 Jaunty

grep -r "stringToSearchFor" directoryToBeSearched

Doing some work on Solaris where the "-r" flag is not an option. To do this on Solaris:

/usr/bin/find . | /usr/bin/xargs /usr/bin/grep "patternToSearchFor"

or if your paths are defined simply:

find . | xargs grep "patternToSearchFor"

~Fin

How to start, stop, & restart samba - Ubuntu Linux 9.04 Jaunty

sudo /ect/init.d/samba stop
sudo /ect/init.d/samba start
sudo /ect/init.d/samba restart

~Fin

Thursday, October 8, 2009

How to execute a .bin file - Ubuntu Linux 9.04 Jaunty

user@machine:~$ ll
-rw-r--r-- 1 brad brad 108008954 2009-10-08 08:15 fileToBeExecuted.bin
user@machine:~$ chmod +x fileToBeExecuted.bin
user@machine:~$ ll
-rwxr-xr-x 1 brad brad 108008954 2009-10-08 08:15 fileToBeExecuted.bin
user@machine:~$ sudo ./fileToBeExecuted.bin
[sudo] password for user:
user@machine:~$

~Fin