Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Apr 022011
 

How to rename a user in Linux?

Answer:

Firstly, you need to have a account with root privileges (You cannot change the account name if you have this user currently logged in)

To rename a user, do the following steps:

1. Rename user

# sudo usermod -l new_user -d /home/new_user -m old_user

2. Update group (Usually the same as user name)

# sudo groupmod -n new_user old_user

That's all.

Mar 282011
 

Swap last two characters in Bash

Answer:

Sometimes it is easy to mis-type characters in the wrong order, e.g. typed "sl" instead of "ls"

To swap it, use the little know Bash's trick: Ctrl + t

E.g.

# sl 
[Ctrl + t]
Mar 242011
 

Allow a remote IP for incoming connection in UFW (Uncomplicated firewall)

Answer:

To allow a remote IP for incoming connection in Ubuntu's UFW (Uncomplicated firewall), you can use the following command:

# sudo ufw allow from x.x.x.x

Of course you need to reload the firewall.

# sudo ufw reload

Mar 082011
 

Disable auto indent when pasting text into vim

Answer:

When you copy multiple lines text and paste it into the vim , sometimes you might find the text is aligned wrongly as the following:

Line1 
    Line 2
        Line 3
            Line 4

To solve this problem, enter the paste mode by

: set paste

Then do all the pasting works, and when finished, type

: set nopaste