You are on page 1of 3

A Practical Exercise In Unix Commands

Try these commands using your Unix account and your email address to practice your proficiency with the Unix command line. This will help you with Assignment One! The command to see the usernames of the last group of users to log into the system is called last: last To see the manual page on the last command: man last To see the hostname that the user logged in from, use the a parameter: last a To pause the display after displaying one screens worth of data: last a | more To sort the display by the first character of the output, which is the username: last | sort To sort the display by the first character of the output, which is the username, and pause the display after showing one screens worth of data: last | sort | more To see only the last time that tbegley logged in with the last command: last | grep tbegley and with the hostname tbegley logged in from: last a | grep tbegley

Page 1 of 3

To email you the results of the last command: last | mail email-address To email you the results of the last command, with the hostname listed: last a | mail email-address To email you the results of the last command, with the subject line of Result of the last command on Grackle: last | mail s Result of the last command on Grackle email-address To email you the results of the last command, with the subject line of Result of the last command on Grackle, and sorted by NetID, and showing the hostname: last a | sort | mail s Result of the last command on Grackle email-address To write the output of the last command to a file called last.txt: last > last.txt To write the results of the last command, and sorted by NetID, and showing the hostname, written to a file called last.txt: last a | sort > last.txt To add (append) to the file called last.txt, to write the results of the last command, and sorted by NetID, and showing the hostname, written to a file called last.txt: last a | sort >> last.txt To email you the file called last.txt, with the subject line of Result of the last command on Grackle, cat last.txt | mail s Result of the last command on Grackle email-address

Page 2 of 3

To view the file called last.txt in its entirety: cat last.txt To view the file called last.txt, pausing every screen: more last.txt To delete the file called last.txt: rm last.txt

Page 3 of 3

You might also like