Creating a .profile, displaying system variables, and creating an alias

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:

Here is what I am supposed to do, word for word from my assignment page:

  1. Create/modify and print a .profile that does the following:
    a) Displays the date and time
    b) Lists all the current users
    c) Adds the users home directory and the current directory to the PATH
    d) Changes the prompt to display the current directory

  2. Display the current system variables

  3. Create an alias for a command that will look for your name in the password file

  4. Relevant commands, code, scripts, algorithms:

.profile, alias

  1. The attempts at a solution (include all code and scripts):

Here is what I have for each step above:

  1. Create/modify and print a .profile that does the following:
    a) date
    b) users
    c) export PS1='${PWD} '
    d) PATH=$PATH:$HOME:$PWD

  2. set

  3. alias findmyname="grep /etc/passwd"

A couple questions:

  1. My teacher wants me to print a listing of the profile. Would I just do "touch .profile" and then append (using ">>") the commands to the file, then print it?

  2. I am not sure if my alias is correct. Not sure how to find the exact location of the passwd file

Thanks in advance.

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Brookdale Community College - Lincroft, New Jersey - United States - Dr. Rick Bournique- COMP 145

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

It would be best if you could include an example, in code tags, of what you have tried so far.

For example, here's start of my .profile (nothing to do with your solution). Send a sample that tries to do your assignment.

# echo Entering .profile ...

umask 002

working_on_book=n

export     HISTSIZE=10000
export HISTFILESIZE=10000
export  HISTCONTROL=ignoreboth

To figure out where the password file is, try "man passwd" and look around the man page.

Your profile will live in the .profile file in your home directory, so you can just print that. If you have to append the commands to the .profile that's pretty primitive. If you know how to use some kind of editor, it would be a lot more convenient for you.

I 1st take your 2nd question.

grep "$LOGNAME" /etc/passwd

Your teacher wants to get your username from the passwd file. LOGNAME variable contains your username.

To take your 1st question. It seems she wants you to print that file. So, use

pr -t .profile

Also it may happen that she only wants to display the contents of the profile file. So, use

cat .profile