Category Archives: unix

How to change default editor

Each works well with your favorite text editor. It is important that there is a default editor known. In debian and in other linux distro, default editor is vi.

You could change default editor:

  1. during distro installation
  2. custom each user into .bashrc or .profile file with line:
    export EDITOR=/usr/bin/emacs
  3. custom locally in a shell session and/or particular program:
    env EDITOR=nano crontab -e


crontab – maintain crontab files for individual users (V3)
crontab [ -u user ] file
crontab [ -u user ] { -l | -r [ -i ] | -e }

Stamp output about crontab file:
crontab -l

Modify crontab with default editor:
crontab -e

yum segmentation fault in centos

After an upgrading with yum program, yum will end with segmentation fault.

Last link about libz is the cause:
-rwxr-xr-x 1 root root  75028  9 gen  2007
-rwxr-xr-x 1 root bin   96572  8 nov  2010
-rw-r--r-- 1 root bin  101462  8 nov  2010 libz.a
lrwxrwxrwx 1 root root     13  8 apr  2011 ->
lrwxrwxrwx 1 root root     13  8 apr  2011 -> need a different link:
lrwxrwxrwx 1 root root     13  8 apr  2011 ->

Reference: yum fails with segfault after source zlib upgrade


DNS lookup utility.
dig [@server] [-b address] [-c class] [-f filename] [-k filename] [-p port#] [-t type] [-x addr] [-y name:key] [-4] [-6] [name] [type] [class] [queryopt...]
dig [-h]
dig [global-queryopt...] [query...]


Set TimeZone on Centos

CentOS update breaks another thing – the logwatch perl timezone manipulation. The exact error message is:
ERROR: Date::Manip unable to determine TimeZone.

Execute the following command in a shell prompt:
perldoc Date::Manip
The section titled TIMEZONES describes valid TimeZones and where they can be defined.

You could fix it modify /etc/localtime. You could use tzconfig command line and follow its questions or:
cp /usr/share/zoneinfo/Europe/Rome /etc/localtime
If your localtime is different, you could choose your zoneinfo in /usr/share/zoneinfo/.



rdate – get the time via the network
rdate [-p] [-s] [-u] [-l] [-t sec] [host...]
rdate -s

If you want syncronize date, then you could add this line into crontab:
* * * * 0 rdate -s

How to add a directory to my PATH statement or variable

When you type the name of an executable file, GNU/Linux searches for that executable in all the directories specified in the PATH environment variable.
By default, your GNU/Linux distribution probably set up a default PATH variable during install. To see what your current PATH variable is set to, in a terminal window, type:
echo $PATH
and press ENTER. The system should respond by writing out the current value of the PATH variable. That probably looks something like:
To add a directory to the PATH statement is a relatively straight forward process, but first a question needs to be answered:
Note that these instructions are for a bash shell which is very common n GNU/Linux systems. If you are running another shell, please consult the directions for that shell.
Which users do you want to be affected by this new PATH value?
1. In a home GNU/Linux system, it’s likely that there is only one user and therefore the answer is: me and my root account.
2. If you are running a multi-user system, then the answer is likely: everybody and root.
3. Possibly the third answer is: only ‘joe’ or some other single user on the system.
Regardless of which user(s) are to affected, the same line(s) need to be added to a profile file. The only variable is: which file?
The line(s) or code to add are:
export PATH

NOTE: The export command need only be called once in the profile file and after all the PATH statements in that file. If an export command is already present in the applicable profile file (see below), then you need not add another one.
You are going to add these lines to the following location depending on which user(s) you want to affect:

1. To add that PATH to every user but root, add the line(s) to /etc/profile
2. To add that PATH to root, add those line(s) to /root/.bash_profile
3. To add that PATH to a specific user(s), add the line(s) to /home/user/.bash_profile

export PATH


How to add user to group

How can I add a user to a group under Linux operating system?

You can use the useradd or usermod commands to add a user to a group. The useradd command creates a new user or update default new user information. The usermod command modifies a user account i.e. it is useful to add user to existing group. There are two types of group. First is primary user group and other is secondary group. All user account related information is stored in /etc/passwd, /etc/shadow and /etc/group files to store user information.

useradd Example – Add A New User To Secondary Group
You need to the useradd command to add new users to existing group (or create a new group and then add user). If group does not exist, create it. The syntax is as follows:
useradd -G {group-name} username

In this example, create a new user called vivek and add it to group called developers. First login as a root user (make sure group developers exists), enter:
grep developers /etc/group

If you do not see any output then you need to add group developers using groupadd command:
groupadd developers
Next, add a user called vivek to group developers:
useradd -G developers vivek
Setup password for user vivek:
passwd vivek
Ensure that user added properly to group developers:
id vivek
uid=1122(vivek) gid=1125(vivek) groups=1125(vivek),1124(developers)
Please note that capital G (-G) option add user to a list of supplementary groups. Each group is separated from the next by a comma, with no intervening whitespace. For example, add user jerry to groups admins, ftp, www, and developers, enter:
useradd -G admins,ftp,www,developers jerry

useradd example – Add a new user to primary group
To add a user tony to group developers use following command:
useradd -g developers tony
id tony

uid=1123(tony) gid=1124(developers) groups=1124(developers)
Please note that small -g option add user to initial login group (primary group). The group name must exist. A group number must refer to an already existing group.

usermod example – Add a existing user to existing group
Add existing user tony to ftp supplementary/secondary group with usermod command using -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option :
usermod -a -G ftp tony
Change existing user tony primary group to www:
usermod -g www tony



useradd – create a new user or update default new user information

useradd [options] LOGIN
useradd -D
useradd -D [options]

add user jerry to groups admins, ftp, www, and developers, enter:
useradd -G admins,ftp,www,developers jerry
add a user tony to group developers use following command:
useradd -g developers tony