Author: Ruwantha Nissanka

3 ways to create and secure passwords in linux

In this guide, Three methods for setting passwords are explained; Using the passwd command Using openssl Using the crypt function in a C program passwd Passwords of users can be set with the passwd command. Users will have to provide their old password before twice entering the new one. As you can see, the passwd tool will do some basic verification to prevent users from using too simple passwords. The root user does not have to follow these rules (there will be a warning though). The root user also does not have to provide the old password before entering the new password twice. encryption with passwd Passwords are stored in an encrypted format. This encryption is done by the crypt function. The easiest (and recommended) way to add a user with a password to the system is to add the user with the useradd -m user command, and then set the user’s password with passwd. encryption with openssl Another way to create users with a password is to use the -p option of useradd, but that option requires an encrypted password. You can generate this encrypted password with the openssl passwd command. The openssl passwd command will generate several distinct hashes for the same password, for this it uses a salt. This salt can be chosen and is visible as the first two characters of the hash. encryption with...

Read More

How to manage users in linux

User management on Linux can be done in three complementary ways. You can use the graphical tools provided by your distribution. These tools have a look and feel that depends on the distribution. If you are a novice Linux user on your home system, then use the graphical tool that is provided by your distribution. This will make sure that you do not run into problems. Another option is to use command line tools like useradd, usermod, gpasswd, passwd and others. Server administrators are likely to use these tools, since they are familiar and very similar across many different distributions. This guide will focus on these command line tools. A third and rather extremist way is to edit the local configuration files directly using vi (or vipw/vigr). Do not attempt this as a novice on production systems! /etc/passwd The local user database on Linux (and on most Unixes) is /etc/passwd. As you can see, this file contains seven columns separated by a colon. The columns contain the username, an x, the user id, the primary group id, a description, the name of the home directory, and the login shell. More information can be found by typing the following command #man 5 passwd Useradd You can add users with the useradd command. The example below shows how to add a user named chris (last parameter) and at the same time...

Read More

How to run a program as another user on Linux

The sudo program allows a user to start a program with the credentials of another user. Before this works, the system administrator has to set up the /etc/sudoers file. This can be useful to delegate administrative tasks to another user (without giving the root password). The screenshot below shows the usage of sudo. User ‘rd’ received the right to run useradd with the credentials of root. This allows ‘rd’ to create new users on the system without becoming root and without knowing the root password. #/usr/sbin/useradd -m paul First the command fails for user rd. But with sudo it works. su – $username By default, the su command maintains the same shell environment. To become another user and also get the target user’s environment, issue the su – command followed by the target username. #su - john Visudo Visudo edits the sudoers file in a safe fashion. Visudo locks the sudoers file against multiple simultaneous edits, provides basic sanity checks, and checks for parse errors. Check the man page of visudo before playing with the /etc/sudoers file. sudo su – On some Linux systems like Ubuntu and Xubuntu, the root user does not have a password set. This means that it is not possible to login as root (extra security). To perform tasks as root, the first user is given all sudo rights via the /etc/sudoers. In fact all users that...

Read More

Over 16,000 readers, Get fresh content from “The Linux juggernaut”

Email Subscribe

ABOUT ME..!

My photo
My name is Surendra Kumar Anne. I hail from Vijayawada which is cultural capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. At present I work at Bank of America as Sr. Analyst Systems and Administration. You can contact me at surendra (@) linuxnix dot com.