Lab MAnual 2
Lab MAnual 2
Lab MAnual 2
Lab Manual 2
About Ubuntu
For our lab sessions we are going to use the operating system Ubuntu. Ubuntu is an
operating system, just like Windows XP, Windows Vista, Windows 7, and Mac OS X
are operating systems. The main difference between Ubuntu and these other operating
systems is that it is free and open-‐source. Open-‐source means that is has been created by
a collective of thousands of volunteers and that the source code is freely available and
constantly being improved upon and examined for bugs.
The reason we will use Ubuntu instead of Windows is that much of the scientific
software used for the applications described in our course, has been developed on Linux-
‐based operating systems such as Ubuntu. In addition, Ubuntu is one of the most user-
‐friendly Linux-‐based operating systems around, making it the optimal choice for
our lab sessions.
Exploring Ubuntu
Below you see a picture of what your desktop will look like the first time you start up
Ubuntu.
This is where you start up This is where you log
programs, open Explorer-‐type out, restart or shut
windows, or alter settings down your computer
1
One way of deleting files inside
Click on this icon to
the user interface (≠ Terminal) is
temporarily hide all the open
windows on your desktop dragging them to the trash
Let’s look at the three menus at the top right: Applications, Places, and System.
Applications is where you can find many of the applications in Ubuntu (at least
the ones with a GUI!). This works just like the Start menu in Windows.
2
standard text editor gedit Text Editor for instance, the Ubuntu equivalent of Windows’
Notepad. The Places menu lists different common or important locations on your
computer.
The Places menu in Ubuntu
If you select your Places > Home Folder, you open a file explorer window of your
home directory. Your home directory is where your personal files and subdirectories
are saved. The window should look something like this.
The third menu that is interesting is the System menu. This is where you can alter many
of Ubuntu’s settings, such as user accounts, desktop backgrounds, keyboard layouts,
install new software, etc.
You can create shortcuts to each of the items in these three menus on, for instance, your
desktop. Just drag an icon to the desktop. Try dragging the Firefox browser icon to your
desktop. If all went well, you now have a link to Firefox on your desktop as well. Try
playing around with Ubuntu a bit to get a feel for how things work.
When you’re ready, we’re going to dig a little deeper into Ubuntu. Go to
Applications > Accessories and start up a Terminal. This should look like this
The Terminal is similar to the Command Prompt in Windows. It’s a command-‐ line
interface to the system. This means that you can get direct access to all the functionality
by typing in commands. In some cases, using a GUI is superior, but for other tasks
being able to directly execute multiple tasks with a single line of commands can save
you lots of time. It depends on the task your performing whether one or the other is the
best choice. In the rest of this tutorial you’ll learn to use the command line for small
tasks.
4
Lab Task:
Run these Linux commands in ubuntu, take screenshot and submit the assignment on
portal.
5
tail Display the last few lines of a text file.
Example: tail /etc/services
cp copy Copies a file from one location to
another. Example: cp mp3files.txt /tmp
(copies the mp3files.txt file to the /tmp directory)
mv rename, ren, Moves a file to a new location, or renames it.
move For example: mv mp3files.txt /tmp
(copy the file to /tmp, and delete it from the original
location)
rm del Delete a file. Example: rm /tmp/mp3files.txt
mkdir md Make Directory. Example: mkdir /tmp/myfiles/
rmdir rd, rmdir Remove Directory. Example: rmdir /tmp/myfiles/
Finding Things:
The following commands are used to find files. “ls” is good for finding files if you
already know approximately where they are, but sometimes you need more powerful
tools such as these:
Linux Descriptio
Comman n
d
which Shows the full path of shell commands found in your path. For example, if you
want to know exactly where the “grep” command is located on the filesystem,
you can type “which grep”. The output should be something like: /bin/grep
whereis Locates the program, source code, and manual page for a command (if all
information is available). For example, to find out where “ls” and its man page
are, type: “whereis ls” The output will look something like:
ls: /bin/ls /usr/share/man/man1/ls.1.gz
locate A quick way to search for files anywhere on the filesystem. For example, you
can find all files and directories that contain the name “mozilla” by typing:
locate mozilla
find A very powerful command, but sometimes tricky to use. It can be used to
search for files matching certain patterns, as well as many other types of
searches. A simple example is:
find . -name \*mp3
This example starts searching in the current directory “.” and all sub-
directories, looking for files with “mp3” at the end of their names.
Informational Commands:
The following commands are used to find out some information about the user or the
system.
6
Linux Command Explanatio
n
ps Lists currently running process (programs).
w Show who is logged on and what they are doing.
id Print your user-id and group id's
df Report filesystem disk space usage (“Disk Free” is how I remember it)
du Disk Usage in a particular directory. “du -s” provides a summary for
the current directory.
top Displays CPU processes in a full-screen GUI. A great way to see the
activity on your computer in real-time. Type “Q” to quit.
free Displays amount of free and used memory in the system.
cat /proc/cpuinfo Displays information about your CPU.
cat /proc/meminfo Display lots of information about current memory usage.
uname -a Prints system information to the screen (kernel version, machine type,
etc.)
Other Utilities:
Here are some other commands that are useful to know.
Linux Command Descriptio
n
clear Clear the screen
echo Display text on the screen. Mostly useful when writing shell scripts. For
example: echo “Hello World”
more Display a file, or program output one page at a time. Examples:
more mp3files.txt ls -la |
more
less An improved replacement for the “more” command. Allows you to scroll
backwards as well as forwards.
lpr Print a file or program output. Examples:
lpr mp3files.txt - Print the mp3files.txt file
ls -la | lpr - Print the output of the “ls -la” command.
7
]