Difference between revisions of "Linux - Terminal"

From Computer Science
Jump to: navigation, search
(On Windows)
 
Line 83: Line 83:
 
sudo apt install atom
 
sudo apt install atom
 
</pre>
 
</pre>
''Other Linux distributions'' use different package managers.  If you use a different Linux distribution and are unable to figure out how to install packages you can ask your instructor, the associate chairperson for CS, or the CS system administrator.
+
''Other Linux distributions'' use different package managers.  If you use a different Linux distribution and are unable to figure out how to install packages you can ask your instructor, your CS advisor, or the CS system administrator.
  
 
After installing the above programs you can open them from the terminal (i.e., to open filezilla you type the command, filezilla).  The programs may also appear in the graphical menu of programs.
 
After installing the above programs you can open them from the terminal (i.e., to open filezilla you type the command, filezilla).  The programs may also appear in the graphical menu of programs.

Latest revision as of 16:19, 5 January 2023

This page is meant to get you started using a terminal program on your personal computer to connect to the CS server.

CS User Accounts

In order to connect to the CS server you will also need your CS user account. CS accounts are normally distributed during the first week of classes. If you are a CS major, you can also request a permanent CS account. See CS Accounts and CS Lab Computers.

ISU CS Lab Computers

The computers in ISU CS labs (Root Hall A-015, A-017, A-019) and GA offices are already configured with Linux. As is standard in Linux, these computers already have a terminal program installed and ready to use. You can verify this as follows.

  • Login to the lab computer with your CS user account information.
  • Click on the icon in the lower left part of the screen (looks similar to the Windows Start button). Start typing either "terminal" or "shell" and click of the results to open the terminal program.
  • You now have a terminal program open.
    • You can type the following to confirm with system you have logged into: hostname
    • You can type the following to login to the CS server and verify that you are logged in there.
ssh cs.indstate.edu
hostname

You can then logoff of the CS server by typing: exit

Note that the lab computers use a networked file system so that you will see your CS account directories when you login to these systems. This means your Documents folder, Downloads folder, and so forth. These are the same files that you will also see when you login to the CS server.

Your Personal Computer

If you are using MacOS, Linux, or an up to date Windows system then you already have a terminal program installed. You don't need to install anything, you just need to follow some steps to use the terminal program that is already installed.

On Windows

Windows 10 The built-in terminal program on Windows 10 is called "Command Prompt".

  • Click the start button, start typing "Command Prompt" and click the program to start it. When this opens you are running commands on your own computer.
  • A few of the commands that you can use are: dir to see a listing of files, cd to change the directory you are looking at, and help to see a list of other commands.
  • To connect to the CS server, you should run the following command: ssh USERNAME@cs.indstate.edu but with "USERNAME" replaced by your CS account (e.g., it could be cs15123, or something along those lines), and at the prompt type your CS account password and press enter.
  • Once your password is accepted, you will be running commands on the CS server (e.g., ls, hostname).
  • When you done, you can run the exit command to close your connection with the CS server. You can run the exit command again to close the Command Prompt.

Windows 11

Mac OS

  • On Mac OS - Built-in Terminal - video demo Use the built-in Terminal program in Mac OS to connect to the cs server, and you can also use the Terminal program to run commands on your local computer. You open the terminal by opening Finder, then click on Applications, then click on Utilities, then open Terminal. When you get the terminal program open, you can login remotely to the CS server by typing "ssh username@cs.indstate.edu" and enter/return (but with your CS username).

Chromebook

  • On Chromebook - Install the Secure Shell app - video demo, Download Chrome Extension configuration
  • On Linux - Built-in Terminal - Similar to MacOS, a terminal program is already built-in. How to get to the terminal program (also called the "shell") depends on which distribution you are running - ask the internet where to find the terminal program for your distribution. When you get the terminal program open, you can login remotely to the CS server by typing "ssh username@cs.indstate.edu" and enter/return (but with your CS username).

File Transfer Program

You will eventually need to transfer files between your personal computer and the CS server. Most OSes have built-in support to do this, but there are other options that are easier to use. We recommend choosing a file transfer program to install. For Windows or Mac you will download the installer to install the program. If you are using Linux or Chromebook, see the sections below about these environments.

  • CyberDuck - works for MacOS or Windows, is freeware, click the large "Download for Windows" or "Download for macOS" in the middle of the page.
  • WinSCP - works for Windows, scroll past ads and click the "Download WINSCP" button.
  • gFTP - good option for Linux, see below about Linux for how to install.

Note - the first time you connect to the CS server with a terminal or file transfer program, you will be notified that the identity of cs.indstate.edu cannot be verified, an ECDSA key will be displayed, and you will be asked if you still want to connect. Type or click yes.

Note - make sure to choose "sftp" as opposed to "ftp" when connecting. ftp is not encrypted and is disabled on the CS server (it will not work). sftp is encrypted and is what we use.

Text-based sftp program that is already installed on many systems - see OS Specific Notes below

Text Editor

Note that while you are using a terminal that is connected to the CS server you can use text-based editors - nano, emacs, vim, jove (see Linux Terminal - Text Editors for more on how to get started with these). You will eventually want to have a good text editor on your personal computer.

