acs logo www.gantep.edu.tr
pfs.gantep.edu.tr
Library - WebMail
Computer Center
INDEX - Services - Guides - Search - Links/Downloads - Local - HelpDesk
[back] /guides/linux/gu-linux-essentials.php
G. U. Linux Essentials
Türkçe
gu-linux-essentials-tr.php

Essential Linux knowledge for interactive users of central Linux accounts in the University of Gaziantep.

Index

Introduction

This guide is aimed at students and staff in the University of Gaziantep who wish to use a central Linux account for interactive work. Such work may include, for example:

  • Creating, editing, and and storing files.
  • Creating, compiling, running programs.
  • Composing a web site.
  • Reading and posting email.
  • Transferring files over the internet.
  • Running any of the many applications available on the central Linux server (including graphical applications via a VNC connection).

This guide provides only a basic introduction to Linux; more detailed guides can be found at ACS Linux Guides. Note that Desktop applications are not covered in this guide.

What is Linux?

Linux is a variant of the Unix operating system. Like the well known Microsoft Windows operating systems Linux can be used to create and store files and run a variety of applications and services.

Why Linux?

Linux is chosen for central university servers because it is reliable, it is not affected by computer viruses/worms/trojans that infect Microsoft Operating systems, and it is well suited to a multi-user environment. As well as interactive servers, all web, mail, and ftp servers in the university are hosted by Linux servers. An additional benefit of Linux is that it is free for download from various distributors; for example http://www.slackware.com and http://www.redhat.com. Linux is also the preferred operating system in many research institutions and in a growing number of companies, government departments, and desktops. For more general information about the Linux operating system see http://www.linuxhq.com and http://www.linux.org (there are many other linux related sites on the internet).

Obtaining a Linux account

Any staff or student in the University of Gaziantep may take an account on a central Linux server. There are two Linux servers for staff, and two Linux servers for students. You can obtain an account on a Linux server (i.e. a login-name and password) from the computer center. For this you will need to show your university ID card. The servers are:

  • For Staff
    • gul1 for mail/webmail/webdisk
    • gul3 for programming and web publishing
  • For Students
    • gul2 for mail/webmail/webdisk/web publishing
    • gul4 for programming and advanced web publishing
You can see more details about the services provided by these servers at http://wwwacs.gantep.edu.tr/services/

Connecting to a central Linux server

Login access to your Linux server is possible from any computer that has an internet connection. You can connect to your central Linux server using ssh; example for a student account:

  ssh login-name@gul4.bim.gantep.edu.tr
and enter your password. See http://wwwacs.gantep.edu.tr/services/ for more details.

You might want to download a nice ssh client for Microsoft Windows from: http://pfs.gantep.edu.tr/windows/ e.g. putty. You can also find an ssh file tansfer cilent there.

For mail servers (gul1, gul3) you may find webmail/webdisk useful.

About passwords

Your password protects your account from another person using it. An unauthorised person using your account could: read and delete your files, read and delete your email use your account for abusive or illegal activities.

You should keep your password secret and not share your account with others. You should not use the same password on different accounts. You should choose a good password that is not easy to guess by another person. You can use letters (upper- and lower-case), numbers, and symbols in your password. To change your password type the following command at the command prompt:

  $ passwd
You can change your mail password inside webmail.
Memorise your new password (its not safe to write it down). If you forget your password then you can get a new one from the computer center; you will need to show your university ID card.

The command prompt

After you have connected to your Linux server and typed your login-name and password correctly you should find that you have the command prompt

  $
you are now in a Linux environment, the command prompt is waiting for you to issue a command.

Case sensitivity

Linux is cASe-sEnSITive: normally commands are written in lower-case, the file names of any files you create are case-sensitive and so for example MyFile.txt is different to myfile.txt.

Command line completion

Use the [TAB] key to help you complete a long command. For example you wish to issue the command:

  $ edit my-diary-september-2003.txt
If the file my-diary-september-2003.txt already exists then you simple have to type
  $ edit my[TAB]
the rest of the file name will be found and the command completed for you.

Email

With a gul1 or gul2 interactive account you also have an email service; your email address is:

    staff                 login-name@gantep.edu.tr
    students         login-name@mail2.gantep.edu.tr

To read and send email you can use the email client pine. Type either pine or mail at the command prompt, for example:

  $ mail
pine is a powerful and easy to use email client, and as you are running it on a Linux system you dont have to worry about Microsoft Windows viruses/trojans/worms etc. A pine guide can be found at http://www.washington.edu/pine/tutorial/.

You can also use an email client on a remote computer (for example MS Outlook in your office) and download your emails from your central Linux server; in this case you should be careful not to allow your computer to be infected with a computer virus/worm. For more information about using a remote email client see: Email Client Settings.

Web

