Entries Tagged 'News' ↓

Ubuntu 8.04 (Hardy Heron) released!

Hi! If you're new here, you may want to subscribe to the Unix Tutorial RSS feed to get regular tips & tricks for all flavors of Unix. Thanks for visiting!

Ubuntu 8.04 TLS

For all of you who were waiting for the next release of Ubuntu, it's finally here! I've been using the beta of Ubuntu 8.04 (Hardy Heron) for the past month or so, and found it an excellent release to work with.

Ubuntu 8.04 links:

atime, ctime and mtime in Unix filesystems

As you know, Unix filesystems store a number of timestamps for each file. This means that you can use these timestamps to find out when any file or directory was last accessed (read from or written to),  changed (file access permissions were changed) or modified (written to).

File and directory timestamps in Unix

Three times tracked for each file in Unix are these:

  • access time - atime
  • change time - ctime
  • modify time - mtime

Continue reading →

How To List Directories in a Directory in Unix

Another quick answer to the question I see a lot in search queries on this blog: listing directories in a directory. I take it that this question means showing a list of only the directories and not other files under a certain location of your Unix filesystem.

Using find to show only directories

find command helps you show only the directories by using a -type d parameter.

Continue reading →

How To Find the Default Block Size in Unix

The questions about default block sizes used in your Unix system are always popular. Today I'd like to show you a few ways to answer them.

Default block size in Linux

If you ever want to confirm the block size of any filesystem of Ubuntu or any other Linux OS, tune2fs command is here to help:

ubuntu# tune2fs -l /dev/sda1 | grep Block
Block count:              4980736
Block size:               4096
Blocks per group:         32768

From this example, you can see that the default block size for the filesystem on /dev/sda1 partition is 4096 bytes, or 4k. That's the default block size for ext3 filesystem.

Default block size in Solaris

The default block size in Solaris is 8192 bytes, or 8k. However, some architectures allow you to use 4k size as well, by specifying it as a command line option for the newfs command.

To be absolutely sure, you can use one of the commands: df -g (takes a filesystem mount point name as the parameter - / or /usr for example) or use fstyp -v command (needs a character device of the filesystem you're interested in).

Using df -g to confirm the filesystem block size

This command can be used as any user, so to confirm a block size for any of the filesystems you don't have to be root. However, it works only for mounted filesystems.

bash-3.00$ df -g /
/                  (/dev/dsk/c1t0d0s0 ):         8192 block size          1024 frag size
12405898 total blocks    4399080 free blocks  4275022 available         751296 total files
603544 free files     30932992 filesys id
ufs fstype       0×00000004 flag             255 filename length

Using fstyp -v to confirm the filesystem block size

Because this command accesses the character device of a particular filesystem, you have to be root to run it. But as a bonus compared to df -g, you can use fstyp -v on an unmounted filesystem:

bash-3.00# fstyp -v /dev/dsk/c1t0d0s0 | grep ^bsize
bsize   8192    shift   13      mask    0xffffe000

How To Find Large Files and Directories in Unix

When you're trying to clean up your filesystems and reclaim some space, one of the first things you'll want to do is to confirm the largest directories and individual files you have. This can be easily done using two Unix commands: find command and du command.

Find files larger than a certain size

It's very simply to find files which are larger than a specified size. The find command accepts a size parameter, and you can specify the limits for file sizes in your command line.

Continue reading →

How to Compare Text Files Using diff

If you need to compare two text files in Unix, you're mostly likely to use the diff command.

Today I'll talk about the simplest scenario: you want to compare two files and understand if there are any differences.

Continue reading →

How To Find Out User ID in Unix

There's quite a few ways to confirm a user ID (uid) in Unix.

id command

This is probably one of the easiest ways to find out a uid of a particular user in your system:

# id -u greys
500

The most common way of using the id command is even simpler, and it gives you all the information about a user you may need:

# id greys
uid=500(greys) gid=500(greys) groups=500(greys)

This not only shows you the user id (uid), but also confirms user's group id (gid) and all the rest Unix groups a user belongs to.

Continue reading →

Solaris Devices

This is a very brief introduction into navigating the device paths in Solaris. I'm using a Solaris 10 installed on Sun v490 for all the commands shown below.

Device files in Solaris

Even though all the block and character special device files are traditionally found under /dev directory, if you look closer at your Solaris 10 setup you will notice that they're not the device files themselves, but instead are just symbolic links to device files under /devices directory.

Solaris uses /devices directory for representing all the physical hierarchy of installed devices and buses found on your hardware system.

Continue reading →

Unix Tutorial update: Reference page

Looking at this website access logs, I see how many people share the same problems and look for the same solutions, but use vastly different search queries to get to my posts.

I've decided to make your life easier, and have just launched a Unix Tutorial Reference page, which is an index of pages based on your searches. Most pages will have a basic introduction to the topic and provide further pointers to the solution posts.

How To: Use apt-get behind proxy

If you run your Ubuntu system behind a firewall and have to use proxy server for http and ftp access, then your apt-get on a newly installed Ubuntu system will probably not work.

To make it use proxy, simply set the http_proxy environment variable. Once you get it working (try something like apt-get update), you'll probably want to add it to your .bashrc file.

Continue reading →