Posted: . At: 1:01 AM. This was 11 years ago. Post ID: 5266
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

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

This is 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.

jason@Yog-Sothoth:~$ 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.

jason@Yog-Sothoth:~$ 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.

jason@Yog-Sothoth:~$ users
jason

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.

jason@Yog-Sothoth:~$ 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.

jason@Yog-Sothoth:~$ alias la="ls -la"

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

jason@Yog-Sothoth:~$ 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.

jason@Yog-Sothoth:~$ 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.

jason@Yog-Sothoth:~$ 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.

jason@Yog-Sothoth:~$ 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.

jason@Yog-Sothoth:~$ sudo arp 192.168.1.1
? (192.168.1.1) at c8:14:51:5f:a9:47 on en0 ifscope [ethernet]

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

jason@Yog-Sothoth:~$ dig yahoo.com
 
; <<>> DiG 9.8.3-P1 <<>> yahoo.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53451
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
 
;; QUESTION SECTION:
;yahoo.com.			IN	A
 
;; ANSWER SECTION:
yahoo.com.		238	IN	A	98.139.180.180
yahoo.com.		238	IN	A	98.138.252.38
yahoo.com.		238	IN	A	206.190.39.42
 
;; Query time: 29 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Tue Jan  2 13:50:31 2018
;; MSG SIZE  rcvd: 75

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.