Your central Linux account provides you with a personal web site. In addition to HTML and JAVA, your web pages may include PHP script.

The address of your web site is:

    staff           http://www1.gantep.edu.tr/~login-name
    students   http://www2.gantep.edu.tr/~login-name

To create a personal web site you need at least an index.html or index.php file in the www/ directory under your top (home) directory. You can create these resources and a simple web site with the makeweb command:

  $ makeweb
To modify your web site you can issue the following commands:
  $ cd ~/www
  $ edit index.html
modify the html text, and and press [Ctrl]-[X] (to save and quit)

The cd and edit commands are explained later in this guide.

HTML and PHP guides can be found here .

Printing

Free printing of plain-text files from gul1 and gul2 to a printer in the computer center is available via the command print. Example,

  $ print myprogram.f90
Remember that only plain-text files can be printed with this command.

The computer center provides a laser printer service for the printing of other documents at a price.

Transferring files to and from your Linux account

You may wish to transfer files over the internet between your Linux account and another computer (for example your computer at home). This may be done using an sftp client on the remote computer.

Using sftp (example for a student account):

  sftp login-name@gul2.bim.gantep.edu.tr
and enter your password.

You might want to download a nice sftp client for Microsoft Windows from: http://pfs.gantep.edu.tr/windows/internet/.

Viewing web and ftp sites, and downloading files

From your Linux account you can browse web and ftp sites, and download files from these sites to your file space. Some of the commands available for this are links, wget, and lftp.

The links utility is a web and ftp client; for example you can view your own or another user's web site as follows:

  $ links http://www1.gantep.edu.tr/~login-name   (for staff)
  $ links http://www2.gantep.edu.tr/~login-name   (for students)

The lftp utility can be used to browse and download files from ftp and web sites, for example:

  $ lftp http://www.gantep.edu.tr/
  $ lftp http://pfs.gantep.edu.tr/
use the ls command to list directories, cd to navigate directories, and get download files.

Some useful web address:

  http://wwwacs.gantep.edu.tr/  - Academic Computing Services web site
  http://www.gantep.edu.tr/     - university web site
  http://www1.gantep.edu.tr/    - staff web sites
  http://www2.gantep.edu.tr/    - student web sites
  http://www.yahoo.com/         - a web search engine
  http://www.google.com.tr/     - another web search in Turkish.

Basic Linux commands

There are thousands of commands available under your Linux account. The following sections explain some of the basic and common commands you may find useful.

Quitting a login session

First you need to know how to quit your login session. The commands are logout or exit.

  $ exit
this quits your login session (and disconnects you from the Linux server).

Listing files

When navigating your file space you need to be able to list the files in your directories.

  $ ls
this gives a list of files in the present working directory.

The ls command has various options, try for example ls -asl.

  $ ll
this gives a long-list of files in the present working directory, it includes information about the file privileges, ownership, size and date.
  $ ll *.f90
this lists only files that have the extension .f90 (more about file extensions later).

Creating, viewing, and modifying files

The basic way to create a file is to use an editor (word processor). There are many editors available under Linux, the simplest to use (yet quite powerful) is the pico editor. This is the editor used in the pine email client to view and compose emails, you can also use it to read and create other files. You can invoke the pico editor with the command pico or the command edit, the later is recommended. For example:

  $ edit diary.txt

Inside the pico editor you can write your text and then save it with [Ctrl]-[O], or save and quit with [Ctrl]-[X]. Use the arrows keys to move around and [Back Space] to delete characters. [Ctrl]-[K] cuts a line and [Ctrl]-[U] pastes. Press [Ctrl]-[G] displays help information.

You can also use edit to simply view a file. Other commands are available for viewing the contents of a files, some of them are:

  $ cat diary.txt
this dumps the contents of the file to the terminal.
  $ more diary.txt
like the cat command but pauses on each page.
  $ less diary.txt
like more, but allows you to scroll up and down the file and search for expressions in the file.

File extensions

To make it easier for you to identify and organise files some standard file extensions can be used. Standard file extensions are also used by programs to determine what to do with a file when it is loaded. Some of the more common file extensions are listed below:

 .txt   - plain text
 .tex   - Latex source
 .html  - HTML(web)
 .php   - HTML with PHP script
 .gif   - graphics file
 .png   - graphics file
 .jpg   - graphics file
 .f     - Fortran 77 source
 .f90   - Fortran 90/95 source
 .c     - C/C++ source
 .doc   - MS Word document
 .xls   - MS Excel document
 .pdf   - PDF document
 .ps    - Postscript document
 .mp3   - Sound
 .mpg   - Video
 .zip   - Compressed (zipped) file
 .gz    - Compressed (gzipped) file
 .tar   - Archive tarfile
 .tgz   - gzipped tarfile
 and many more ....
