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
~/cse374
directory. -
Make a new directory called
hw1
-
Change directories to that directory
-
Enter
script hw1.script
to 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
now
file should have three lines in it. Use thewc
command to display the number of lines (and only the number of lines) in the file. -
Show the contents of the
now
file- 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
now
file to a file calledpastnow
. -
Go to your home directory, and then enter a command to locate the
pastnow
file 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 -k
to 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
now
in 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
now
file 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
ll
and execute the command you used in step 15. -
Demonstrate your new alias by entering
ll
. -
Enter
vim
to start vim. -
Use
ctrl-z
to suspend vim. -
Bring vim back to the foreground. Then
ctrl-z
again. -
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
grep
to 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 variableUSER
to print[user] is great
, with you as the user, to the screen.- Hint: You can see all the current environment variables by entering
printenv
, or the value in one variable by enteringecho "$VARNAME"
. - My screen says:
amckinn is great
- Hint: You can see all the current environment variables by entering
-
Enter
exit
to stop recording your script.