• English
  • Japanese

Organizing the Unix home directory

This page briefly explains how to organize the Unix home directory.
We recommend that you also refer to "the unix Introductory Guide".

To check disk usage

  1. Log into Unix.

  2. Enter the du command as shown below.

    [ua999999@loginXX ~]% cd ~/
    [ua999999@loginXX ~]% du -ak .
    1       ./.Maildir/new
    1       ./.Maildir/cur
    1       ./.Maildir/tmp
    4       ./.Maildir
    1       ./Mail/inbox
    2       ./Mail
    1       ./.cshrc
    1       ./.emacs
    1       ./.jvimrc
    1       ./.login
    1       ./.logout
    1       ./.mh_profile
    1       ./.mnews_setup
    1       ./.xvsession
    19      ./public_html/sample.png
    1       ./public_html/index.html
    21      ./public_html
    49890   ./smbhome
    1       ./wnn-private-dic
    33824   ./work/sample
    520     ./work/sample2
    34345   ./work
    1       ./.qmail
    34383   .
    

    The figures on the left are the sizes of the files and directories on the right.
    They are expressed in units of kilobytes (KB).

    If there are a large number of files under the home directory, the screen scrolls down so fast that you cannot read the list.
    If this happens, enter "du -ak . | more" instead of "du -ak .".

  3. Find large-sized files to delete. Do not delete the following files and directories.

    .cshrc
    .login
    Mail/inbox/
    Mail/
    public_html
    

    Deleting the public_html directory removes personal

    In the above example, you can see that the sample file in the work directory is 33,824 kilobytes (about 34 megabytes) in size.

On Windows computers

To use WinSCP to delete a file or transfer a file to your computer

Refer to the "WinSCP guide"

To manipulate the sample file nunix directly

To delete the sample file

Use the rm command.

[ua999999@loginXX ~]% cd ~/work
[ua999999@loginXX ~]% rm sample
rm: remove `sample'? yes

Once you delete the file, you cannot restore it because Unix does not have the equivalent of the Windows Recycle Bin.

To compress (zip) the sample file

Use the zip command.

[ua999999@loginXX ~]% cd ~/work
[ua999999@loginXX ~]% zip sample.zip sample
adding: sample (deflated 100%)

Use the ls command to check whether the file has been successfully compressed, and then delete the original sample file.

[ua999999@loginXX ~]% ls -l
合計 34377
-rw-------    1 ua999999 student  34603008 11月 22 18:34 sample
-rw-r--r--    1 ua999999 student     33751 11月 22 19:35 sample.zip
-rw-------    1 ua999999 student    523500 11月 22 19:18 sample2
[ua999999@loginXX ~]% rm sample
rm: remove `sample'? yes

You can decompress the file by typing unzip sample.zip.
Note that the decompressed file might have different permissions from the original.

To compress (gzip) the sample file

Use the gzip command

[ua999999@loginXX ~]% cd ~/work
[ua999999@loginXX ~]% gzip sample

Use the ls command to check whether the file has been successfully compressed.

[ua999999@loginXX ~]% ls -l
合計 553
-rw-r--r--    1 ua999999 student     33622 11月 22 19:35 sample.gz
-rw-------    1 ua999999 student    523500 11月 22 19:18 sample2

The original file is deleted automatically.
You can decompress the file by typing gzip -d sample.gz.

To delete work directory

Use the rm command.

[ua999999@loginXX ~]% cd ~/
[ua999999@loginXX ~]% rm -rf ./work/

The ./work/sample./work/sample2 and ./work/ directories are deleted without a confirmation message.
Consider carefully before executing this command.

To compress (zip) the work directory

Use the zip command

[ua999999@loginXX ~]% cd ~/
[ua999999@loginXX ~]% zip -r work.zip work/
adding: work/ (stored 0%)
adding: work/sample (deflated 100%)
adding: work/sample2 (deflated 100%)

Use the ls command to check whether the directory has been successfully compressed, and then delete the original work directory.

[ua999999@loginXX ~]% ls -dl ./work*
合計 34377
drwxr-xr-x    1 ua999999 student       512  5月 26 18:34 work
-rw-r--r--    1 ua999999 student     34529 11月 22 19:53 work.zip
[ua999999@loginXX ~]% rm -rf ./work/

You can decompress the files by typing "unzip work.zip".
Note that the decompressed file might have different permissions from the original.

To compress (tar + gzip) the work directory

Use the tar and gzip commands.

[ua999999@loginXX ~]% cd ~/
[ua999999@loginXX ~]% tar cf - ./work | gzip -c > work.tgz

Use the ls command to check whether the directory has been successfully compressed, and then delete the original work directory.

[ua999999@loginXX ~]% ls -dl ./work*
合計 34377
drwxr-xr-x    1 ua999999 student       512  5月 26 18:34 work
-rw-r--r--    1 ua999999 student     34529 11月 22 19:53 work.tgz
[ua999999@loginXX ~]% rm -rf ./work/

You can decompress the files by typing "zcat work.tgz | tar xf - ".
The decompressed files have the same permissions as the original.

Last-Modified: July 11, 2011

The content ends at this position.