Binary executable files usually have no file extension (unlike the .exe extension for Microsoft Windows executables).

The file command reads a file and attempts to determine its type; for example:

  $ file go.gif
  go.gif: GIF image data, version 87a, 100 x 80

  $ file courses.html
  courses.html: HTML document text

File manipulation

Renaming, copying and deleting files

The mv command is used to move or rename files:

  $ mv myprog.f90 myprog2.f90
the file myprog.f90 is renamed to myprog2.f90
  $ mv myprog2.f90 programs/
the file myprog2.f90 is moved into the directory called programs/. You need to create the directory first (see mkdir below).

The cp command is used to make a copy of a file:

  $ cp myprog.f90 myprog2.f90
a copy of the file myprog.f90 is created and named myprog2.f90.

The rm command is used to delete files:

  $ rm myprog.f90
the file myprog.f90 is removed (deleted).

Creating and removing directories

You can organise your files into different directories (folders). To create a new directory, for example called documents/, the mkdir (make directory) command is used:

  $ mkdir documents
To remove the directory the rmdir (remove directory) command is used:
  $ rmdir documents
Note that the directory musty be empty before it can be deleted.

Moving between directories

The cd (change directory) command is used to move between directories:

  $ cd documents
this takes you down to the documents/ directory.
  $ cd ..
this takes you up one directory level.
  $ cd
this takes you to your top directory from anywhere is your directory tree.
  $ pwd
this displays your present working directory.

Referencing your top directory with ~/:

To help you reference easily the position of a file in your directory tree the symbols ~/ represent your top (home) directory. Examples of usage:

  $ ls ~/
lists the files in your top (home) directory
  $ cp ~/myprog2.f90 ~/programs/
this copies the file myprog2.f90 in the top directory to the directory programs/ situated under your top directory; you can issue this command in any directory as it specifies the full path.

File compression

File compression utilities are used to reduce the size of a file; this is done for various reasons including:

  • to reduce file space usage
  • to make file transfer of large files over a network easier
  • to reduce the size of large email attachments
If you download a file from the internet, for example from an ftp site, you may find that it is compressed and has one of the following file extensions:
  .zip  the zip utility
  .gz   the gzip utility
  .bz2  the bzip2 utility
  .tgz  a gzipped tarfile.
We will look briefly at the zip and gzip utilities next.

Consider that we have a file called myfile.doc.

  $ ll myfile.doc
  -rw-r--r--    1 ab123456   users  204800 Sep  5 11:15 myfile.doc
the file has a size of 204800 bytes.

To compress the file with the zip utility the command is

  $ zip myfile.zip myfile.doc
  adding: myfile.doc (deflated 71%)
The message indicates that myfile.doc has been added to the zip file myfile.zip and is compressed by 71%.
  $ ll myfile.*
  -rw-r--r--    1 ab123456   users  204800 Sep  5 11:15 myfile.doc
  -rw-r--r--    1 ab123456   users   60543 Sep  5 11:27 myfile.zip
The file listing indicates that the size of the zipped version of the file is only 60543 bytes. You can remove the original file if you wish to save file space.

Additional files can be added to the zip file; for example:

  $ zip myfile.zip anotherfile.doc
  adding: anotherfile.doc (deflated 88%)
You can view the contents of an zip archive with the zipinfo command:
  $ zipinfo myfile.zip
  Archive:  myfile.zip   66927 bytes   2 files
  -rw-r--r--  2.3 unx   204800 tx defN  5-Sep-03 11:15 myfile.doc
  -rw-r--r--  2.3 unx    53248 bx defN  5-Sep-03 11:32 anotherfile.doc
  2 files, 258048 bytes uncompressed, 66635 bytes compressed:  74.2%  
To uncompress and extract the original files from a zip archive you can use the unzip command:
  $ unzip myfile.zip
  Archive:  myfile.zip
  inflating: myfile.doc
  inflating: anotherfile.doc
The zip utility can also be used to create compressed archives of directories. For more information about zip and unzip type: zip -h, man zip, unzip -h, man unzip.

To compress a file with the gzip utility the command is:

  $ gzip myfile.doc

  $ ll myfile.*
  -rw-r--r--    1 ab123456   users   60420 Sep  5 11:15 myfile.doc.gz
In this case the file is compressed and given an additional .gz extension; the original file is not present.

To uncompress the file the gunzip command is used:

  $ gunzip myfile.doc.gz

  $ ll myfile.*
  -rw-r--r--    1 ab123456   users  204800 Sep  5 11:15 myfile.doc
The file is returned to its original state.

For more information about the gzip and gunzip utility type: gzip --help and man gzip, gunzip -help and man gunzip.

To create archives of directories you can use the tar utility and then use gzip to compress the tarfile. Alternatively you can use the -z (zip) option of tar. See man tar and tar --help.

