Tutorial_sn_logo


Linux and VI Editor Fundamentals

Jemmy Hu, HPC Analyst


Index


Objectives

This self-directed tutorial is mainly for people who have none or very little experience in Linux system, particularly for Windows users who want to migrate to SHARCNET Linux systems. Examples shown in the lightgrey areas were run on 'narwhal', a SHARCNET cluster. We hope that this tutorial would be a good starting point for newcomers to Linux.

Back to Index

What is Linux?

Linux is a free Unix-type operating system originally created by Linus Torvalds with the assistance of developers around the world in the 90's. Linux is becoming popular as a powerful, low-cost operating system for cluster servers.

Linux Features Back to Index

Directory Structure in Linux

This is not a complete list, but the most general directories on Linux system.
Directory Meaning
/bin Directory for system command
/dev Directory with special files which enable to work with pheripheral devices
/etc System programs and data
/lib Libraries that are needed to execute the binaries in /bin/ and /sbin/
/mnt Directory for temporarily mounted file systems
/tmp Directory for temporary data sets
/usr Other system programs
/var Files which are being updated during system running
/opt Directory for large, static application software packages
/home User's home directory. User has a common home directory on SHARCNET systems
/work work directory, with a quota of 200GB on some large SHARCNET systems
/scratch scratch directory on SHARCNET systems with an expiry time of 2 weeks

Back to Index

Getting Started

Let's try a few simple commands
Back to Index

Changing Password

To change your Linux account password, use the command passwd

[jemmyhu@nar316 ~]$ passwd
Changing password for user jemmyhu.
Changing password for jemmyhu
(current) UNIX password:
(You will write your actual password after colon.)
New password:
(You will write your new password after colon.)
Re-type new password:
(You will repeat your new password after colon.)
Password changed

If you type your old password and a new password correctly, the new one becomes valid.

NOTE: you can change your SHARCNET password on the SHARCNET webportal.

Back to Index

Basic Linux Commands

The basic format of a command is command [option] ...,
please check the command's manpage (man command) for other options. Back to Index

File Permissions

Back to Index

Other Important Linux Commands

For a list of Linux commands, please see Linux Bash Commands .

Back to Index

What is vi?

vi (visual editor) is the default editor that comes with the UNIX/Linux operating system. 
Alternate editors for UNIX environments include nano (formerly named pico) and emacs
(For basic emacs commands, see: http://www.cs.colostate.edu/helpdocs/emacs.html )

The vi editor is a full screen editor and has two modes of operation:
1. Command mode commands which cause action to be taken on the file, and
2. Insert mode in which entered text is inserted into the file.

In the command mode, every character typed is a command that does something to the text file
being edited; a character typed in the command mode may even cause the vi editor to enter the
insert mode. In the insert mode, every character typed is added to the text in the file; 
pressing the Esc key turns off the Insert mode.
While there are a number of vi commands, just a handful of these are usually sufficient for
beginning vi users.

Both UNIX/Linux and vi are case-sensitive. Be sure not to use a capital letter in place of a 
lowercase letter; the results will not be what you expect.
Back to Index

Basic vi Commands

Back to Index

Further Reading

SAMS Teach Yourself Unix in 24 Hours, third edition, Sams Publishing, 2001

http://www.fsid.cvut.cz/cz/U201/LINUX.HTML
Quick Linux Tutorial, by Jiri Vogel
http://faculty.plattsburgh.edu/jan.plaza/computing/help/commands.html
Basic Unix Commands
http://www.ss64.com/bashsyntax/vi.html
vi Editor Commands
http://www.cs.colostate.edu/helpdocs/vi.html
Basic vi Commands

Back to Index


© 2007, 2008, Jemmy Hu, SHARCNET