Sunday, August 21, 2011

Bash shell auto-completion for Git

Nice Git tweak taken from http://progit.org/book/
Quote:


If you use the Bash shell, Git comes with a nice auto-completion script you can enable. Download the Git source code, and look in the contrib/completion directory; there should be a file called git-completion.bash. Copy this file to your home directory, and add this to your .bashrc file:
source ~/.git-completion.bash
If you want to set up Git to automatically have Bash shell completion for all users, copy this script to the/opt/local/etc/bash_completion.d directory on Mac systems or to the /etc/bash_completion.d/directory on Linux systems. This is a directory of scripts that Bash will automatically load to provide shell completions.


Sunday, April 18, 2010

How to setup/change password in a command line

If changing your own password you just need to run in the terminal this:

passwd

and you will be prompted to enter your current password. Once you do this successfully you need to enter twice the new password.

You may also need to setup one or change the password for another user. Then of course you need to login as root and run the following:

passwd user_name

where user_name is the username of the user in question. The system prompts you to enter the password twice, and that's it.

Saturday, April 17, 2010

How to create new user account in Debian/Ubuntu linux from a command line

The following works in Debian and Ubuntu linux.

The best and least problematic way to create new user account on a Linux system is from a command line:

useradd -m -g group -s /bin/bash new_user_name

After running this code as a root, you will end up with a new account new_user_name, with the correspondingly named home directory, default login shell bash, and belonging to the group group. If -g is not specified, a primary user group will be created with the same name as the user being added to the system.

Some important files related to accounts (for Debian based distros):
  • /etc/passwd - user accounts info
  • /etc/shadow - passowrds (encrypted) and other secure user accounts info
  • /etc/group - group account info
  • /etc/default/useradd - default values for account creation