Example:

  $ tar -czf myprograms.tgz myprograms/

Here, the directory myprograms/ is a directory containing files that I wish to archive.
tar -czf myprograms.tgz means "create a tar archive file that is gzip'ed and called myprograms.tgz"; All the files contained in the directory myprograms/ (and below it) will be collected into a single archive file. This is ideal for making backups or copying a directory to another directory or another computer or sending to someone by email. Note that the popular Windows program winzip recognises the tar and gzip'ed tar format.

Programming

Many programming environments are available on your Linux account, including, for example, Fortran 77/90/95, C/C++, perl, php, and java. The following are examples of creating, compiling, and running a Fortran program.

Creating/editing a Fortran 90 source file:

  $ edit myprog.f90
  PRINT *, "Hello world"
  END
  [Ctrl]-[X]
Compiling the Fortran 90 source to an executable:
  $ fortran myprog.f90
Running the executable:
  $ run myprog
If you need to stop an running program press [Ctrl]-[C]

You can also run programs in background, this means that the program may continue running even after you have disconnected from the server.

You may wish to kill (terminate) a program that you are running; the program may be running in foreground or in background.

  [Ctrl]-[C]             - to kill a foreground program.

  $ jobs                 - to get the job number of a background
  $ kill %job-number       program and then kill it.

  $ ps                   - to get the pid of a background process
  $ kill -9 pid            and then kill it.
You can use the top utility to view the resources taken by a running program:
  $ top

Information about other users

If you are interested in finding out which others users are logged onto the server and who they are you can use the following commands.

  $ users

  $ finger

  $ finger login-name

  $ w

Communicating with other users

You can communicate with other users in various ways. Here are some utilities you can use for this:

Send an email to another user:

  $ mail login-name
Write a message to the terminal of another user:
  $ write login-name
Interactively 'talk' with another user:
  $ talk login-name

Finding out more about a command

Commands usually have a manual page and/or help information:

  $ man commandcommand --help

  $ command -h
Also:
  $ whereis command

  $ whatis command

File-space

There is a limit to how much file space you can use. At the time of writing this document the limit (quota) is 90 Megabytes for your email inbox, and 1024 Megabytes (a Megabyte is about 1,000,000 bytes). for your home directory.

Related commands are:

  $ showquota

  $ quota

Information about the system

You can get information about the server with the following commands:

    sysinfo - general system information
  linuxinfo - general system information
       free - display system memory usage.
         df - display system disk usage
        top - detailed interactive list of system processes and resources
     ps aux - detailed list of system processes
     uptime - system uptime and load
       date - system time and date

Other selected commands

        cal - print this month's calendar
   cal 2003 - print calendar for the year 2000
    fortune - print out a random fortune cookie
       chfn - change your personal information displayed by finger.

Dot (.) Files

You will usually find some files in your top directory that begin with the dot (.) character. Such files are hidden from simple file listings. Some of the common files are:

   .plan        - the contents of these two files (if they exist)
   .project       is displayed when someone 'finger's you.

   .login       - login script for customising your login.

   .forward     - include a forward mail address to forward
                  your email to another account or host.

   .signature   - the text in this file is appended to your email.

Data processing with Linux commands

The following utilities can be powerful tools for performing some basic processing of data stored in files.

   cat  - concatenate files.
  sort  - sort lines of text files.
  uniq  - remove duplicate lines from a sorted file.
  diff  - find differences between two files.
  echo  - display a line of text.
   sed  - a Stream EDitor.
    tr  - translate or delete characters.
  grep  - search for lines in a file matching a pattern.
  head  - output the first part of files.
  tail  - output the last part of files.
 split  - split a file into pieces.
    wc  - print the number of bytes, words, and lines in files.
   cut  - remove sections from each line of files.
See the manual pages and help option for more details.

These utilities are made more powerful when used together with piping and output redirection:

The expression

  command1 | command2
means pipe the output of command1 to the input of command2.

The expression

  command3 > file
means redirect the output of command3 to the file file.

Example

  $ cat mydata.txt | sort > mydata.out
Here the output of the command cat mydata.txt is piped into the input of the sort program, the output of this program is redirected (from the screen) to the file mydata.out. The file mydata.out therefore contains the same lines contained in mydata.out but sorted into alphabetical order.

Getting help from the system manager

The university system manager and the computer center are happy to receive questions and comments from you; send email to system@gantep.edu.tr - you can expect a reply the same day.

Other related contact information can be found at ACS helpdesk.

More information about Linux

This guide provides only a basic introduction to Linux; more detailed guides can be found at ACS Linux Guides

8th September 2003

[back] /guides/linux/gu-linux-essentials.php
system manager, University of Gaziantep. system@gantep.edu.tr.