Linux and CS Systems - Getting Started

From Computer Science
Revision as of 02:16, 19 January 2022 by Jkinne (talk | contribs) (Assignment 0)
Jump to: navigation, search

This page is part of Programming and CS - Getting Started

This page is meant to help a new student in a CS course at ISU to get familiar with using Linux (in particular using the text-based terminal to interact with the system).

Getting Started

  1. Read - Ubuntu Linux Command Line Tutorial or Linux Tutorial - this gives you some background and introduces you to some of the terms that we use. After reading through the tutorial you have a better chance of being able to follow along the rest of the steps in this Getting Started.
  2. System Setup - Linux - System Setup - to get your computer setup (programs installed, etc.).
  3. Using the Terminal
    1. Linux Terminal - Files and Directories and Getting Around
    2. Linux Terminal - System Information
    3. Linux Terminal - Text Editors
    4. Using Linux - Large Text Files
    5. Linux Terminal - More Commands to Know

Common Mistakes

  • When logging in remotely to the CS server, when you are typing your password you might not see anything printed on your screen while you type. That is a security feature so that someone watching your screen would not know how many characters are in your password. Just finish typing your password and type enter when finished.
  • Note that all commands and file names in Linux are case sensitive. hello.txt is different than Hello.txt. The copy command is cp, Cp would not work, and neither would cP or CP.
  • The characters _ and - are different, and having a space in a file name is different than not having one ("hello world.txt" is different than "helloworld.txt").
  • For Linux directories and filenames, the "/" character is used to separate directories. On Windows, the "\" character is used instead. If you typed
    cd /u1/class
    then this changes the directory to the class directory that is inside of the u1 directory. If you instead typed
    cd \u1\class
    you would get an error.
  • The "top" or "highest level" of the Linux file system is the directory / and this is comparable to the "C:\" that was traditionally the top of the file system in Windows. In Windows there can be multiple drives (so D:\, E:\, etc.), but in Linux everything is underneath / (including additional drives, they will show up at a certain location under /).
  • On Linux, ~ is a shortcut for your home directory. User cs15100's home directory is in /u1/class/cs15100/, so if cs15100 is logged in and types
    cd ~
    then this means to change directories to /u1/class/cs15100/. If user jkinne types
    cd ~
    then this means to change directories to jkinne's home directory (which happens to be /u1/h0/jkinne/).

More Reading

Read through another tutorial about Linux. Some options include the follow.

Self Test

Here we give small tasks for you to complete. These are numbered so that we can refer to them. For each you would need to be logged into one of the CS systems (remotely logged into the CS server or using one of the CS lab computers).

Linux.0 Log in to the CS server, and run the chfn command to put your name into the system. You can leave all the other fields blank (just type enter). Also, use the chsh command to change your default shell from /bin/tcsh (or whatever it is) to /bin/bash

Linux.1 Log in to the CS server, create a directory named aboutMe in your home directory, and create a text file name.txt. In the name.txt file, give your full name.

Linux.2 In your aboutMe directory, create a file courses.txt and list which CS courses you are currently taking or plan to take in the upcoming term.

Linux.3 Log in to the CS server, create a directory named notes in your home directory, and create a text file named linux.txt and put in some links to linux tutorials or information that you have found helpful.

Linux.4 Log in to the CS server, create a directory named linux-bootcamp in your home directory.

Linux.5 In your linux-bootcamp directory, create a text file shake.txt. In shake.txt, put how many lines are in the shakespeare.txt file mentioned in the information above.

Linux.6 In your shake.txt file, add information about how many times "the" appears in shakespeare.txt. Use the command grep, add to what you had how many lines "the" appears in shakespeare.txt. Hint - use the -c option for grep, also use the -i option so your count will also include "The", "THE", etc. In your shake.txt, you should have the number of lines that contain "the" (including "The", etc.), and also the percentage of the lines that contain the.

Linux.7 In your linux-bootcamp directory, create a text file weather.txt. Copy the Indianapolis weather csv file from /u1/junk/weather/ into your linux-bootcamp directory. In your weather.txt file, put how many rows of data are in the csv file (use wc, head, and tail). Assuming 365 days per year, put in your weather.txt file how many years of data are in the csv file.

Linux.8 In your weather.txt file, put the maximum PRCP, SNOW, SNWD, TMAX, TMIN, MEAN from the csv file. Hint - use the sort command, and use the options -t, -k, -n, -o.

Assignment 0

The following is a typical first assignment to get started in Linux on the CS server. Here we assume your login on the server is cs00100.

Update your password, change your "finger" information (put your true name and can leave the rest blank), and set your normal shell. You execute each of these commands, one after another.

passwd
chfn
chsh -s /bin/bash cs00100

You can see which other shells you can choose from (other than bash) with cat /etc/shells. Bash reads configuration information from a file ~/.bashrc. A file with good defaults for the CS server are at .bashrc. More help on bash - bash manual.

If you want to see what commands you have run in the current login session you can run the command history. Bash also keeps history from previous sessions in the file ~/.bash_history.

The first time You should create directories to store programs (~/bin), ...