Log in to users
- Run the ssh client
Use the values in the table below to connect to users.
ssh configuration parameter value protocol ssh ssh version 2 ssh port 22 host users.cs.umb.edu user name your Unix username Authentication method password
- Enter your password
A dialog box will appear on the screen into which you must type the password for your Unix account.
Directory for this Exercise
(When you are ready for me to check this exercise, please scroll back up to where you entered these commands!)
- Make sure you are in your home directory
cd- Go to your it244 directory
cd it244- Go to your ex directory
cd ex- Create an ex09 directory
mkdir ex09- Go to your ex09 directory
cd ex09Start Up a Script Session
Execute the script command, using the --flush option
script --flushHidden Files
- Return to your home directory
cd- Confirm that you are in your home directory
pwd- Look at your hidden files
ls -aThese files configure various settings in your Unix environment.
Startup Files
- Go to my home directory
cd ~ckelly- Look at my "invisible" files
ls -a- Look at the contents of my .bash_profile file
cat .bash_profileThis file runs other files that customize my Unix environment.
- Look at the contents of some of the other files
cat .bashrcWhat you see here may not mean much to you now.
But it will later in this course.Absolute Pathnames
- Go to my course_files/it244_files directory using an absolute pathname
cd /home/ckelly/course_files/it244_filesYou can use this pathname anywhere in the filesystem and will always refer to the same directory.
- Determine your location
pwdNotice that pwd always returns the absolute pathname of your current directory.
- Go to my home directory using an absolute pathname
cd /home/ckelly- Verify that you are in my home directory
pwdTilde ~
- Return to your home directory using tilde ~
cd ~- Determine your current location
pwdYou should be in /home/YOUR_UNIX_ID
- Go to my home directory using tilde ~
cd ~ckelly- Determine your current location
pwdYou should be in /home/ckelly
- Go to your it244 directory using tilde ~
cd ~/it244- Determine your current location
pwdYou should be in /home/YOUR_UNIX_ID/it244.
Notice that, although short, ~/it244 is an absolute pathname and can be used anywhere within this filesystem.The . in a Directory
- Go to your ex09 directory in your it244/ex directory using tilde ~
cd ~/it244/ex/ex09- Look at the entire contents of your ex09 directory
ls -aNotice that you have a . and a .. entry.
The . stands for your current directory.
- Create a file named foo.txt
touch foo.txt- Create a test directory
mkdir test- Enter the test directory
cd test- Determine your current location
pwd- Copy foo.txt from the parent directory into your current directory
cp ../foo.txt .You use . to specify the current directory and .. to specify the parent directory.
- Check that the copy operation worked
ls- Make sure you are in your test directory
pwd- Remove everything from your test directory
rm *- Go back to your ex09 diretory
cd ..- Remove the test directory
rmdir testRelative Pathnames in the Current Directory
- Go to the course_files/it244_files directory in my home directory
cd ~ckelly/course_files/it244_files- Check your location
pwd- List the contents of this directory
ls- Display the contents of fruit.txt
cat fruit.txtSince fruit.txt is in your new current directory, its pathname is simply the filename.Relative Pathnames in a Subdirectory
- List the content of the current directory
ls- List the contents of the dir1 directory using a relative pathname
ls dir1- List the contents of the dir2 directory using a relative pathname
ls dir1/dir2- Display the contents of foo.txt inside dir2 using a relative pathname
cat dir1/dir2/foo.txtRelative Pathnames above the Current Directory
- Go to the dir1/dir2 directory using a relative pathname
cd dir1/dir2- Display your current location
pwd- Display the contents of the course_files/it244_files directory using a relative pathname
ls ../../- Display the contents of the root directory using a relative pathname
ls ../../../../../..Relative Pathnames neither Above nor Below your Current Directory
- Look at the contents of my home directory using a relative pathname
ls ../../../..- Look at the contents of my class notes directory for this course
ls ../../../../public_html/teaching/it244/- Look at the first 10 lines of my notes for today's class
head ../../../../public_html/teaching/common/exercises/linux/intro/exercise_08.htmlLook at the Permissions of Files in a Directory
- Go to your home directory
cd- Make sure you are in your home directory
pwd- Look at the permissions assigned to the contents of your home directory
ls -l- Go to my home directory
cd ~ckelly- Make sure you are in my home directory
pwd- Look at the permissions assigned to the contents of my home directory
ls -lExit Your Script Session
Use the exit command
exitYou should see a confirmation message confirming that the script is finished, resulting in a file called typescriptPractice with Permissions
- Go to your ex09 directory
cd ~/it244/ex/ex09- Make sure you are in the right directory
pwd- Use nano to create the file name.txt
nano name.txt- Enter your name in this file and hit Enter
Then save the file (Control O) and exit (Control X) nano.
- Look at the permissions on this file
ls -l name.txtYou have read and write permission on this file
- Display the contents of name.txt
cat name.txtYou have read permission so you can run cat on it.
- Open name.txt with nano
nano name.txtYou can only open the file if you have read permission.
- Add the city in which you live under your name and hit Enter again
Then save the file (Control O) and exit (Control X) nano.
- Display the content of the file again
cat name.txtYou have write permission so you were able to change the file.
- Remove write permission from this file
chmod 400 name.txt- Look at the permissions for this file
ls -l name.txtYou are the only one who has any permissions on this file.
And all you can do it read it.
- Display the contents of this file
cat name.txt- Open the file with nano
nano name.txt- Try to add Massachusetts as the third line of this file
Try to save (Control O) and (Control X) quit.
You can't because you do not have write privileges.
- Quit nano
Control XWhen asked the following, press "N".Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?- Look at the contents of this file
cat name.txtNothing has changed.
- Remove all privileges from this file
chmod 000 name.txt- Look at the permissions for this file
ls -l name.txt- Try to display the contents of the file
cat name.txtYou can't.
- Try to open the file with nano
nano name.txtYou can't.
- Quit nano
Control X- Restore the original privileges
chmod 644 name.txt- Look at the permissions for this file
ls -l name.txt- Display the contents of this file
cat name.txtRe-Start Your Script Session
Execute the script command, using both the --flush option AND the --append option
script --flush --appendchmod with Numeric Arguments
- Go to your ex09 directory
cd ~/it244/ex/ex09- Make sure you are in the right directory
pwd- Create a test.txt file
touch test.txt- Look at the permissions on your test.txt file
ls -l test.txt- Remove read permission for all but the owner of the file
chmod 600 test.txt- Look at the permissions on your test.txt file
ls -l test.txt- Give read and write permission to everyone
chmod 666 test.txt- Look at the permissions on your test.txt file
ls -l test.txt- Restore the original permissions
chmod 644 test.txt- Look at the permissions on your test.txt file
ls -l test.txt- Delete test.txt
rm test.txtExit Your Script Session
Use the exit command
exitYou should see a confirmation message confirming that the script is finished, resulting in a file called typescriptBash Script for this Exercise
- Go to your ex09 directory
cd ~/it244/ex/ex09- Make sure you are in you ex09 directory
pwd- Create the script ex09.sh
nano ex09.sh- Add the following line, and then skip two empty lines:
# Exercise 9, First Portion- Write into this file the commands you used above, from the sections indicated here.
Include Unix commands from the section Hidden files to the section Relative pathnames neither above nor below your current directory.
- Skip two empty lines, add the following line, and then skip two more empty lines:
# Exercise 9, Second Portion- Write into this file the commands from the previous sections indicated here
Only enter commands from the section chmod with numeric arguments.
- Save this file
Save and quit.
- Test the script
bash ex09.shFix any errors you find.
If you have trouble, see me.