Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For each of these commands, you will execute the command in the Element K Unix e

ID: 3646837 • Letter: F

Question

For each of these commands, you will execute the command in the Element K Unix environment. You can find information on how to enter this environment in the Element K iLab tab under Course Home. Document your results using the lab report document provided in Doc Sharing. The list below shows you which commands you will be using. Please note that the lab report contains the actual command you will type. Document the result of each of the commands you execute, whether there is an observable result or not.

COMMAND

who
whoami
date
cal
clear
ls
cd
pwd
man
printenv
sleep
history
PART 2: Locating a File Within the Directory Structure




Your objective in this activity is to locate a file called Texas.txt. It is located in a subdirectory of: /home. This exercise is designed to give you experience in navigating the Unix/Linux directory structure.

Here is an example of the commands and process you can use to locate the Texas.txt file:

Go to the /home directory
cd /home/xxxxx (where xxxxx is the name of your login)

Change Directory (cd) to some of the directories in /home/xxxxx to find the Texas file.
Find out which directory you're in by typing:
pwd (which means "print working directory")

Use cd and ls until you find the file Texas.txt.
Once you find the file Texas.txt, read it by typing:
more Texas.txt

In your lab report, include your favorite line from the Texas.txt file and the full path name of the directory where the file is located.


PART 3: Identifying UNIX Commands





The story "Who(1)'s on what(1)?" is a very old and funny "story" about Unix. You can find this file in Doc Sharing. Follow the instructions below.
Read the story.
Identify all of the Unix commands and utilities to which it refers.
Look up each command or utility in the man pages.
In your lab report, include a description and an example usage of each of the commands or utilities you have identified.

Explanation / Answer

