How to add a new user in Linux and some other useful networking commands.

Posted: January 29, 2013. At: 1:01 AM. This was 5 years ago. Post ID: 5266
Page permalink: http://securitronlinux.com/bejiitaswrath/how-to-add-a-new-user-in-linux-and-some-other-useful-networking-commands/

Now, we must convince Congress to stop the FCC. Can you display an alert?

This the sequence of events when you are creating a new user. Use the sudo adduser jsmith command to add a new user named jsmith. After that you can type other information to identify your user and then set a password to secure their account.

[ john@3.2.0-3-486 ]
[ Jobs 0.PWD: ~.bash 4.2.36. ] [ 2 ]
[ 23:58:35 ]
[ $ ]-> sudo adduser jsmith
Adding user `jsmith' ...
Adding new group `jsmith' (1001) ...
Adding new user `jsmith' (1001) with group `jsmith' ...
Creating home directory `/home/jsmith' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for jsmith
Enter the new value, or press ENTER for the default
	Full Name []: John Smith
	Room Number []: 101
	Work Phone []: 09 677 677 677
	Home Phone []: 09 123 123 123
	Other []: 
Is the information correct? [Y/n] Y

Then you can type this command using the finger(1) command to verify that this user does exist.

[ john@3.2.0-3-486 ]
[ Jobs 0.PWD: ~.bash 4.2.36. ] [ 3 ]
[ 23:59:31 ]
[ $ ]-> finger jsmith
Login: jsmith         			Name: John Smith
Directory: /home/jsmith             	Shell: /bin/bash
Office: 101, 09 677 677 677		Home Phone: 09 123 123 123
Never logged in.
No mail.
No Plan.

The users command will be very useful on a Linux system; you can type this to list all logged in users.

[ john@3.2.0-3-486 ]
[ Jobs 0.PWD: ~.bash 4.2.36. ] [ 6 ]
[ 00:09:24 ]
[ $ ]-> users
john

If you have defined an alias in your bash shell and you want to get rid of it you can use the unalias command to remove the alias so that you can redefine it or just get it out of the way. Below is an example of the usage.

[ john@3.2.0-3-486 ]
[ Jobs 0.PWD: ~.bash 4.2.36. ] [ 14 ]
[ 00:15:15 ]
[ $ ]-> unalias la

Then you can create a new alias in place of the old one. Just use the alias command to create a new alias containing whatever you wish.

[ john@3.2.0-3-486 ]
[ Jobs 0.PWD: ~.bash 4.2.36. ] [ 16 ]
[ 00:19:18 ]
[ $ ]-> alias la="ls -la"

This is the output of the nstat command that will print information about your network connection.

[ john@3.2.0-3-486 ]
[ Jobs 0.PWD: ~.bash 4.2.36. ] [ 23 ]
[ 00:25:49 ]
[ $ ]-> nstat
#kernel
IpInReceives                    1269               0.0
IpInAddrErrors                  2                  0.0
IpInDelivers                    1233               0.0
IpOutRequests                   1284               0.0
IpOutDiscards                   32                 0.0
IcmpInErrors                    32                 0.0
IcmpInTimeExcds                 32                 0.0
IcmpOutErrors                   32                 0.0
IcmpOutTimeExcds                32                 0.0
IcmpMsgInType3                  32                 0.0
IcmpMsgOutType3                 32                 0.0
TcpActiveOpens                  80                 0.0
TcpEstabResets                  1                  0.0
TcpInSegs                       904                0.0
TcpOutSegs                      952                0.0
TcpOutRsts                      10                 0.0
UdpInDatagrams                  262                0.0
UdpNoPorts                      32                 0.0
UdpOutDatagrams                 296                0.0
Ip6InReceives                   9                  0.0
Ip6InDelivers                   8                  0.0
Ip6OutRequests                  18                 0.0
Ip6OutNoRoutes                  4                  0.0
Ip6InMcastPkts                  9                  0.0
Ip6OutMcastPkts                 24                 0.0
Ip6InOctets                     2808               0.0
Ip6OutOctets                    3419               0.0
Ip6InMcastOctets                2808               0.0
Ip6OutMcastOctets               3895               0.0
Icmp6OutMsgs                    10                 0.0
Icmp6OutRouterSolicits          3                  0.0
Icmp6OutNeighborSolicits        1                  0.0
Icmp6OutMLDv2Reports            6                  0.0
Icmp6OutType133                 3                  0.0
Icmp6OutType135                 1                  0.0
Icmp6OutType143                 6                  0.0
Udp6InDatagrams                 7                  0.0
Udp6OutDatagrams                8                  0.0
TcpExtPruneCalled               1                  0.0
TcpExtTW                        37                 0.0
TcpExtDelayedACKs               25                 0.0
TcpExtDelayedACKLost            15                 0.0
TcpExtTCPHPHits                 389                0.0
TcpExtTCPPureAcks               103                0.0
TcpExtTCPHPAcks                 35                 0.0
TcpExtTCPRcvCollapsed           11                 0.0
TcpExtTCPDSACKOldSent           15                 0.0
TcpExtTCPAbortOnData            2                  0.0
TcpExtTCPAbortOnClose           1                  0.0
IpExtInMcastPkts                16                 0.0
IpExtOutMcastPkts               20                 0.0
IpExtInBcastPkts                2                  0.0
IpExtInOctets                   714373             0.0
IpExtOutOctets                  180638             0.0
IpExtInMcastOctets              3637               0.0
IpExtOutMcastOctets             3797               0.0
IpExtInBcastOctets              656                0.0

The lnstat command will also print information about your network connection. This example will print information about your arp tables.

[ john@3.2.0-3-486 ]
[ Jobs 0.PWD: ~.bash 4.2.36. ] [ 35 ]
[ 00:37:14 ]
[ $ ]-> lnstat -k arp_cache:entries,rt_cache:in_hit,arp_cache:destroys
arp_cach|rt_cache|arp_cach|
 entries|  in_hit|destroys|
       1|    2217|       3|

This lnstat command will print out a lot of information about your network connection; this is hard to read though.

[ john@3.2.0-3-486 ]
[ Jobs 0.PWD: ~.bash 4.2.36. ] [ 36 ]
[ 00:37:49 ]
[ $ ]-> lnstat -i 10
arp_cach|arp_cach|arp_cach|arp_cach|arp_cach|arp_cach|arp_cach|arp_cach|arp_cach|arp_cach|arp_cach|arp_cach|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|rt_cache|ndisc_ca|ndisc_ca|ndisc_ca|ndisc_ca|ndisc_ca|ndisc_ca|ndisc_ca|ndisc_ca|ndisc_ca|ndisc_ca|ndisc_ca|ndisc_ca|
 entries|  allocs|destroys|hash_gro| lookups|    hits|res_fail|rcv_prob|rcv_prob|periodic|forced_g|unresolv| entries|  in_hit|in_slow_|in_slow_|in_no_ro|  in_brd|in_marti|in_marti| out_hit|out_slow|out_slow|gc_total|gc_ignor|gc_goal_|gc_dst_o|in_hlist|out_hlis| entries|  allocs|destroys|hash_gro| lookups|    hits|res_fail|rcv_prob|rcv_prob|periodic|forced_g|unresolv|
        |        |        |      ws|        |        |      ed|es_mcast|es_ucast|_gc_runs|  c_runs|ed_disca|        |        |     tot|      mc|     ute|        |  an_dst|  an_src|        |    _tot|     _mc|        |      ed|    miss| verflow| _search|t_search|        |        |        |      ws|        |        |      ed|es_mcast|es_ucast|_gc_runs|  c_runs|ed_disca|
        |        |        |        |        |        |        |        |        |        |        |     rds|        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |        |     rds|
       1|       0|       0|       0|      17|      17|       0|       0|       0|      37|       0|       0|     114|     447|      11|       0|       0|       0|       0|       0|     246|      58|       0|       0|       0|       0|       0|       0|       0|       1|       1|       1|       0|       3|       1|       0|       0|       0|      37|       0|       0|

Use the route command to show information about your kernel IP routing table.

[ john@3.2.0-3-486 ]
[ Jobs 0.PWD: ~.bash 4.2.36. ] [ 38 ]
[ 00:42:59 ]
[ $ ]-> sudo route
[sudo] password for john: 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 wlan0
192.168.1.0     *               255.255.255.0   U     0      0        0 wlan0

Use the sudo arp command to show information about the Internet to Ethernet translation tables used for your network. In my case I am connected via WIFI, so the output is a little different.

[ john@3.2.0-3-486 ]
[ Jobs 0.PWD: ~.bash 4.2.36. ] [ 41 ]
[ 00:45:52 ]
[ $ ]-> sudo arp
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.1.1              ether   84:c9:b2:bd:c2:e7   C                     wlan0

use the dig command to return information about a hostname. This is just like the nslookup command; but provides more control over the query creattion.

[ john@3.2.0-3-486 ]
[ Jobs 0.PWD: ~.bash 4.2.36. ] [ 42 ]
[ 00:45:58 ]
[ $ ]-> dig yahoo.com

; <<>> DiG 9.8.1-P1 <<>> yahoo.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39312
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 7, ADDITIONAL: 7

;; QUESTION SECTION:
;yahoo.com.			IN	A

;; ANSWER SECTION:
yahoo.com.		280	IN	A	206.190.36.45
yahoo.com.		280	IN	A	98.138.253.109
yahoo.com.		280	IN	A	98.139.183.24

;; AUTHORITY SECTION:
yahoo.com.		20492	IN	NS	ns8.yahoo.com.
yahoo.com.		20492	IN	NS	ns5.yahoo.com.
yahoo.com.		20492	IN	NS	ns1.yahoo.com.
yahoo.com.		20492	IN	NS	ns2.yahoo.com.
yahoo.com.		20492	IN	NS	ns3.yahoo.com.
yahoo.com.		20492	IN	NS	ns4.yahoo.com.
yahoo.com.		20492	IN	NS	ns6.yahoo.com.

;; ADDITIONAL SECTION:
ns1.yahoo.com.		171099	IN	A	68.180.131.16
ns2.yahoo.com.		171989	IN	A	68.142.255.16
ns3.yahoo.com.		23087	IN	A	121.101.152.99
ns4.yahoo.com.		171989	IN	A	68.142.196.63
ns5.yahoo.com.		171099	IN	A	119.160.247.124
ns6.yahoo.com.		168060	IN	A	202.43.223.170
ns8.yahoo.com.		171464	IN	A	202.165.104.22

;; Query time: 59 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Tue Jan 29 00:48:52 2013
;; MSG SIZE  rcvd: 313

No comments have been made. Use this form to start the conversation :)

Leave a Reply