• 2. A session in the shell

    In this unit we will go through a longer terminal session to understand the logic of the language. We start by exploring the system environment and then move on to screen handling. The commands we issue in this unit are very simple and limited to getting information from the system - all "read-only". You also learn to how to record a terminal session. See the script 2.1 Handout: A shell session for details. Then you have to upload the results on to 2.3 Assignment: A shell session.

    Commands you will learn: cal ; clear ; date ; echo ; exit ; hostname ; ncal ; reset ; stty size ; top ; uname ; uptime

    • 2.1 Handout: A shell session Page

      We interact with a Unix machine by issuing commands to its shell. Learn the basic structure of those commands by practicing, date, cal, ncal, uptime, top, hostname, uname, echo, echo $SHELL and echo $USER. And also get used to how the shell behaves with type-ahead and get to know some control commands (Ctrl+C, Ctrl+D,..).

      Not available unless: The activity 1.5 Test: Intro, Log in is marked complete
    • 2.2 Recording: A shell session URL
      Not available unless: The activity 2.1 Handout: A shell session is marked complete
    • 2.3 Assignment: A shell session

      When capturing a screen-cast the typical GUI user makes films, generating big video files which are sometimes not even sharp. The shell user captures his terminal in the terminal itself, for example in ttyrec. The resulting files are thousand times smaller and always sharp!

      Preparation

      When capturing a screen-cast the typical GUI user makes films, generating big video files which are sometimes not even sharp. The shell user captures his terminal in the terminal itself. The resulting files are thousand times smaller and always sharp!

      There are many terminal recording tools available. We will use ttyrec. Just by issuing the command ttyrec it will begin capturing everything that happens in the terminal to a file. To end the capture, type exit. You will find the recording in a file called ttyrecord. To give it a different name, simply provide the name as a parameter. For example:

      $ ttyrec  mywork.ttyrec
      [work in the terminal]
      $ exit
      exit
      

      Please be careful not to press non-printable characters like arrow keys, page up/down during the recording. They tend to upset ttyrec!

      To play back, run:

      $ ttyplay mywork.ttyrec
      

      Assignment

      Login to your shell account and practice the steps given below. Once you are confident capture your work to a file named assign2b-USERNAME.ttyrec. Replace USERNAME with the username assigned to you. Don't use the space character, capital letters or any other characters in the file name.

      If you make a mistake, just exit and start again!

      Step 1. Display the system clock time.

      Step 2. How many seconds have passed from 00:00:00 UTC of 1 January 1970 to the time you are doing the assignment?

      Step 3. Find out how long the computer was running since the last reboot.

      Step 4. Print the values of the environment variables HOSTNAME, HOSTTYPE, USER and HOME.

      Then exit the ttyrec. Check the recording by running it on ttyplay. If everything is OK, then write a note in this assignment giving us your shell username and saying that you have finished the assignment 2B. You don’t have to upload anything, the supervisor will visit your home directory to check.

      Don't forget to mention your shell username in your reply! That is how we'll find your recording.

      Not available unless: The activity 2.1 Handout: A shell session is marked complete
    • 2.4 Test: A shell session Quiz

      Check what you've learned above by taking this MC test.

      Not available unless: The activity 2.3 Assignment: A shell session is marked complete
    • 2.5 Assignment (optional). Some fun commands Forum

      In the course we learn only the essential shell commands. But Unix is built in such a way that others can add commands on their own. The mainstream Linux distributors collect such additional tools on their merit, package them and add in to their repositories. So, in the case of Debian/Ubuntu it is a matter of # apt install PACKAGE to install such a package.

      We have installed the collection below in the lab machine - some serious and other less serious. Read about them,, test them and post your findings in this forum. Note that you can start only one discussion. Chose a tool nobody has taken. If you like to add something about a tool somebody else has taken, then reply in the other thread.

      atop | axel | btop | cmatrix | csysdig | curl | ffmpeg | figlet | htop | iftop | iotop | jp2a | lynx | fastfetch | linuxlogo | nmap | ntop | perf | powertop | ranger | sensors | speedtest-cli | s-tui | stress | tcpdump | tcptraceroute | tldr | traceroute | w3m | wget

      Not available unless: The activity 2.4 Test: A shell session is marked complete