Entries Tagged 'Basic stuff' ↓
February 14th, 2008 — Basic stuff, Unix
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 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.
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 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 →
January 15th, 2008 — Basic stuff, Unix
I've noticed how many people found other pages of this blog trying to find more information about Unix sockets, and so I thought it's about time we shed some light on this seeming mysterious, but really simple concept.
What is a Unix socket?
A Unix socket (the technically correct name for it is Unix domain socket, UDS) is a way of inter-process communication (IPC) in Unix. Like almost everything in Unix, a socket is a file. It's a special file, to be precise. Unix processes which want to communicate between each other use special set of functions to access the special file of a Unix socket, and easily exchange data in both directions.
In very simple terms, a Unix socket is nothing but a byte steam - a data transfer between processes running locally or on networked Unix systems.
January 11th, 2008 — Basic stuff
sudo allows you to run a Unix command as a different user. Using /etc/sudoers file to confirm what privileges are available to you, this command effectively elevates your access rights, thus allowing you to run commands and access files which would otherwise be not available to you.
How sudo command works
The real and effective user id (uid) and group id (gid) are set to match those of the target user as specified in /etc/sudoers file (the safest way to change this file is to use the visudo command - check out the visudo tutorial). The way you use sudo is simple enough: you run this command and specify a command line you'd like to run with the privileges of a different user. Before the requested command is run, you are asked to confirm your identify by providing your user password.
Continue reading →
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 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.
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 →
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 →