Logging in to users
- Run the ssh client
Use the values in the table below to connect to the virtual machine we'll be using in this class.
In the value for "host" listed below, the first part of the string, "users", specifies the machine, on the Unix network, that you will connect to.
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.- Confirm that you are connected
You should see the following:Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-171-generic x86_64)- Learn More About the Machine to Which You Are Connected
The uname command displays information about the machine you are using.uname -aWhen used with the -a option, uname displays more information than just the name of the machine.Your Shell
- Determine Your Current Shell
The easiest way to determine your current shell is to use the ps (process status) command.psThe ps command shows all your running processes, including your shell, bash.Explore Your Home Directory
- Learn Your Current Location
At every point in your Unix session, you are working inside some directory.
When you log in, you will be in your home directory.
You can create subdirectories inside your home directory, and customize your environment through special files located here.
To determine your current location, you will use the pwd command, which stands for "print working directory".pwdNotice that your home directory has the same name as your username, and is located inside /home.
This is true for all users.- Look at the Contents of Your Home Directory
The ls command (for "list"), when used with no arguments will display the contents of your current directory.lsYou should see at least one directory - it244. This is where you will submit your homework assignments.- Look at Your "Invisible" files
ls, when used without the proper option, ls will not show files whose first character is a ".".
These special files are used to change features of your Unix environment.
To see these files, you need to use ls with the -a option:ls -a- Forward Your Unix Account Emails to Another Email Address
You can forward the emails sent to your Unix email account by creating a .forward file.
The .forward file contains the email address you want your Unix email to be forwarded to.
To do this, we will use a Unix trick.
Since I haven't introduced you to a Unix text editor yet, we'll use the cat command instead.
Later, when we talk about redirecting the input and output of a command, you'll understand why this works.
Where I have written "Control D" below, you should hold down the Control key while pressing the key for the letter "D".
Where I have written YOUR_EMAIL_ADDRESS, enter your UMass Boston e-mail address. Where you see [Enter], that means to press the Enter key.cat > .forward [Enter] YOUR_EMAIL_ADDRESS [Enter]Press Ctrl-d and then press the Enter key- View the Contents of the file you just created.
cat .forwardIf you make a mistake, simply repeat the procedure.
The file contents will be overwritten by the new text you enter.- Test your .forward file
Send an email to YOUR_UNIX_USERNAME@cs.umb.edu
If forwarding is working, then you should see this message in your email account after a minute or two. If you get an error message, or nothing happens, then don't worry about it.Create ex and ex6 Directories
- Make sure you are in your home directory
cd- If your it244 directory was created and it now exists, then go into it. (Otherwise, we'll need to help you set it up.)
cd it244- Create an ex directory
mkdir ex- Go to your ex directory
cd ex- Create an ex6 directory
mkdir ex6- Go to your ex6 directory
cd ex6nano
- Run nano creating a text file named today.txt
nano today.txt- Practice with nano
Write a few sentences about what you did today.
Use as many of the nano commands, which you see at the bottom of the page, as you can.
The ^ character you see before each letter in the help menu at the bottom of the page tells you to hold down the Control key as you type the letter of the command.
Some important commands do not appear in the menu.
Control A will take you to the beginning of the line, Control E will take you to the end of the line, and Control K will delete the current line.
When you use Control K, the line you deleted is placed in a buffer.
You can get this line back, pasting it in your current position in the file. using Control U.- Save the file
Control OAfter typing this command, the file name will appear at the bottom of the screen.
Hit Enter, to indicate that this is the correct file name.- Quit nano
Contrl X- Look at the contents of the file
cat today.txtscript
- Run script
script --flush- Move to your home directory
cdIf you run cd without any arguments, it will take you to your home directory.
- Determine your current location
pwdYou should be in/home/YOUR_UNIX_ID- List the contents of your home directory
ls- Quit script
exit- Determine your current location
pwdYou should be in/home/YOUR_UNIX_ID/it244/ex/ex6When you run script, a sub-process is generated which contains a new instance of the Bash shell.
Any changes you make to your environment, such as your current location, disappear when you exit script.
Since you started script in your ex6 directory, that is where you will return when you exit.
Any files you created or changed while you were using script will remain as you left them in your script session since they are part of the file system, not your environment.- Look at the typescript file
cat typescript- Run script again, adding you new session to typescript
script -a- Look at the value of the SHELL variable
echo $SHELLPay attention to capitalization. Unix is case sensitive.- Quit script
exit- Look at the typescript file
cat typescriptYou should see the echo command you just invoked, along with its results.Stopping the Execution of a Command
- Run a command that cannot finish
To see how this works, we'll try to run ssh using an account on users that doesn't exist.ssh foo@users.cs.umb.eduIf you get a message saying the authenticity of host cannot be established, type "yes".
No password you can enter will allow this command to complete, because you are trying to log into an account that does not exist.- Abort the program
Control CThis is the only way you can get out.Command Line Editing Practice
- Type something at the command line
foo bar bletch- Move to the beginning of the command line
Control A- Move to the end of the command line
Control E- Clear the command line
Control UUse the History Feature
- Retrieve the last command
⇑- Retrieve the command before that
⇑- Return to the last command
⇓Look at a man Page
- Run man on ls
man ls- Scroll down one screen
Space- Scroll down one line
Enter- Scroll up one line
⇑- Scroll down one line
⇓- Quit man
qExperiment with apropos
- Run apropos on the word "link"
apropos linkUse info
- Run the info command on the word "link"
info link- Display the help menu
h- Close the help menu
x- Quit info
q- Run info without an argument
infoYou should see the first page of the info system.- Look at the file permission entry
mAt the bottom of the screen, you should see the following promptMenu item:Enter the "File" then hit the Tab key, then press Enter.- Go to the previous node
pYou should see the entry for "Numeric operations"- Return to the File permissions node
n- Look at the "Mode Structure" Link
Keep hitting the down arrow until you are on the line with an * and the words "Mode Structure"
Hit Enter
You should see the "Mode Structure" page- Quit info
q