Nothing Arbitrary Development Blog

Display mount points in ubuntu

May 19th, 2011

As you know I really enjoy working with both redhat/centos and ubuntu. Today I was in Ubuntu and wanted to display the mount points and what type of storage they were. I sued this command to do it.

# mount -l
/dev/sda1 on / type ext3 (rw) [uec-rootfs-ebs]
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
devtmpfs on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
/dev/sdb on /mnt type ext3 (rw)

Adjusting Path in linux

March 23rd, 2011

Pre and Post adding to Path

Linux determines the executable search path with the $PATH environment variable. To add directory /this/new/path to the beginning of the $PATH environment variable, use the following:

PATH=/this/new/path:$PATH

To add that directory to the end of the path, use the following command:

PATH=$PATH:/this/new/path

Simple enough. Remember do NOT add the trailing slash to the path that you are adding.

Delete bash shell history

March 2nd, 2011

How to delete shell history in bash. This works on most linux distros.

history -c

Then exit your current shell.

exit

and log back in to shell

ssh username@localhost

Using the find command to remove files

February 25th, 2011

Linux or UNIX find and remove files using the “find” command.

To remove multiple files such as *.jpg with one command:

find . -type f -name “Find-This-File” -exec rm -f {} \;

If you would like to include directories in the removal process use the following (removing the “-type f” no longer specifies only find files):

find . -name “Find-This-File” -exec rm -f {} \;

Example finding all jpg images in the current directory:

find . -name “*jpg” -exec rm -f {} \;

SCP Command Examples

February 22nd, 2011

What is Secure Copy?

scp allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh. Which means it is much more secure than ftp. If possible all transfer should be done over scp.

Examples
Copy the file “helloworld.tar” from a remote host to the local host

$ scp username@remotehost.com:helloworld.tar /transfer/to/local/directory

Copy the file “helloworld.tar” from the local host to a remote host

$ scp helloworld.tar username@remotehost.com:/transfer/to/remote/directory

Copy the directory “foo” from the local host to a remote host’s directory “bar”

$ scp -r foo username@remotehost.com:/transfer/to/remote/directory/bar

Copy the file “helloworld.tar” from remote host “server1.com” to remote host “server2.com”

$ scp username@server1.com:/transfer/to/remote/directory/helloworld.tar \
username@server2.com:/transfer/to/remote/directory/

Copying multiple files “foo.txt” and “bar.txt” from the local host to your home directory on the remote host

$ scp foo.txt bar.txt username@remotehost.com:~

Copy multiple files from the remote host to your current directory on the local host

$ scp username@remotehost.com:~/\{foo.txt,bar.txt\} .

Improve SCP Performance

By default scp uses the Triple-DES cipher to encrypt the data being sent. Using the Blowfish cipher has been shown to increase speed. This can be done by using option -c blowfish in the command line.

$ scp -c blowfish some_file username@remotehost.com:~

It is often suggested that the -C option for compression should also be used to increase speed. The effect of compression, however, will only significantly increase speed if your connection is very slow. Otherwise it may just be adding extra burden to the CPU. An example of using blowfish and compression:

$ scp -c blowfish -C local_file username@remotehost.com:~

Verizon Blackberry Call Forwarding

February 9th, 2011

Here’s how to do call forwarding simply.

To Activate:
Press *72.
Enter the phone number where you want calls to be forwarded. (e.g. *72-908-123-4567).
Press SEND and wait for confirmation. You should hear a confirmation tone or a message.
Press END.

To Deactivate:
Press *73.
Press SEND and wait for confirmation. You should hear a confirmation tone or a message.
Press END.

Simple.

How to Restart MySQL in Red Hat or Fedora Core

January 27th, 2011

If you are using mysql on RedHat Linux (Fedora Core/Cent OS) then use following command (MUST be run at root):

First SSH to the server:

ssh root@{servername}

or login as your user and sudo to root

ssh {username}@{servername}

sudo su

To start mysql server:

/etc/init.d/mysqld start

To stop mysql server:

/etc/init.d/mysqld stop

To restart mysql server

/etc/init.d/mysqld restart

Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service:

  • service mysqld start
  • service mysqld stop
  • service mysqld restart

How to restart apache on a Red Hat server

January 25th, 2011

Restart httpd/apache fc/rhel

service httpd restart

Start httpd/apache fc/rhel

service httpd stop

Stop httpd/apache fc/rhel

service httpd start

You can also run /etc/init.d/httpd restart script

/etc/init.d/httpd restart

DNS flush on mac OSX 10.5 and higher

January 18th, 2011

I needed to clear my dns on my Macbook Pro running OSX 10.6 Snow Leopard. On a *nix server I would run

lookupd -flushcache

to clear my DNS cache.

However after moving websites around using my freshly configured MacBook Pro I needed to do the same. I tried with my usual command but that didn’t work. After a few google links I found the solution.

dscacheutil -flushcache

Add user to a specific usergroup

January 16th, 2011

Within my Redhat server I needed to add a new user to the same groups that I was configured for.

First I needed to find my user groups.

ae@na-unix$ groups ae
ae : webdev wheel

Then I needed to check the other user’s usergroups. I wanted to confirm that they only had their own group.

Read the rest of this entry »