XEmacs Java KDE DOS Disk Commands Email man Pages Printing Home



CS1 Environment: Linux



This is a brief introduction to Linux commands. For more information on Linux try the "Little Igloo Site" at http://www.littleigloo.org.

Logging In
Getting Started
Changing Your Password
Displaying Files and Directories
Manipulating Files and Directories
Viewing the Contents of Files
File Permissions and Protections
Printing

Logging In

The operating system you will be using is Linux.

At login time, you'll see a prompt that will look something like this:

Red Hat Linux release 5.2 (Apollo)

Kernel 2.0.35

dougal login:

Enter your user name and press the Enter key.

Next you will be prompted for your password:

password:

Enter your password. The characters you enter won't be echoed to the screen, so type carefully. If you mistype your password, you'll see the message

Login incorrect

Type your password again. Once you have correctly entered your user name and password, you will be logged in to the system.

The environment you will be using is KDE (K Desktop Environment). For further information on KDE check the KDE web site or our introduction to the KDE environment.


Getting Started

To start using Linux you will first have to open a terminal window. To do this in KDE:

Choose application starter (this will be a white letter K on your toolbar) followed by Utilities then Terminal

This will open kvt which is a command line window. You will be presented with the command prompt which will look something like:

[machine_name]user:

where machine_name is the name of the machine you are on and user is your user name.

To start you off here's some basic Linux information and commands that you'll probably find quite useful, if you want to know more about any of the Linux commands you can access the online Unix manual by typing man followed by the command you'd like more information on. For example, if you required more information about the ls command you would type man ls

N.B.Linux filenames and commands are case sensitive


Changing Your Password

You can change your password at any time, all you have to do is type passwd. You will be asked to enter your old password and then prompted to enter a new one. Finally, you will be prompted to re-type your new password. If this does not match the first password you typed in you will be asked to repeat the process.


Displaying Files and Directories

Displaying files and Directories

To view a list of your files and directories use the ls command. Variations on this command are ls -a which will list directories and files with '.' at the beginning of their name ("dot files") which are hidden unless the -a extension is used. ls -l will give a list of each file and also show the file type, permissions, number of hard links, the owner of the file, the group name, size in bytes and timestamp. Using ls -F will list all files and directories and also place a '/' after a directory name.

Manipulating Files and Directories

To establish what working directory you are in type pwd this will display your working directory.

To change into another directory you use the cd command. i.e. cd directory_name. To move back up to the parent directory type cd ... No matter where you are in the directory structure, if you type cd just on its own you will be returned to your home directory.

To copy a file to another directory the cp command is used. i.e. cp filename directory_name. This will keep your old file intact and put a copy of it in your chosen directory. Alternatively, to move the file to another directory rather than copying it, use the mv command i.e. mv filename directory_name. Using this command will not leave the original file intact but will instead move it to your chosen directory. The mv command can be used to rename a file i.e. to rename the file old_file to new_file type mv old_file new_file.

Note: cp and mv will overwrite the destination file (if it already exists) without asking you.

To create a directory the mkdir command is used. For instance, to create a directory called MyDir you would type mkdir MyDir. Type ls and you will see the directory you have just created, then use cd MyDir to move into your new directory.

To remove a file use the rm command i.e. rm filename and to remove a directory use rmdir directory_name. This command will delete the directory only if the directory is empty.

Viewing the Contents of Files

To view the contents of your files use the more or cat commands. Using more will display your file one screenful at a time while cat will display the whole file at once.

To move about a file while using more, use the space bar to move forward a page, type 'b' to display the previous page and type 'q' to exit more.

To find an occurence(s) of a particular string in a file use the grep command. For instance if you wished to display all the lines in a file that contain the string my_string type grep my_string filename.

File Permissions and Protection

To change a file's permission use chmod. This command will change the settings to only allow people you want to read, execute or change the file. There are three levels of users of a file: the owner, the group the owner belongs to and everyone else. These users are abbreviated to u for the user, g for the owner's group, a for everyone and ofor others. The three permissions are abbreviated to r for read, w for write and x for execute. So for example if you wished to allow users in your group to be able to read the file, you would use:

chmod g+r filename

or to remove write permission from everyone:

chmod a-w filename

where the minus sign removes a permission from a set of users and the plus sign adds a permission.

Printing

To print a file use the lpr command, i.e:

lpr myfile

or the a2ps command, i.e:

a2ps myfile






Kathleen McLean
Last modified: Mon Sep 27 11:34:44 BST 1999