March 24th, 2008 — Basic stuff, Linux, Ubuntu
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!
I see that my Finding Large Files and Directories post is quite popular, yet there are a few more ways to simplify your search for the largest disk space consumers in your Unix system.
Make find command show file sizes
If you remember, the default way a find command reports results includes only the fully qualified (that means including the full path) filenames.
Now, if you look at a task of identifying the largest files, it's great if you can get a list of all the files bigger than some figure your specify, but what would be even better is to include the exact size of each file right into the output of the find command.
March 20th, 2008 — Basic stuff
Surprisingly, I see quite a fe questions around file ownership asked all the time. And one of the first questions asked concerns the Unix user who owns a particular file.
It's very easy to confirm who the owner of a file is, and you can do it using the ls command.
March 18th, 2008 — Advanced topics, Linux, RedHat, Ubuntu
You probably know that modern Linux distributions have many things in common. Well, one of the reasons for this is LSB - Linux Standard Base. LSB is a joint project by a number of Linux vendors to standardize the OS environment.
From Linux Standard Base article on Wikipedia:
The goal of the LSB is to develop and promote a set of standards that will increase compatibility among Linux distributions and enable software applications to run on any compliant system. In addition, the LSB will help coordinate efforts to recruit software vendors to port and write products for Linux.
One of the immediate benefits of LSB compliancy is ability to confirm the exact information about your Linux release using the lsb_release command. By exact information I mean the release version, vendor name and most interestingly the codename of your current Linux release.
Continue reading →
March 11th, 2008 — News
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 →
February 14th, 2008 — Basic stuff, Unix
I can see some of you have arrived to my Unix file types post looking for an example of using symlinks in Unix. Today I would like to give you a quick introduction into Unix symlinks.
What is symlink?
Symlink is a short name for symbolic link (sometimes also referred as soft link) is a special type of file in Unix, which references another file or directory. Symlink contains the name for another file and contains no actual data. To most commands, symlinks look like a regular file, but all the operations (like reading from a file) are referred to the file the symlink points to.
February 12th, 2008 — Perl
A few months ago, I've given a really simple example of using Perl for parsing directory trees in Unix. If you looked closer at it, you would have noticed that the script was working fine, but showing file modes as strange large numbers which didn't look like the usual file permissions you would expect. Today I'm going to explain why this happens, and show you how to find out a user type in Perl.
lstat and stat functions, return, among other things, the file mode value. While it looks confusing initially, it is in fact quite simply a combination field, which includes both the file type and all the permissions for it. If you print this field as a single decimal number, you will not recognize it, but if you simply convert it to octal, you will immediately start seeing the pattern:
Mysterious mode 33261 from the example below becomes 100755 when converted into octal, and you can easily see then the permission part of it: 0755.
Continue reading →
February 7th, 2008 — News
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 →
January 30th, 2008 — Basic stuff
If you know the name of a particular user on your Unix system and just want to confirm the primary Unix group (gid) of this individual, just use the id command:
$ id -g greys
115
Continue reading →
January 23rd, 2008 — News
There's quite a few ways to confirm a user ID (uid) in Unix.
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.
January 21st, 2008 — Basic stuff
bash (Bourne Again SHell) comes with pretty much every Unix-like OS these days. If you ever wonder what exact version of bash shell you have on your system, here's how you find out: just use the –version parameter in the command line.
Using /bin/bash to tell its version
On RedHat Linux, this is how it might look:
bash-2.05b$ /bin/bash –version
GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.
Continue reading →