January 3rd, 2008 — News
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. You can follow me on Twitter, too! Thanks for visiting!
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.
January 2nd, 2008 — Basic stuff, Unix
Finding the compiler version in your Unix system should be the first step before you attempt to compile any package from its source codes. In fact, if you're familiar with the common compilation routine, the configure script which you run to generate the Makefile before compiling anything does exactly that - it finds out which compilers (if any) you have installed on your system, and confirms their versions and capabilities.
Continue reading →
December 21st, 2007 — Basic stuff
Now and then I come across a situation when I need to run a script or a Unix command and would like to not only see the output of it on the screen, but also save this output to some log file. Redirecting the standard output using standard Unix stream redirection isn't always useful because your output will either be shown to you, or sent to the file - but not both at the same time
tee command
That's where the tee command becomes really useful. You pipe your output to this command, and let it take care of the rest.
Continue reading →
December 19th, 2007 — Linux, RedHat
If you're a really curious mind, you won't be satisfied with simply knowing the current release of your RedHat Linux, that's why there's a few more commands you could use to satisfy your interest.
RedHat release
If you simply want to confirm whether you're using a RHEL4, RHEL5 or any of the previous RedHat Linux releases, this is the first place to look:
bash-3.1$ cat /etc/redhat-release
Red Hat Enterprise Linux Client release 5 (Tikanga)
RedHat kernel version and type
Next step is to find out the exact Linux kernel version on your system, and also confirm whether it's 64-bit or not:
bash-3.1$ uname -a
Linux rhserver123 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:14 EST 2007 x86_64 x86_64 x86_64 GNU/Linux
RedHat kernel build
For the most curious ones, here's the last command. Use it to confirm who and when compiled the RedHat kernel you're using, and what gcc compiler was used in the build process.
bash-3.1$ cat /proc/version
Linux version 2.6.18-8.el5 (brewbuilder@ls20-bc1-14.build.redhat.com) (gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)) #1 SMP Fri Jan 26 14:15:14 EST 2007
See also:
December 14th, 2007 — Unix
Quite often there's a need for you to take a screenshot of your Unix desktop, and as always there's a number of ways to do it. Today I'm going to cover the command line approach to taking screenshots.
Taking a Screenshot with xwd
Most modern Unix desktop systems come with Gnome desktop environment by default, and use Xorg as their default X11 server. This means you are likely to have the xwd tool in your OS, which allows you to take screenshots.
Continue reading →
December 13th, 2007 — Basic stuff, Linux, Ubuntu
visudo is a tool for safely updating the /etc/sudoers file, found in most Linux systems (Ubuntu for example).
Here's what the Ubuntu man page says about it, I think it's a great summary:
visudo edits the sudoers file in a safe fashion, analogous to vipw(8). visudo locks the sudoers file against multiple simultaneous edits, provides basic sanity checks, and checks for parse errors. If the sudoers file is currently being edited you will receive a message to try again later.
Attention: due to the sensitive content of the /etc/sudoers file, you can only run visudo as root.
December 3rd, 2007 — Linux, Solaris
Mounting an ISO image of a CD/DVD before burning it is one of the basic steps to verifying you're going to get exactly the desired result. It's also a neat trick to access files from a CD/DVD image when you only need a file or two and not a whole CD. Why burn it at all when you can access files much quicker and easier by simply mounting the ISO image?
Every Unix OS has a way to access ISO filesystem, and today I'll only give you examples for Linux and Solaris. In both cases, the two things you need for the example to work are the ISO image itself and an available mount point (basically, an empty directory) on your filesystem to mount it under.
Here's how to mount an ISO in Linux:
# mount -o loop /net/server/linux-bootcd.iso /mnt
November 20th, 2007 — Basic stuff
If you ever need to save the history of your Unix shell session, one of the easiest ways to do it is to use the script command, found in most Unix systems.
Simply provide the file name for your log as a command line parameter:
$ script /tmp/unix-session.log
Continue reading →
November 8th, 2007 — Scripts, Unix
I had a need to scan a huge directory tree today, identifying the users and Unix groups owning all the files. The problem I faced was too long usernames and group names which meant the
find /directory -ls
command which I normally use for such tasks wasn't terribly useful because there was no space delimiter between a username and a group. Results of such scan of the directory tree will have to later be parsed by other tools, and that's why proper splitting of the output into separate fields is so important.
This issue was motivational enough to refresh my Perl skills and sketch the following script (based entirely on this Never Run Unix Find Again article).
Continue reading →
September 25th, 2007 — Basic stuff, Unix
In Unix systems, there are 6 file types. Below I will give a very short description of each.
How to find out the type of file in Unix
The first and most obvious way to confirm the type of a particular file is to use the long-format output of ls command, invoked by the -l option:
$ ls -l *
-rw-r--r-- 1 greys greys 1024 Mar 29 06:31 text
Continue reading →