Basic Linux command-line and utilities for accessing it (ITI8510)

Allikas: Lambda
Real-Time Operating Systems and Systems Programming
[ @ ]

We use a separate server for our programming purposes, it's name is dijkstra.cs.ttu.ee and you can have its SSH login account by registering your user name with the lecturer. Since it's a Linux system and we use command-line you will need some experience with it.

SFTP access for dijkstra

Under some linuxes you can use the file explorer to navigate to location:

 sftp://dijkstra.cs.ttu.ee/

Logging in

Your user name for dijkstra is name.family .

Server: dijkstra.cs.ttu.ee

Use 'ssh', Putty, SSH Secure Shell, or 'ssh' under Cygwin to log in. Basic ssh command for logging:

ssh username@dijkstra.cs.ttu.ee

Once logged in

You can type in commands and their arguments (separate them with spaces). Some of the more useful commands.

  • mkdir dirname - make directory named 'dirname'
  • ls - list files in directory
  • cd dirname - change working directory to 'dirname'
  • ./progname - run your program from the same directory
  • mydir/progname - run your program from directory 'mydir'

Compiling

For compiling the program, you can use 'gcc' utility (-o hello sets the program output to be the file hello):

gcc hello.c -o hello

A shorter alternative would be to use 'make' utility;

make hello

For more difficult compilation (such as when joining different files) you might consider writing a 'makefile'

Editor

You can use editor on your own computer and upload the files with a program such as PSCP. That can get tedious and boring. It's more useful to learn a proper editor for command-line.

From the editors on dijkstra we strongly recommend 'vim', but 'nano' is also quite popular. For the reasons, consult the diagram below.

Common-editor-learning-curves.jpg


Hints for vim

Vi has modes: you start in command mode and insert text in insertion mode. That is due to the fact that you must be able to use an editor when you have only character keys available. This is confusing until you get used to it. It takes years to master, but once mastered it's effortles, fun and useful.

Remember: To get to the command mode from any other mode, press ESC

Some hints in commmand mode:

  • To quit without saving, press :q!
  • Save & quit, press ZZ (or :wq)
  • To write (enter insertion mode), press i, then type.

Advanced hint:

  • For syntax highlighting you can type
:syntax on

To save yourself from writing it every time, go to your home directory, create file '.vimrc' with the words 'syntax on' in it.

cd
cat >> .vimrc
syntax on

Then press CTRL+D (to send end-of-file)