unix

Disk Usage

Question: 
How to check disk usage on Unix system

du -hd1 (-h human readable, -d1 depth 1-level)

Unix file permissions

Question: 
How to manage Unix file permissions

There are three levels of security associated with every directory and file.

  • The first is the "owner".
  • The next is the "group". You are assigned to the appropriate group when you get your account.
  • The last level is "other" which is everyone on the system.

You can give or take away permission to read, write, or execute to any of user, group, or other. To see what permissions are set, use the command

ls -l

Here are two lines of example output

-rw-r--r-- 1 jsmit001 student 29607 Jun 16 09:34 tutor.vi

Backing-up and uploading MySQL databases

Question: 
How to back-up and upload MySQL databases on the command line

To back-up use the mysqldump command. For example:

mysqldump -Qq -hdb28.pair.com -uzrtch_2 -p zrtch_mykb > my-dump-mykb.sql

To upload use the mysql command. For example:

mysql -hDBSERVER -uzrtch_26 -p zrtch-espanaviva < dump-espanaviva-13OCT07.sql

Changing Colours on Linux Terminal

Question: 
How to Change Colours on Linux Terminal

1. From the command execute:

dircolors -p > .dirSourceJES

2. Edit colours within .dirSourceJES

3. From the command execute:

eval "`dircolors -b .dirSourceJES`"

Source: http://sos.blog-city.com/changing_colors_in_the_linux_terminal.htm

Locate files with a certain name and show their date

Question: 
How to find files with a certain name and show their date


find . -name "slider.css" -exec ls -al {} \;

Locate a search string in a selection of files

Question: 
Locate a search string in a selection of files on UNIX

Locate a search string in a selection of files

find . -exec grep "swf" '{}' \; -print

The above will search for 'swf' within all files from the current location recursively (including all subdirectories).