The Linux operating system is now commonly used as an alternative to
Windows in software development companies and many other organizations
as well. For instance, many Latin American government agencies use it
extensively because of its open source nature.
This tutorial goes over the basics of Linux. The tutorial is geared for computer science students at USF and
for helping new students setup their system for the semester.
Running Programs
With
Linux, you can use either a graphical user interface or a command-line
computing. When you login to a USF computer science account, you'll
see the Linux GUI. You can run applications by choosing
Applications
in the top-left corner.
File Manager
Unlike
a home PC or laptop, the lab computers are multi-user. So there may be
others who have logged in remotely and are using the same computer you
are using. In general, every user's workspace is separate and you don't
have access to other user's files. But realize that they are there.
Your
home directory will have your user name as part of its name and it
should be represented with an icon on the Desktop. If you click on that
icon, you'll see the subdirectories and files you have in a File
Manager window. Some have been setup for you. You'll also want to
create some subfolders yourself-- you can do this by selecting File |
Create Folder.
Text Editors
Under
Applications | Accessories, there are some file editing programs,
KWrite and Text Editor. You can use these to write programs or anything
else. You'll also learn more sophisticated software development
environments later.
When you create a file, you'll save it somewhere within the file hierarchy rooted at your home directory.
Command-Line Terminal
You
can get to the command-line by choosing Applications | System |
Terminal Program. The terminal window that appears will allow you to
enter Linux commands.
File System
Where as Windows File Manager has a root named
C:
, Linux has a root directory named '
/
'.
This is the root directory for all users on the shared file system. All
other directories, including your home directory, are in a hierarchy
below that.
When you login to your CS account, your home directory is
/home/yourUserName
For instance, Professor Wolber's is
/home/wolber
You also have a web directory:
/home/web/yourUserName
Files put into this directory are accessible to the public from any browser. You could put your homepage here.
Linux Commands
Linux
has hundreds of commands, but there is a smaller set that are
essential. Login to Linux, open a terminal window, and try the
following commands.
ls
lists the files in your current directory.
pwd
tells you where you currently are in the file system.
mkdir programs
creates a new subdirectory called 'programs'
cd programs
changes
you from the current directory to the subdirectory 'programs' (if it
exists). After running this command, try pwd again.
cd
changes you from wherever you are to your home directory. Try pwd again to verify you are back in your home directory.
cd ..
takes you up in the directory hierarchy, e.g., if you're in /home/wolber/programs, it will take you to /home/wolber.
passwd
changes your password. Do this.
Here's
some more commands. You'll need them for the tasks set out below, but
you don't need to try them right now. 'src' refers to the source of an
operation, 'dest' to the destination of an operation.
cp src dest
copies a file named src to a file name dest.
mv src dest
moves a file from src to dest
rm file
removes a file (be careful)
rmdir directory
removes a directory (be even more careful)
Task: Organize your file system for the semester.
1. Create the sub-directory 'programs' from your home directory. Make sure you are in your home directory, then type:
mkdir programs
2. Create sub-directories within 'programs' to 'samples' and 'projects'. If you are still in your home directory, type:
cd programs
pwd
mkdir samples
mkdir projects
‘samples’
is where you'll put program snippets you do in class that perform
specific operations. ‘projects’ is where you'll put course projects you
complete.
3. View your system setup.
cd
this take you to your home directory
ls
should list 'programs'
You can also view your directory hierarchy using the Linux graphical user interface.
Before
proceeding, show your professor or TA that you have created the
directories and can view them with the command-line and GUI.
4. Create a file with a text editor.
Select
Applications in the upper left corner and choose Accessories | Text
Editor. This is a simple wysiwyg text editor. Create a file
named me.txt. Put your name as the only line in it and save it in your home directory.
5.Copy a file
Open a terminal window and perform an ‘ls’. It should show "me.txt"
Copy the file into the programs subdirectory. From your home directory, enter:
cp me.txt programs/.
This means to copy me.txt (the source) into the subdirectory programs and keep the same file name ('.' means same name).
Navigate to the programs directory and make sure the file was copied.
cd progams
ls
6. Move a file.
Move the file to the samples directory using the mv command.
mv me.txt samples/.
ls
me.txt should be gone
cd samples
ls
me.txt should be here
7. Delete the file
rm me.txt