This is an old revision of the document!


Useful Linux Commands

The following will help you get started with Linux on the SCS Network. It will only describe the very basics. For an in-depth look at Linux, the internal workings, and how the operating system works see the O'Reilly set of books in particular 'Essential System Administration' by Aeleen Frisch.

FIXME A lot of the content has not yet been moved to the new support site. For more information, please visit the old linux help page.

Opening a Terminal Window

Linux has a window manager, and windows that you can work with. (SCS uses Gnome as the default window manager). Although GUIs are useful, and many tasks can now be done using GUIs, much of the work in Linux is still done on the command line. Essentially all work can be done on the command line, without using the GUI at all. The terminal window is used to type command line arguments. For the Gnome window manager you have to access the menu (top left corner icon) and then select “Accessories → Terminal”.

Basic Linux Commands

When using a Linux command line, the following commands are essential to navigating around the system:

Linux Command DOS Command Description
ls dir List the files in a directory.
Usage: ‘ls’ or ‘ls directory
cd cd Change to a different directory.
Usage: ‘cd directory
Some special examples are ‘cd ..’ which moves up one directory, or ‘cd ~’ which switches to your user home directory.
rm del, deltree Delete files or directories.
Usage: ‘rm file’ or ‘rm -r directory
cat type Display the contents of a file.
Usage: ‘cat file
clear cls Clear the screen.
Usage: ‘clear
mkdir mkdir Create a new directory.
Usage: ‘mkdir directory
cp copy Copies files or directories.
Usage: ‘cp file destination’ or ‘cp -R directory destination
mv ren, move Move or rename files or directories.
Usage: ‘mv file destination
find Locate files within a directory.
Usage: ‘find directory -name file
Example: ‘find ~ -name '*.c'’ will find all of the C source code files in your home directory.
tail Display the last few lines of a file.
Usage: ‘tail -n lines file
Example: ‘tail -n 20 project.c’ will display the last 20 lines of the source code in project.c.

For more help with Linux commands, you can use the built-in help system. Type ‘man command’ to see the help page for a particular command. In addition, you can read the online unix help.

Linux Command-Line Examples

Here are some examples of more complicated commands which you may find useful.

Linux Command Description
less README.txt
Display the file README.txt on the screen, allowing you to scroll through it with arrow keys. Press ‘Q’ to exit.
date > date.txt
Get the current system date and time, and save the output to the text file date.txt
grep keyword README.txt
Search the file README.txt for keyword, and display any matching lines.
uname -a
Display the version of the operating system which you are using.
tar -acvf archive.tar.gz project/
Create a compressed archive of a directory, much like a zip file.
tar -xvf archive.tar.gz
Extract a compressed archive to the current directory.
whoami
Display the name of the user that you are currently logged in as.
ssh lambda02
Use a secure, encrypted protocol to log into a different computer. You will get a command prompt on the remote computer. You can use exit to return to your original computer.
Back to top
fyi/useful_linux_commands.1256047917.txt.gz · Last modified: 2009/10/20 10:11 by lass