Linux help. I am a little lost which commands to use. Thank you for the help! 1.
ID: 3736547 • Letter: L
Question
Linux help. I am a little lost which commands to use. Thank you for the help!
1. File whod is as follows:
pchen72 pts/0 2014-01-15 00:46 (174-26-130-129.phnx.qwest.net)
jmaszk pts/2 2014-01-15 09:47 (sslvpn.172-31-24-198.asu.edu)
bvbui pts/7 2014-01-16 14:12 (bbmobi.mobile.asu.edu)
mtcrowle pts/8 2014-01-16 11:46 (10.142.76.73)
mrchave3 pts/9 2014-01-16 14:58 (mc-pc.mobile.asu.edu)
cnorzaga pts/10 2014-01-16 14:58 (csn-laptop.mobile.asu.edu)
aarroyo3 pts/14 2014-01-16 15:13 (general2.asu.edu)
rarock pts/15 2014-01-16 15:01 (robbie-pc.mobile.asu.edu)
vtanders pts/16 2014-01-16 15:01 (vance-pc.mobile.asu.edu)
fgharo pts/17 2014-01-16 12:13 (en4081450114.etslabs.dhcp.asu.edu)
adelorme pts/18 2014-01-16 15:11 (austin-laptop.mobile.asu.edu)
bsleater pts/19 2014-01-16 15:05 (10.142.168.186)
ktnakas1 pts/20 2014-01-16 15:03 (samuel.mobile.asu.edu)
btlyons1 pts/21 2014-01-16 15:06 (10.140.117.129)
eakers pts/22 2014-01-16 15:06 (easton-aa08e7bb.mobile.asu.edu)
bammons pts/23 2014-01-16 15:06 (bammons21.mobile.asu.edu)
kuitche pts/24 2014-01-16 15:07 (prlta207i01.care.asu.edu)
stmarqu1 pts/25 2014-01-16 15:07 (seth-lap.mobile.asu.edu)
jsstrat1 pts/26 2014-01-16 15:12 (general2.asu.edu)
scamaren pts/27 2014-01-16 15:12 (medusa2.asu.edu)
dlcost pts/28 2014-01-16 15:13 (general.asu.edu)
jaguymon pts/29 2014-01-16 15:12 (otaku.mobile.asu.edu)
armolina pts/30 2014-01-16 15:12 (alex-laptop.mobile.asu.edu)
btlyons1 pts/31 2014-01-16 15:12 (general1.asu.edu)
aepittma pts/32 2014-01-16 15:12 (general2.asu.edu)
samuel pts/33 2014-01-16 15:12 (general.asu.edu)
swcooke pts/34 2014-01-16 15:12 (general.asu.edu)
cnorzaga pts/35 2014-01-16 15:12 (general1.asu.edu)
jtsmit11 pts/36 2014-01-16 15:12 (general.asu.edu)
djeverha pts/37 2014-01-16 15:13 (general2.asu.edu)
kdorer1 pts/39 2014-01-16 15:13 (10.140.115.255)
aarroyo3 pts/40 2014-01-16 15:13 (general1.asu.edu)
cdmurph2 pts/41 2014-01-16 15:13 (10.140.115.207)
ccolbou pts/0 2017-08-26 13:45 (68.2.235.50)
kwxue pts/1 2017-08-26 15:25 (10.141.12.243)
pearson pts/3 2017-08-26 06:34 (184.98.85.186)
lzhu61 pts/4 2017-08-26 14:43 (10.144.87.25)
avuong1 pts/5 2017-08-26 15:35 (10.152.100.245)
ramdisk pts/7 2017-08-22 17:17 (10.106.150.87)
xuehu pts/8 2017-08-26 11:30 (10.143.20.11)
zdienstb pts/9 2017-08-26 15:22 (70.162.164.21)
cschierb pts/10 2017-08-26 15:46 (104.167.172.229)
kuitche pts/11 2017-08-26 14:53 (10.152.112.188)
nfranks1 pts/12 2017-08-26 15:43 (70.176.114.211)
xchen308 pts/13 2017-08-26 13:22 (10.144.16.12)
dzebraus pts/14 2017-08-26 15:10 (64.53.153.77)
dzygadlo pts/15 2017-08-26 15:11 (184.101.72.51)
zcherla pts/16 2017-08-26 15:28 (70.176.115.184)
kagrawa2 pts/17 2017-08-26 15:48 (76.10.12.26)
kohamilt pts/18 2017-08-26 15:46 (45.21.39.213)
cdchapm2 pts/19 2017-08-26 14:30 (70.166.120.172)
lzhu61 pts/20 2017-08-26 14:09 (10.140.172.60)
bvenka19 pts/21 2017-08-26 15:47 (70.162.0.35)
cmadsen1 pts/22 2017-08-26 15:33 (68.99.202.50)
pkalungi pts/24 2017-08-26 15:00 (10.143.198.41)
mthakka2 pts/25 2017-08-26 15:47 (174.17.193.24)
avuong1 pts/26 2017-08-26 15:47 (10.152.100.245)
mdemare1 pts/28 2017-08-26 15:30 (68.2.58.74)
huahongt pts/0 2015-03-17 11:00 (r-laptop-pc.cidse.dhcp.asu.edu)
aalsham4 pts/1 2015-03-07 15:56 (en4085268.cidse.dhcp.asu.edu)
sbatra4 pts/3 2015-03-08 15:12 (:1.0)
samuelml pts/2 2015-03-17 07:49 (:pts/4:S.0)
mlsamuel pts/4 2015-03-17 07:49 (sslvpn.172-31-21-28.asu.edu)
mlsamuel pts/5 2015-03-17 07:50 (:pts/4:S.2)
jschmid8 pts/6 2015-03-17 11:25 (ultra.dhcp.asu.edu)
mburkhar pts/7 2015-03-17 12:35 (10.143.188.76)
mlsamuel pts/8 2015-03-17 07:49 (:pts/4:S.3)
mlsamuel pts/9 2015-03-17 07:49 (:pts/4:S.4)
kuitche pts/10 2015-03-17 12:41 (asup4084949.dhcpeast.asu.edu)
mlsamuel pts/11 2015-03-17 07:49 (:pts/4:S.1)
sbatra4 pts/12 2015-03-09 22:37 (:2.0)
ckurtz pts/14 2015-03-12 10:41 (seclnxvdi04.snm.asu.edu)
rbeerma pts/21 2015-03-17 11:36 (sslvpn.172-31-17-187.asu.edu)
skovatch pts/22 2015-03-17 10:42 (simona.mobile.asu.edu)
drynears pts/25 2015-03-17 10:48 (oked2228.mobile.asu.edu)
ramdisk pts/2 2016-11-28 20:22 (rmrds1.asu.edu)
admarkh1 pts/3 2016-11-30 13:55 (allendm23.mobile.asu.edu)
ybudiya pts/5 2016-11-30 06:22 (ip68-2-208-121.ph.ph.cox.net)
kuitche pts/6 2016-11-30 14:35 (en4106038.tps.dhcp.asu.edu)
ctestama pts/7 2016-11-30 13:07 (macbook-pro-3.dhcp.asu.edu)
jpeng31 pts/8 2016-11-30 14:03 (desktop-tgjm0un.mobile.asu.edu)
ctestama pts/10 2016-11-30 14:00 (macbook-pro-3.dhcp.asu.edu)
hhuang38 pts/11 2016-11-30 14:13 (casual_user.dhcp.asu.edu)
mtwerner pts/12 2016-11-30 14:17 (marks-yoga.mobile.asu.edu)
a.Find out who was logged into the system at 7am on 2015-03-17
b.Get the login info for the user “samuel”
c.How many unique users are logged in on a general machine
d.How many users are logged in more than once on a general machine?
e.For users logged into systems with known valid IP addresses, display usernames, date logged in (yyyy/mm/dd format) and IP address
Explanation / Answer
Hi,
Please find the below details, Hope it helps you !! Below unix commands are executed based on the file provided as example in your question.
a.Find out who was logged into the system at 7am on 2015-03-17
We can do it in 2 ways 1) We can find it from File you provided 2) Directly from the server.
[Chapter]$ grep "2015-03-17 07:00" File
djeverha pts/37 2015-03-17 07:00 (general2.asu.edu)
[Chapter]$
(or)
[Chapter]$ last | grep "Thu Jun 4 17:11"
oracle pts/0 dhcp-aip-ph2-lev Thu Jun 4 17:11 - 17:19 (00:07)
[Chapter]$
b.Get the login info for the user “samuel”
[Chapter]$ awk -F ' ' '{print}' File | grep -w ^samuel
samuel pts/33 2014-01-16 15:12 (general.asu.edu)
[Chapter]$
c.How many unique users are logged in on a general machine,
**** Assuming that general machine is (general.asu.edu)
[Chapter]$ awk -F ' ' '{if ($5 == "(general.asu.edu)") print $1}' File | sort -u
dlcost
samuel
swcooke
jtsmit11
[Chapter]$
d.How many users are logged in more than once on a general machine?
**** Assuming that general machine is (general.asu.edu) and i edited the file to make sure swcooke logged on general machine more than once for testing purpose.
[Chapter]$ awk -F ' ' '{if ($5 == "(general.asu.edu)") print $1}' File | sort | uniq --count | awk -F ' ' '{if ($1 > 1) print $2}'
swcooke
[Chapter]$
e.For users logged into systems with known valid IP addresses, display usernames, date logged in (yyyy/mm/dd format) and IP address
** Assuming known valid IP address as input (10.142.76.73) and be careful while copying the below command and executing it. Please copy as it is while executing and don't remove ">"
[Chapter]$ grep -w "(10.142.76.73)" File | awk '
> BEGIN { FS = OFS = " " }
> { split($3, date, /-/)
> $3 = date[3] "/" date[2] "/" date[1]
> print $0
> }
> '
mtcrowle pts/8 16/01/2014 11:46 (10.142.76.73)
[Chapter]$
** Note all the commands are tested and the output placed after testing.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.