This document is a general Linux introduction, with a short introduction to shell scripting as well. It covers basic Linux usage, with a focus on the command-line, and gives links to more advanced material. Exercises throughout this introduction guide the learning process. The top-level URL for this Linux Introduction is: http://www.macs.hw.ac.uk/~hwloidl/Courses/LinuxIntro/.
For information on how to access machines remotely see this Section of the Linux Intro.
The main goal of this document is to provide sufficient information on basic Linux and shell scripting usage to get started on introductory exercises. By the end of the Section called Basic Linux Usage you should be able to launch commands from the command-line, compose commands using pipes, and navigate in the filesystem. By the end of the Section called Basic Shell Scripting Using bash you should be able to write basic shell scripts to perform repetitive operations.
The context of this guide are under-graduate and post-graduate courses at Heriot-Watt University, Edinburgh, that rely on basic knowledge of Linux usage. In particular, this guide should provide sufficient context for assignments in the courses F21CN Computer Network Security and F21SC Industrial Programming. However, it should be of broader use, and it is designed for such.
Depending on your experience with Linux-like operating systems, follow one path (column) in the table below.
Table 1. Roadmap through the document based on your experience with Linux
|No Experience||Little Experience||Some Experience|
|Get Started:||the Section called Step-by-step Login Information||the Section called Basic Linux Usage||the Section called Basic Shell Scripting Using bash|
|Focus on:||the Section called Basic Linux Usage||the Section called Basic Linux Usage||the Section called Basic Shell Scripting Using bash|
|Also cover:||the Section called Basic Shell Scripting Using bash||the Section called Basic Shell Scripting Using bash||the Section called Shell Script Examples|
|Further reading:||Sobell's Linux Guide (detailed textbook on Linux, shell and much more)|
|Short info:||Linux Quick Reference Sheet (O'Reilly)||Linux Practical||Linux Command-line reference|
|More detail:||Linux Tutorial (guru99)||Unix Shell (software carpentry)||Linux Shell Scripting Tutorial (Vivek G. Gite)|
|Screencasts:||First Steps||Basic Linux Usage||Shell Scripting|
|For C Programmers:||the Section called Practical: Edit-Compile-Run Cycle for C Programs|
Experienced users may want to jump straight to the the Section called Quick Start and follow the links given there. The material in this introduction is mainly for users with little or no experience with Linux.
|Linux Quick Reference|
Before you start the tutorial, proper, it is strongly recommended that you get this this Linux quick-reference (O'Reilly).
First of all, make sure that you have your username and password ready. You will get these at induction day. If you missed that opportunity, contact the help desk (room EMB 1.33).
Now, work through the Section called Basic Linux Usage, which takes you through the first steps of logging in and basic Linux command-line usage. By the end of this section, you should be able to launch commands from the command-line and get help on the most common activities.
Then, work through the Section called Basic Shell Scripting Using bash, which teaches you basic shell usage in bash and takes you through a couple of exercises. It starts with simple straight-line scripts, i.e. sequences of commands that are executed as if typed on the command line, and moves on to repetitive scripts, e.g. using loops and function calls.
Finally, to deepen your understanding, look at the examples in the Section called Shell Script Examples, save the examples in separate files, and execute the files as discussed. Make small changes to the scripts to modify behaviour. By the the end of this section, you should be able to write basic shell scripts, to automate repetitive processes.
For further practicals beyond the scope of this tutorial, check the section below, in particular look-up the detailed 3-part online Unix Tutorial by Information Services at Edinburgh University.
If you prefer a comprehensive textbook, covering the range of basic to advanced Linux usage, with many examples and a fairly complete command reference, check out Sobell's Linux Guide.
All exercises in this tutorial are shown in a format like this:
$ pwd /home/hwloidl
If in the above example you got an error like
There is a lot of good introductory material on Linux around.
These are guides tailored to the Linux setup at MACS:
Short Linux Tutorial for MACS by Rob Stewart (a Linux practical for those completely new to Linux)
These are general Linux tutorials or cheat sheets (a concise collection of the most important commands):
Reference Cards of the Advanced Bash Scripting Guide.
The following resources are more detailed Linux introductions and tutorials:
The Unix Shell (a software carpentry course)
Advanced Bash-Scripting Guide by Mendel Cooper (the best source of information for bash scripting; example driven)
Bash Reference Manual (for looking up details of bash commands etc)
Unix Toolbox (especially useful for sysadmin tasks)
Books about Linux and UNIX in general:
A Practical Guide to Linux Commands, Editors and Shell Programming, by Mark G. Sobell, Prentice Hall, 2012. ISBN 978-0133085044. (an excellent, comprehensive guide to Linux usage, starting from scratch and reaching advanced usage)
Learning the UNIX Operating System: A Concise Guide for the New User, By Grace Todino-Gonguet, John Strang, Jerry Peek. 5th Edition October 2001 ISBN 0-596-00261-0. (an introduction to UNIX for newbies)
UNIX in a Nutshell: System V Edition, By Arnold Robbin (standard reference book)
Linux Cookbook, learning UNIX by examples (for Beginners)
UNIX Power Tools (the ultimate guide for efficient usage of UNIX tools)
The first section covers basic Linux usage (the Section called Basic Linux Usage). The second section is a basic introduction to shell scripting (the Section called Basic Shell Scripting Using bash). Some worked examples of more complex shell scripts are given in the Section called Shell Script Examples. For more advanced topics see the Advanced Bash-Scripting Guide by Mendel Cooper. The final section (the Section called Local Setup) contains information specific to our local setup. As an appendix, the Section called Step-by-step Login Information provides step-by-step guidance on how to login and get started with this Linux Introduction.
|Basic Linux Usage|