Virtually all Unix systems allow users to log in and run programs over a network from other locations. This feature is intrinsic to Unix systems, and only disabled on certain proprietary or embedded installations. It is possible to use both GUIs and CLIs in this fashion, although GUIs may not work well over slow connections such as a slower home Internet services. Different graphical programs have vastly different bandwidth demands. Some will work fine over a DSL, cable, or WiFi connection, while others require a fast wired connection.
The command line interface, on the other hand, works comfortably on even the slowest network connections.
Logging into a Unix CLI from a remote location is usually done using Secure Shell (SSH).
If you want to remotely log in from one Unix system to another, you can simply use the ssh command from the command line. The general syntax of the ssh command is:
ssh [flags] login-id@hostname
The login-id portion is your login name on the remote host. If you are logging into a campus-managed server, this is likely the same campus login ID used to log into other services such as VPN, email, Canvas, etc.
The first time you connect to each remote host, you will be asked to verify that you trust it. You must enter the full word "yes" to continue:
The authenticity of host 'unixdev1.ceas.uwm.edu (129.89.25.223)' can't be established. ED25519 key fingerprint is SHA256:askjdkj2ksjfdfamnmnmw5lka7jdkjka,mksjdkssfj. No matching host key fingerprint found in DNS. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
If the connection is successful, you will be asked for your password. Note that nothing will echo to your screen as you type the password. Login panels that echo a '*' or a dot for each character are less secure, since someone looking over your shoulder can see exactly how long your password is. Knowing the length reduces the parameter space they would have to search in order to guess the password.
If you plan to run graphical programs on the remote Unix system,
you may need to include the -X
(enable X11
forwarding) or -Y
(enable trusted X11 forwarding)
flag in your ssh command. Run
man ssh for full details.
-X
or -Y
only when
connecting to trusted computers, i.e. those managed by you or
someone you trust. These options allow the remote system to
access your display, which can pose a security risk. For
example, a hacker on the remote system could display a fake
login panel on your screen in order to steal your login
and password.
Examples:
shell-prompt: ssh joe@unixdev1.ceas.uwm.edu
If you have X11 capabilities and used -X or -Y with your ssh command, you can easily open additional terminals from the command-line if you know the name of the terminal emulator. Simply type the name of the terminal emulator, followed by an '&' to put it in the background. ( See Section 1.18.3, “Internal Shell Commands and Symbols” for a full explanation of background jobs. ) Some common terminal emulators are coreterminal, konsole, urxvt, and xterm.
shell-prompt: coreterminal &
If you're connecting to a Unix system from a Windows system, you will need to install some additional software.
The Cygwin Unix-compatibility system is free, quick and easy to install, and equips a Windows computer with most common Unix commands, including a Unix-style Terminal emulator. Once Cygwin is installed, you can open a Cygwin terminal on your Windows desktop and use the ssh command as shown above.
The Cygwin installation is very quick and easy and is described in Section 1.4.1, “Cygwin: Try This First”.
A more limited method for remotely accessing Unix systems is to install a stand-alone terminal emulator, such as PuTTY, https://www.chiark.greenend.org.uk/~sgtatham/putty/. PuTTY has a built-in ssh client, and a graphical dialog box for connecting to a remote machine. For more information, see the PuTTY documentation.
In rare cases, you may be asked to specify a terminal type when you log in:
TERM=(unknown)
Terminal features such as cursor movement and color changes are triggered by sending special codes (characters or character combinations called magic sequences) to the terminal. Pressing keys on the terminal sends codes from the terminal to the computer.
Different types of terminals use different magic sequences. PuTTY and most other terminal emulators emulate an "xterm" terminal, so if asked, just type the string "xterm" (without the quotes).
If you fail to set the terminal type, some programs such as text editors will not function. They may garble the screen and fail to recognize special keys such as arrows, page-up, etc.
You can set the terminal type after logging in, but the methods for doing this vary according to which shell you use, so you may just want to log out and remember to set the terminal type when you log back in.
Remotely log into another Unix system using the ssh command or PuTTY, or open a shell on your Mac or other Unix system. Then try the commands shown below.
Unix commands are preceded by the shell prompt "shell-prompt: ". Other text below refers to input to the program (command) currently running. You must exit that program before running another Unix command.
Lines beginning with '#' are comments, and not to be types.
# List files in the current working directory (folder) shell-prompt: ls shell-prompt: ls -al # Two commands on the same line shell-prompt: ls; ls /etc # List files in the root directory shell-prompt: ls / # List commands in the /bin directory shell-prompt: ls /bin # Create a subdirectory shell-prompt: mkdir -p Data/IRC # Change the current working directory to the new subdirectory shell-prompt: cd Data/IRC # Print the current working directory shell-prompt: pwd # See if the nano editor is installed # nano is a simple text editor (like Notepad on Windows) shell-prompt: which nano If this does not report "command not found", then do the following: # Try the nano editor shell-prompt: nano sample.txt # Type in the following text: This is a text file called sample.txt. I created it using the nano text editor on Unix. # Then save the file (press Ctrl+o), and exit nano (press Ctrl+x). # You should now be back at the Unix shell prompt. # Try the "vi" editor # vi is standard editor on all Unix system. It is more complex than nano. shell-prompt: vi sample.txt Type 'i' to go into insert mode Type in some text Type Esc to exit insert mode and go back to command mode Type :w to save Type :q to quit shell-prompt: ls # Echo (concatenate) the contents of the new file to the terminal shell-prompt: cat sample.txt # Count lines, words, and characters in the file shell-prompt: wc sample.txt # Change the current working directory to your home directory shell-prompt: cd shell-prompt: pwd # Show your login name shell-prompt: id -un # Show the name of the Unix system shell-prompt: hostname # Show operating system and hardware info shell-prompt: uname -a # Today's date shell-prompt: date # Display a simple calendar shell-prompt: cal shell-prompt: cal nov 2018 # Simple math with unlimited precision shell-prompt: bc -l scale=50 sqrt(2) 8^2 2^8 a=1 b=2 c=1 (-b+sqrt(b^2-4*a*c))/2*a 2*a quit # Show who is logged in and what they are running shell-prompt: w shell-prompt: finger # Exit the shell (which logs you out from an ssh session) # This can also be done by typing Ctrl+d, which is the ASCII/ISO # character for EOT (end of transmission) shell-prompt: exit
Make sure you are using the latest version of this document.
Carefully read one section of this document and casually read other material (such as corresponding sections in a textbook, if one exists) if needed.
Try to answer the questions from that section. If you do not remember the answer, review the section to find it.
Write the answer in your own words. Do not copy and paste. Verbalizing answers in your own words helps your memory and understanding. Copying does not, and demonstrates a lack of interest in learning.
Check the answer key to make sure your answer is correct and complete.
DO NOT LOOK AT THE ANSWER KEY BEFORE ANSWERING QUESTIONS TO THE VERY BEST OF YOUR ABILITY. In doing so, you would only cheat yourself out of an opportunity to learn and prepare for the quizzes and exams.
Important notes:
Show all your work. This will improve your understanding and ensure full credit for the homework.
The practice problems are designed to make you think about the topic, starting from basic concepts and progressing through real problem solving.
Try to verify your own results. In the working world, no one will be checking your work. It will be entirely up to you to ensure that it is done right the first time.
Start as early as possible to get your mind chewing on the questions, and do a little at a time. Using this approach, many answers will come to you seemingly without effort, while you're showering, walking the dog, etc.
What must be added to Unix to allow remote access?
Can we run graphical programs on remote Unix systems? Elaborate.
Does the CLI require a fast connection for remote operation?
What command would you use to log into a remote system with host name "myserver.mydomain.edu" using the user name "joe", assuming you want to run a graphical X11 application?
What should you do if someone advises you to use rsh or telnet?
How can Windows users add an ssh command like the one used on Unix systems?
What is the purpose of the TERM environment variable? What will happen if it is not set correctly?