It is likely worthwhile going through the assignment twice. The first time work out what to do at each step. You can use all the resources at your disposal, including lectures and demos, man files, and Google. Remember that you can also use the history command to look at all the commands you have executed - this may help you review your work in preparation for a second run-through that you record for submission.
Commands¶
-
Change into your
~/cse374directory. -
Make a new directory called
hw1 -
Change directories to that directory
-
Enter
script hw1.scriptto start recording a transcript of your work. -
Display your current working directory
-
Run a command to print
"Bash is fun"to the screen. -
Run the above command and redirect the output to a file called
now. -
Run a command to print the current date and time and append the output to
now. -
Run a command to print the kernel release and append it to
now. -
Your
nowfile should have three lines in it. Use thewccommand to display the number of lines (and only the number of lines) in the file. -
Show the contents of the
nowfile- There are many commands to do this. The commands have subtle differences.
- The autograder will recognize a few straightforward, but probably not all, options.
-
Copy the
nowfile to a file calledpastnow. -
Go to your home directory, and then enter a command to locate the
pastnowfile in your folders.- There are a number of ways to find or locate a file on a Linux system, and more than one way to solve this problem. Remember you can use
man -kto figure out the name of a command you don’t yet know. - These methods have some differences and are not entirely interchangeable. It is worth understanding the differences.
- The autograder will accept a few, but probably not all, solutions.
- There are a number of ways to find or locate a file on a Linux system, and more than one way to solve this problem. Remember you can use
-
Move to the directory with
nowin it. -
List the contents of that directory. Use the option that shows the additional details (permissions, date edited, etc.) about each file.
-
Enter a command to reset the permissions for the
nowfile to read, write & execute for the user, and read & execute only for the group and read only for others. You should do this in one step. -
Use the same command from step 15 to show whether you got it right.
-
Return to your home directory.
-
Define an alias that allows you to type
lland execute the command you used in step 15 -
Demonstrate your new alias by entering
ll. -
Enter
vimto start vim. -
Use
ctrl-zto suspend vim. -
Bring vim back to the foreground. Then
ctrl-zagain. -
Enter a command to list all the processes belonging to your user.
-
Since this might be a lot of processes, re-enter the command and pipe the output through
grepto find the phrase “vim” -
Terminate this process by using a command at your bash prompt.
- You will need to send a signal
-9, or otherwise specify ‘kill’ the process.
- You will need to send a signal
-
And last but not least, use
echo, and the existing environment variableUSERto print[user] is great, with you as the user, to the screen.- Note: Your environment variable may be
USERNAMEinstead ofUSER- use the applicable one - Hint: You can see all the current environment variables by entering
printenv, or the value in one variable by enteringecho "$VARNAME" - My screen says:
dy2018 is great
- Note: Your environment variable may be
-
Enter
exitto stop recording your script.