The following are four good options that are cross-platform - can be installed on Mac, Windows, Linux, and Chromebook. If you already use some other option (e.g., Visual Studio Code, Eclipse, Notepad++, or anything else that is used by programmers) feel free to keep using what you are already using. Note that Word is not a text editor - it does not store files in plain text, which is what is needed for programming.

  • Kate - make sure to download the "release" installer.
  • Submlime - used by Luke May.
  • Emacs - used by Jeff Kinne, click "GNU/Linux", "Windows", or "MacOS" depending on your OS and follow the instructions.
    • For Windows, download is from https://ftp.gnu.org/gnu/emacs/windows/, choose the latest emacs-## folder to click on, then download the zip file at the bottom that ends in "-x86_64.zip", extract the zip to somewhere to keep the program (e.g., C:\Program Files\), then run the file runemacs.exe in the bin directory.
    • For macOS, the easiest install is from https://emacsformacosx.com/
  • Vim - used by Geoff Exoo. For Windows, download and run the "self-installing executable". For macOS download and run MacVim.dmg from https://github.com/macvim-dev/macvim/releases/latest
  • VS Code
  • ne (nice editor)

When starting a new text editor do an internet search for a tutorial to get you started; once you are comfortable with the basics do an internet search for a cheat sheet of keyboard shortcuts to help you remember them.

Installing for Linux

Most Linux distributions have their own package management systems, with the programs mentioned on this page being installable via the package management system. There often is a graphical interface to the package management system, and there is normally a text-based interface - you type commands on the terminal to install packages.

Debian, Ubuntu, and related Linux distributions use the APT package manager, and you can install the programs mentioned on this page by entering the following commands in the terminal. Note that you will likely be asked in the terminal whether you want to install the package, you need to type Y and press enter.

sudo apt update  # makes sure APT has the latest information about packages available
sudo apt install emacs
sudo apt install kate
sudo apt install gftp
sudo apt install vim
# Note - installing atom requires adding the repository where atom is kept
wget -qO - https://packagecloud.io/AtomEditor/atom/gpgkey | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" > /etc/apt/sources.list.d/atom.list'
sudo apt update
sudo apt install atom

Other Linux distributions use different package managers. If you use a different Linux distribution and are unable to figure out how to install packages you can ask your instructor, your CS advisor, or the CS system administrator.

After installing the above programs you can open them from the terminal (i.e., to open filezilla you type the command, filezilla). The programs may also appear in the graphical menu of programs.

Chromebook

On Chromebook you can choose whether to install apps and do all of your work connected to the CS server, or install Linux on your Chromebook and then use the instructions above on installing the programs.

Using apps - Install the following apps.

  • Text Editor - Text
  • Terminal Program - Secure Shell
  • File Transfer Program - use the builtin Files app along with the Secure Shell app, configure as follows.
    • Open the Files app.
    • Click on the triple-dots in the upper right of the Files app, click Add new service, click Secure Shell App.
    • On the Secure Shell App screen that comes up, enter your login information with cs.indstate.edu as the server and 22 as the port. Then click SFTP Mount.
    • Go back to the Files app and you will see LOGIN@cs.indstate.edu:22 as an option on the left.

Linux (Beta) on Chromebook

  • Not all chromebooks allow installation of Linux (Beta). If this works then you will have Linux installed on your Chromebook and will be able to use any of the commands that you use on the CS server.
  • Follow instructions from google.
  • Note - installation could take a very long time (e.g., an hour or more). If installation fails you may need to select Remove Linux Beta and try again.
  • Once installation is complete you open a terminal using the Terminal app. To install the programs mentioned on this page follow the instructions above for Linux (using the APT package manager commands).
  • After the programs are installed you can open them by typing the command in the Terminal or by opening them as apps.

Copy/paste - in either the Secure Shell app or the Terminal app, copy/paste as follows. To copy, simply select text with the mouse and it will be copied to the clipboard. To paste, do a triple-click (three finger click).

Other OS-Specific Notes

If you are using Windows and have Putty installed as your terminal program, it installs a text-based file transfer program as well - psftp - which you should be able to find in your list of programs.

If you are using MacOS or Linux, a text-based file transfer program - sftp - is normally installed by default.

In either case, new users often prefer to use graphical file transfer programs (those mentioned above).

For the text-based sftp programs, the basic commands you will need.

  • ls, cd, pwd - show you the files on the server and change directories on the server.
  • lls, lcd, lpwd - show you the files on your computer and change directories on your computer.
  • put - send a file from your computer to the server (from your current directory on your computer, to the current directory on the server).
  • get - download a file from the server to your computer
  • quit

Compilers/Interpreters

Python

C/C++

Backing up Files - Rsync

GUI Programs X-Windows

Sample HW

The following might be used by your instructor as part of a HW assignment to verify you have your computer setup properly.

  1. Follow the steps above to setup your computer with a file transfer program, text editor, and terminal program. Make sure you are able to use the file transfer program and terminal programs to connect to your CS class account on the CS server.
  2. Make sure you can open the text editor. Create a text file aboutMySystem.txt and put the following information.
    1. Your name:
    2. Your CS class account:
    3. Operating System:
    4. Text editor you are using:
    5. File transfer program:
    6. Did you have any difficulties in getting the programs setup? If yes, explain.
  3. Create the following screen shots demonstrating that you have the programs installed on your system properly. Note - you can ask the internet how to take a screenshot (e.g., type in - how to screenshot on chromebook). For each screenshot, make the screenshot of your whole screen (so I can see which OS you are running on and the program open and connected).
    1. textEditor.jpg - a screenshot that shows you editing the aboutMySystem.txt file with your text editor.
    2. fileTransfer.jpg - a screenshot that shows you using the file transfer program to connect to the CS server with your CS class account.
    3. terminal.jpg - a screenshot that shows you with the terminal program open and connected to the CS server with your CS class account.
  4. Use the file transfer program to connect to the CS server with your CS class account.
    1. While connected, create a new directory in your CS class account on the CS server. Name the new directory SystemSetup.
    2. Transfer the files you just created (aboutMySystem.txt, textEditor.jpg, fileTransfer.jpg, terminal.jpg) into the SystemSetup directory in your CS class account on the server.