Archive for January, 2009
Linux: Set IP address through shell
by Ali on Jan.09, 2009, under Linux
To change IP address immediately:
ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up or ifonfig eth0 192.168.1.10/24
route add default gw 192.168.1.1
echo nameserver 192.168.1.1 > /etc/resolv.conf
Linux: User management
by Ali on Jan.02, 2009, under Linux
useradd: Add new users commands:
-d specify home directory
-s shell
-p specify password
-g user’s primary group
-G user’s other group
-m create home directory
The following command creates a user “ali”, adds to groups users and admin and create his home directory:
useradd -g users -G admin -p <password> -d /home/ali -m ali -s /bin/shell
usermod: Modify existing users
Use above switches to modify a user
Add “ali” to another group:
usermod -G <groupname> ali
userdel: Delete a user
Removes the user “ali”. To delete home directories use -r switch:
userdel -r ali
passwd: user Password
Logged on users can just use passwd to change their password. If root is changing a user’s password:
passwd <username>
su: switch user
To switch from current user to another:
su <username>
You may switch from root to another user without entering user’s password, but not the other way around. This will not log off current user. To return to previous user shell type “exit”.
Users, passwords and group information are stored in these files:
Users: /etc/passwd
Groups: /etc/group
Passwords: /etc/shadow