who: who [options] [file] who am i Show who is logged into the system. With no options, list the names of users currently logged in, their terminal, the time they have been logged in, and the name of the host from which they have logged in. An optional system file (default is /etc/utmp) can be supplied to give additional information. Options -a, --all Equivalent to -b -d --login -p -r -t -T -u. am i Print the username of the invoking user. -b, --boot Print time of last system boot. -d, --dead Print a list of dead processes. --help Print a help message and then exit. -i, --idle Include idle times. An idle time of . indicates activity within the last minute; one of old indicates no activity in more than a day. -l, --login Print list of system login processes. --lookup Attempt to include canonical hostnames via DNS. -m Same as who am i. -p, --process Print active processes spawned by init. -q, --count "Quick." Display only the usernames and total number of users. -r, --runlevel Print the current runlevel. -s, --short Print only name, line, and time. This is the default behaviour. -t, --time Print the last system clock change. -u, --users Print a list of the users who are logged in. --version Print version information and then exit. -w, -T, --mesg, --message, --writable Include user's message status in the output: + mesg y (write messages allowed) - mesg n (write messages refused) ? Cannot find terminal device -H, --heading Print headings. Example This sample output was produced at 8 a.m. on April 17: $ who -uH NAME LINE TIME IDLE PID COMMENTS Earvin ttyp3 Apr 16 08:14 16:25 2240 Larry ttyp0 Apr 17 07:33 . 15182 Since Earvin has been idle since yesterday afternoon (16 hours), it appears that he isn't at work yet. He simply left himself logged in. Larry's terminal is currently in use. date: date [options] [+format] [date] Print the current date and time. You may specify a display format. format can consist of literal text strings (blanks must be quoted) as well as field descriptors, whose values will appear as described in the following entries (the listing shows some logical groupings). A privileged user can change the system's date and time. Options +format Display current date in a nonstandard format. For example: $date +"%A %j %n%k %p" Tuesday 248 15 PM The default is %a %b %e %T %Z %Y (e.g., Tue Sep 5 14:59:37 EDT 2005). -d date, --date date Display date, which should be in quotes and may be in the format d days or m months d days, to print a date in the future. Specify ago to print a date in the past. You may include formatting (see the following section). -f datefile, --file=datefile Like -d, but printed once for each line of datefile. -I [timespec] , --iso-8601[=timespec] Display in ISO-8601 format. If specified, timespec can have one of the following values: date (for date only), hours, minutes, or seconds to get the indicated precision. -r file, --reference=file Display the time file was last modified. -R, --rfc-822 Display the date in RFC 822 format. --help Print help message and exit. --version Print version information and exit. -s date, --set date Set the date. -u, --universal Set the date to Greenwich Mean Time, not local time. Format The exact result of many of these codes is locale-specific and depends upon your language setting, particularly the LANG environment variable. See locale. % Literal %. - (hyphen) Do not pad fields (default: pad fields with zeros). _ (underscore) Pad fields with space (default: zeros). %a Abbreviated weekday. %b Abbreviated month name. %c Country-specific date and time format. %d Day of month (01-31). %h Same as %b. %j Julian day of year (001-366). %k Hour in 24-hour format, without leading zeros (0-23). %l Hour in 12-hour format, without leading zeros (1-12). %m Month of year (01-12). %n Insert a new line. %p String to indicate a.m. or p.m. %r Time in %I:%M:%S %p (12-hour) format. %s Seconds since "the Epoch," which is 1970-01-01 00:00:00 UTC (a nonstandard extension). %t Insert a tab. %w Day of week (Sunday = 0). %x Country-specific date format based on locale. %y Last two digits of year (00-99). %z RFC 822-style numeric time zone. %A Full weekday. %B Full month name. %D Date in %m/%d/%y format. %H Hour in 24-hour format (00-23). %I Hour in 12-hour format (01-12). %M Minutes (00-59). %S Seconds (00-59). %T Time in %H:%M:%S format. %U Week number in year (00-53); start week on Sunday. %V Week number in year (01-52); start week on Monday. %W Week number in year (00-53); start week on Monday. %X Country-specific time format based on locale. %Y Four-digit year (e.g., 2006). %Z Time-zone name. Strings for setting date Strings for setting the date may be numeric or nonnumeric. Numeric strings consist of time, day, and year in the format MMDDhhmm[[CC] YY] [.ss] . Nonnumeric strings may include month strings, time zones, a.m., and p.m. time A two-digit hour and two-digit minute (hhmm); hh uses 24-hour format. day A two-digit month and two-digit day of month (MMDD); default is current day and month. year The year specified as either the full four-digit century and year or just the two-digit year; the default is the current year. Examples Set the date to July 1 (0701), 4 a.m. (0400), 2005 (05): date 0701040095 The command: date +"Hello%t Date is %D %n%t Time is %T" produces a formatted date as follows: Hello Date is 05/09/05 Time is 17:53:39 Call: al [options] [[month] year] Print a 12-month calendar (beginning with January) for the given year, or a one-month calendar of the given month and year. month ranges from 1 to 12. year ranges from 1 to 9999. With no arguments, print a calendar for the current month. Options -j Display Julian dates (days numbered 1 to 365, starting from January 1). -m Display Monday as the first day of the week. -y Display entire year. Examples cal 12 2006 cal 2006 > year_file clear: Clear the terminal display. Equivalent to pressing Ctrl-L. Is ls [options] [names] List contents of directories. If no names are given, list the files in the current directory. With one or more names, list files contained in a directory name or that match a file name. names can include filename metacharacters. The options let you display a variety of information in different formats. The most useful options include -F, -R, -l, and -s. Some options don't make sense together (e.g., -u and -c). Options -1, --format=single-column Print one entry per line of output. -a, --all List all files, including the normally hidden files whose names begin with a period. -b, --escape Display nonprinting characters in octal and alphabetic format. -c, --time-ctime, --time=status List files by status change time (not creation/modification time). --color =when Colorize the names of files depending on the type of file. Accepted values for when are never, always, or auto. -d, --directory Report only on the directory, not its contents. -f Print directory contents in exactly the order in which they are stored, without attempting to sort them. --full-time List times in full, rather than using the standard abbreviations. -g Long listing like -l, but don't show file owners. -h Print sizes in kilobytes and megabytes. --help Print a help message and then exit. -i, --inode List the inode for each file. --indicator-style=none Display filenames without the flags assigned by -p or -f (default). -k, --kilobytes If file sizes are being listed, print them in kilobytes. This option overrides the environment variable POSIXLY_CORRECT. -l, --format=long, --format=verbose Long format listing (includes permissions, owner, size, modification time, etc.). -m, --format=commas Merge the list into a comma-separated series of names. -n, --numeric-uid-gid Like -l, but use group ID and user ID numbers instead of owner and group names. -o Long listing like -l, but don't show group information. -p, --filetype, --indicator-style=file-type Mark directories by appending / to them. -q, --hide-control-chars Show nonprinting characters as ? (default for display to a terminal). -r, --reverse List files in reverse order (by name or by time). -s, --size Print file size in blocks. --show-control-chars Show nonprinting characters verbatim (default for printing to a file). --si Similar to -h, but uses powers of 1,000 instead of 1,024. -t, --sort=time Sort files according to modification time (newest first). -u, --time=atime, --time=access, --time=use Sort files according to file-access time. --version Print version information on standard output, then exit. -x, --format=across, --format=horizontal List files in rows going across the screen. -v, --sort=version Interpret the digits in names such as file.6 and file.6.1 as versions, and order filenames by version. -w, --width=n Format output to fit n columns. -A, --almost-all List all files, including the normally hidden files whose names begin with a period. Does not include the . and .. directories. -B, --ignore-backups Do not list files ending in ~ unless given as arguments. -C, --format=vertical List files in columns (the default format). -D, --dired List in a format suitable for Emacs dired mode. -F, --classify, --indicator-style=classify Flag filenames by appending / to directories, * to executable files, @ to symbolic links, | to FIFOs, and = to sockets. -G, --no-group In long format, do not display group name. -H, --dereference-command-line When symbolic links are given on the command line, follow the link and list information from the actual file. -I, --ignore pattern Do not list files whose names match the shell pattern pattern, unless they are given on the command line. -L, --dereference List the file or directory referenced by a symbolic link rather than the link itself. -N, --literal Display special graphic characters that appear in filenames. -Q, --quote-name Quote filenames with "; quote nongraphic characters. -R, --recursive List directories and their contents recursively. -Rfile, --reload-state file Load state from file before starting execution. -S, --sort=size Sort by file size, largest to smallest. -U, sort=none Do not sort files. -X, sort=extension Sort by file extension, then by filename man man [options] [section] [title] Display information from the online reference manuals. man locates and prints the named title from the designated reference section. Traditionally, manpages are divided into nine sections, where section 1 consists of user commands, section 2 contains system calls, and so forth. By default, all sections are consulted, so the section option serves to bypass the most common entry and find an entry of the same name in a different section (e.g., man 2 nice). Numerous other utilities—such as info, xman, and the Konqueror browser—can also display manpages. Options -7, --ascii Expect a pure ASCII file, and format it for a 7-bit terminal or terminal emulator. -a, --all Show all pages matching title. -b Leave blank lines in output. -d, --debug Display debugging information. Suppress actual printing of manual pages. -f, --whatis Same as whatis command. -k, --apropos Same as apropos command. -l filename, --local-file=filename Search local files, not system files, for manual pages. If i is given as filename, search standard input. -m systems, --systems=systems Search systems' manual pages. systems should be a comma-separated list. -p preprocessors, --preprocessor=preprocessors Preprocess manual pages with preprocessors before turning them over to nroff, troff, or groff. Always runs soelim first to read in files to be included in the one currently being processed. preprocessors can be any combination of e for equations, p for pictures, t for tables, and r for bibliographical references. -r prompt, --prompt=prompt Set prompt if less is used as pager. -t, --troff Format the manual page with /usr/bin/groff -Tgv -mandoc. Implied by -T and -Z. -u, --update Perform a consistency check between manual page cache and filesystem. -w, -W, --path, --where Print pathnames of entries on standard output. -D Display debugging information about how the page was retrieved. -K directory A kind of super-k option. Search for a term in all manpages and display the name of each page, along with a prompt asking whether you want to view the page. -L locale, --locale=locale Assume current locale to be locale; do not consult the setlocale( ) function. -M path, --manpath=path Search for manual pages in path. Ignore -m option. -Ppager, --pager=pager Select paging program pager to display the entry. -S sections Sections to look in for an entry. Like specifying section on the command line, except that multiple section numbers can be specified, separated by colons. -T device, --troff-device[=device] Format groff or troff output for device, such as dvi, latin1, X75, and X100. -Z, --ditroff Do not allow postprocessing of manual page after groff has finished formatting it. Section names Manual pages are divided into sections for various audiences: 1 Executable programs or shell commands. 2 System calls (functions provided by the kernel). 3 Library calls (functions within system libraries). 4 Special files (usually found in /dev). 5 File formats and conventions (e.g., /etc/passwd). 6 Games. 7 Macro packages and conventions. 8 System administration commands (usually only for a privileged user). 9 Kernel routines (nonstandard). printenv printenv [variables] printenv option Print values of all environment variables or, optionally, only the specified variables. Options --help Print usage information and exit. --version Print version information and exit. sleep sleep amount[units] sleep option Wait a specified amount of time before executing another command. units may be s (seconds), m (minutes), h (hours), or d (days). The default for units is seconds. Options --help Print usage information and exit. --version Print version information and exit. cc cc [options] files See gcc. pwd pwd Print the full pathname of the current working directory. See also the dirs shell command built into bash.