Linux and CS Systems - Getting Started
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).
- 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.
- System Setup - Linux - System Setup - to get your computer setup (programs installed, etc.).
- Using the Terminal
- 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/classthen this changes the directory to the class directory that is inside of the u1 directory. If you instead typed
cd \u1\classyou 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/).
Read through another tutorial about Linux. Some options include the follow.
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.
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
If you use your account to login to the GUI on one of the CS lab computers then some directories will be created in your account (e.g., Downloads, Documents, etc.). You should create the following as well and use (a) your
bin directory to put programs or scripts that you have downloaded or created that you want to be able to use, (b) your
programs directory to put installation files for programs that you might need, (c) your
private directory to keep files you want to make sure to keep private from other users, and (d) your
public_html directory to store files that you want to be accessible on the web (at https://cs.indstate.edu/~YOUR_LOGIN).
mkdir ~/bin/ echo "export PATH=$PATH:~/bin/" >> .bashrc # add the ~/bin/ directory to where shell looks for programs mkdir ~/programs/ mkdir ~/private/ chmod go-rwx ~/private/ # makes that directory not accessible to other users mkdir ~/public_html/ chmod go+rx ~/public_html/ # so the web server can access this directory chmod go+x ~ # so the web server can access your public_html
Create a file in your
public_html directory, and practice copying a file from somewhere else on the system.
cd ~/public_html nano hello.txt # or use your preferred editor - vim, emacs, jove, ... # type something in your hello.txt file, save it, and # check that you can view it at https://cs.indstate.edu/~YOUR_LOGIN/hello.txt cp /usr/dict/words . # copies that file into current directory, which should still be your public_html # now check https://cs.indstate.edu/~YOUR_LOGIN/words
Create a sub-directory within your
public_html directory, put some file there, edit the Apache configuration file (
.htaccess) to allow directory listing of this directory (turned off by default for security reasons).
cd ~/public_html mkdir files_public cd files_public echo "Options +Indexes" >> .htaccess ls -a # verify that the .htaccess file exists now cat .htaccess # see what is in the file now cp /u1/junk/kinne/text-samples/shakespeare.txt . cp /u1/junk/kinne/text-samples/austen.txt . # Now browse to https://cs.indstate.edu/~YOUR_LOGIN/files_public