Você está na página 1de 57

Lecturer notes -

Eng. Roble Mohamed Ali

Ubuntu Linux
book Prepared by Prof:
Rooble Mohamed Ali

Lecturer at PIDAM University ,University Of


Bosaso Somalia

1
Lecturer notes -
Eng. Roble Mohamed Ali

Chapter 1: Linux introduction


Linux History

Linux looks like UNIX system. Linux is developed by Linux Torvalds. Linux development
began in 1991. Linux source code is available for free on the internet. The basic Linux system is
standard environment for applications and user programming.

Definition
Linux is a modern, free operating system based on UNIX standards. It has designed to run
efficiently and reliably on common PC hardware; it also runs on a variety of other platforms. It
provide a programming interface and user interface compatible with standard UNIX systems and
can run a large number of UNIX applications, including an increasing number of commercially
supported applications.
Components of a Linux System
Any Linux system consists of three components.
1. Kernel
2. System libraries
3. System utilities

Kernel:
The Kernel is responsible for maintaining all the important abstraction of the operating system. It
includes virtual memory and processes. Kernel is most important component of the Linux
system.
2
Lecturer notes -
Eng. Roble Mohamed Ali

System libraries:
It contains standard set of functions through which application can interact with the Kernel.
System library implements much of the operating system functionality that does not need the full
privileges of Kernel code.

System utilities:
System utilities are programs that perform individual, specialized management tasks

Linux BASIC FEATURES


Linux has a number of features, mostly good and some bad, but it is necessary to know at least
some of them:
1. UNIX is Portable: Portability is the ability of the software that operates on one machine to
operate on another, different machine.
2. Open system: The system that more than one system can access the same data at the same
time. Or distributed by network.
3. open source : free and available on the internet
4. Multi-user Capability: This means that more than one system can access the same data at the
same time. Several people involved in a common project can conveniently access each others
data. Apart from data, other resources like memory(RAM), the
CPU(the chip), or the hard disk can be used by many users simultaneously.
4. multi-users : one or more users can access at the same time
5. Multi-tasking Capability: Multi-tasking means that a user can perform more than one tasks
at the same time. A user can do this by placing some tasks in the background while he works on a
task in the foreground. An ampersand(&) placed at the end of the command line sends the
process in background

6. Reliability: biggest servers on this planet running on Linux .


.
7. Linux has built in networking: The Linux has various built in programs and utilities like
UUCP, mail, write, etc. With these utilities one can communicate with other user or one server to
another.
8. Security: Computer system security means protecting hardware and the information contained
within the system. Security means to avoid:
a) Unauthorized access to the computer system.
b) Unauthorized examination of output.
9. Software Development Tools: Linux offers an excellent variety of tools for software
development for all phases, from program editing to maintenance of software.

BASIC ARCHITECTURE OF UNIX/LINUX SYSTEM

3
Lecturer notes -
Eng. Roble Mohamed Ali

1. Hardware: The hardware at the centre of the structure provides the operating system with
basic services. The hardware constitutes all the peripherals like memory (RAM, HDD, FDD, CD
etc), processor, mouse and other input devices, terminal (i.e. VDUs), printers etc.
2. The Kernel: The operating system interacts directly with the hardware, providing common
services to programs and insulating user program complexities of hardware. The operating
system is also called as Kernel. This kernel interacts directly with the hardware. Because of this
hardware isolation of user program, it is easy to move the user programs easily between UNIX
systems running on different hardware.
3. Shell: Shell is actually the interface between the user and the Kernel that isolates the user from
knowledge of Kernel functions. The shell accepts the commands keyed in by the users and
checks for their syntax and gives out error messages if something goes

Popular shells :
C shell - csh : resembles that of the C programming language
Bourne shell sh : used on Unix and Linux
Korne shell ksh : standard configuration
Tc shell - Tcsh : similar to the C shell
Bash shell the basic shell available on all linux

Flavors of UNIX

AIX- IBM : uses mainframe computers


BSD/- : commercial version
HP UX : for business servers
4
Lecturer notes -
Eng. Roble Mohamed Ali

Solaries ; sun Microsystems for web servers

The most popular Linux Distributions


1. Ubuntu : is the most well-known linux distribution based on Debian .
2. Linux mint : is a Linux distribution built on top of Ubuntu
3. Debian is Os composed only of free , open source
4. Federa is responsored by Redhat
5. Cent Os : is community project and available for free
6. Open use /SUSE Enterprise ::is community created Linux distribution sponsored by
Novell

Chapter 2: Ubuntu Linux

Ubuntu Philosophy
The term Ubuntu is a traditional African concept originating from the Bantu languages of
southern Africa. It can be described as a way of connecting with othersliving in a global
community where your actions affect all of humanity. Ubuntu is more than just an operating
system: it is a community of people coming together voluntarily to collaborate on an
international software project that aims to deliver the best possible user experience.

A brief history of Ubuntu


Ubuntu was conceived in 2004 by Mark, a successful South African entrepreneur, and his
company Canonical. Shuttle worth recognized the power of Linux and open source, but was also
aware of weaknesses that prevented mainstream use
Shuttleworth set out with clear intentions to address these weaknesses and create a system that
was easy to use, completely free , and could compete with other mainstream operating systems.
With the Debian system as a base, Shuttle worth began to build Ubuntu. Using his own funds at
first.
installation CDs were pressed and shipped worldwide at no cost to the recipients. Ubuntu spread
quickly, its community grew rapidly, and soon Ubuntu became the most popular Linux
distribution available.
With more people working on the project than ever before, its core features
and hardware support continue to improve, and Ubuntu has gained the attention of large
organizations worldwide. One of IBMs open source operating systems is based on Ubuntu. In
2005, the French Police began to transition their entire computer infrastructure to a variant of
Ubuntua process which has reportedly saved them millions of euros in licensing fees for
Microsoft Windows. By the end of 2012, the French Police anticipates that all of their computers
will be running Ubuntu. Canonical profitsfrom this arrangement by providing technical support
and custom-built software .While large organizations often find it useful to pay for support
5
Lecturer notes -
Eng. Roble Mohamed Ali

services, Shuleworth has promised that the Ubuntu desktop operating system will always be
free, As of 2012, Ubuntu is installed on an estimated 2% of the worlds computers. this equates
to tens of millions of users worldwide, and is growing each year. As there is no compulsory
registration, the percentage of Ubuntu users should be treated as an estimate.

Proprietary Software vs Free/Libre Open-Source Software

Proprietary software is designed, developed and marketed by a company as their own system. It
is sold for profit and functions on only one type of computer. Examples of proprietary operating
systems include Microsoft Windows and Mac OS X. The source code of these systems is not
freely available and if you tried to modify or distribute it would constitute a felony.

Ubuntu, on the other hand, is NOT proprietary software because it is actively maintained by the
FLOSS community.

What Is FLOSS?

FLOSS is the acronym for Free/Libre Open-Source Software. FLOSS software is different from
proprietary or commercial software because it is:

FREE to use

FREE to share, and

FREE to develop

This means you can download and use Ubuntu without paying money. You can then make copies
of the software and distribute it to as many people as you want. Finally, the source code of
Ubuntus operating system is freely available, so you can inspect the program and make changes
to suit your own needs.

This freedom is made possible because Ubuntu uses the GNU General Public License (or simply
GPL) which is the most widely used software license in the FLOSS community. The GPL was
written by computer programmer Richard Stallman in 1989, and explicitly states that users are
free to run, copy, distribute, inspect, change, develop and improve the software provided they
provide the same freedom to others.

. Its Managed & Funded By Canonical

Although Ubuntu is maintained by the FLOSS community, it is managed and funded by a


privately held company called Canonical Ltd. Canonical was founded (and funded) in 2004 by
6
Lecturer notes -
Eng. Roble Mohamed Ali

South African entrepreneur, Mark Shuttleworth, the visionary behind Ubuntu.


Canonical provides commercial support to companies using Ubuntu for a fee. The revenue from
this support then goes towards the ongoing development of Ubuntu, developments such as:

releasing new versions of Ubuntu every six months

coordinating security, and

hosting servers for Ubuntus online community

Canonicals main offices are in in London, but it also has offices in Canada, the US, and
Taiwan.

The Ubuntu Operating System

As youve hopefully learned by now, Ubuntu is many things, but it is most famous for being a
computer operating system. In simplest terms, an operating system, or OS, is software that
communicates with computer hardware. What sets Ubuntu apart from proprietary operating
systems, and what makes it similar to other FLOSS operating systems, is that Ubuntu uses the
Linux kernel.

Why Use Ubuntu?

There are many reasons to use Ubuntu, but here are some of the most important ones:

Its free and open source: shared code, shared efforts, shared principles, no cost.

Its easy to use, trial and install: you dont have to be an expert.

Its beautiful, sleek, and stylish: learn more about the Unity desktop environmen

Its stable and fast: usually loads in less than a minute on modern computers.

It has no major viruses! Ubuntu is immune to computer-crashing Windows viruses. Say


goodbye to Blue Screens of Death!

Its up-to-date: Canonical releases new versions of Ubuntu every six months and also brings
you regular updates for free.

7
Lecturer notes -
Eng. Roble Mohamed Ali

It is supported: you can get all the support and advice you need from the global FLOSS
community and Canonical.

. Ubuntu Releases

Ubuntu Version Numbers

Canonical releases new versions of Ubuntu every six months, in April and October. Each Ubuntu
release has a version number that contains the year and month of its release. This guide, for
example, discusses the latest version of Ubuntu 11.10 which was released in October of 2011.
The next scheduled release of Ubuntu, version 12.04, will be in April of 2012; the one after that
will be 12.10 in October of 2012, and so on.

Ubuntu Code Names

In addition to version numbers, Ubuntu releases are also given alliterative code names using an
adjective and an animal. The code name for Ubuntu 11.10 is Oneiric Ocelot; for version 12.04, it
will be Precise Pangolin. So if you find yourself talking to a fellow Ubuntu enthusiast and they
are raving about Natty Narwhal, they are not talking about their love for fashionable marine
mammals, but rather version 11.04 of the Ubuntu operating system.

For a complete listing of Ubuntu versions and code names, see the table below.

Normal Releases vs. Long Term Support (LTS) Releases

One of the great features of Ubuntu (and there are many) is that it is supported within a
structured time frame. New versions of the operating system are released every six months and
are normally supported by Canonical for 18 months thereafter. These versions are referred to as
normal releases.

In addition to normal releases, Canonical also develops Long Term Support (LTS) releases which
are versions of Ubuntu that are released approximately every two years (if on schedule) and are
supported for three years thereafter. The upcoming version of Ubuntu, 12.04, will be a Long
Term Support release.

8
Lecturer notes -
Eng. Roble Mohamed Ali

Ubuntu 14.10 - the current stable support version, released in late October 2014, codenamed
Utopic Unicorn.

Ubuntu 14.04 LTS - the current long term support version, released in mid April 2014,
codenamed Trusty Tahr.

Ubuntu 12.04 LTS - a previous long term support version, released in April 2012, codenamed
Precise Pangolin.

Ubuntu 10.04 LTS - a previous long term support version, released in April 2010, codenamed
Lucid Lynx

Installing Ubuntu

Different Ways To Install Ubuntu

There are three different ways you can install Ubuntu on to your computer:

9
Lecturer notes -
Eng. Roble Mohamed Ali

Download & Install It

This option will replace your current operating system with Ubuntu. A complete installation will
run the fastest and smoothest on your computer, but requires a full commitment to leave behind
your old operating system.

For step-by-step instructions on how to do this, please visit:

http://www.ubuntu.com/download/ubuntu/download

Note that this method can also be used to create a dual-boot setup, but requires some knowledge
of partitioning. Keep reading for an easier method.

Try It On A CD Or USB Stick

This option will allow you to maintain your current operating system and also run Ubuntu from
an independent storage device. This installation requires the least commitment from you and
your computer, but will probably affect the quality and speed of Ubuntus performance.

For step-by-step instructions on how to do this, please visit:

http://www.ubuntu.com/download/ubuntu/download

Run It alongside Windows Or Mac OS

This option, also known as a dual boot installation, will install Ubuntu on your computer
alongside your current Windows or Mac operating system. Whenever you start your computer,
you will have the option of choosing to boot into Ubuntu or Windows/Mac OS.

This is the installation option that we will be discussing in this guide as it is the easiest way for
beginners to transition to Ubuntu. Detailed instructions will be provided for a Windows 7 dual
boot installation, but for those using Mac OS,

2 Installing Ubuntu Alongside Windows 7 With Wubi

Installing Ubuntu alongside Windows is easy to save time , here steps with pictures

1. Put the Ubuntu DVD into the DVD-drive

10
Lecturer notes -
Eng. Roble Mohamed Ali

2. Restart your computer. You should see a welcome screen prompting you to choose your
language and giving you the option to install Ubuntu or try it from the DVD.

3. As the Ubuntu boots, you can see the following screen.

4. Prepare to install Ubuntu

a. We recommend you plug your computer into a power source

b. You should also make sure you have enough space on your computer to install
Ubuntu

c. We advise you to select Download updates while installing and Install this third-
party software now

d. You should also stay connected to the internet so you can get the latest updates
while you install Ubuntu

e. If youre not connected to the internet, well help you set up wireless at the next
step

11
Lecturer notes -
Eng. Roble Mohamed Ali

5. Allocate drive space


Use the checkboxes to choose whether youd like to Install Ubuntu alongside another
operating system, delete your existing operating system and replace it with Ubuntu, or
if youre an advanced user choose the Something else option
6. Begin the installation

Depending on your previous selections, you can now verify that you have chosen the way
in which you would like to install Ubuntu. The installation process will begin when you
click the Install Now button. Ubuntu needs about 4.5 GB to install, so add a few extra GB
to allow for your files.

7. Select your location

If you are connected to the internet, this should be done automatically. Check your
location is correct and click Forward to proceed. If youre unsure of your time zone,
type the name of the town youre in or click on the map and well help you find it.

8. Select your preferred keyboard layout

Click on the language option you need. If youre not sure, click the Detect Keyboard
Layout button for help

9. Enter your login and password details

12
Lecturer notes -
Eng. Roble Mohamed Ali

Learn more about Ubuntu while the system installs

Chapter 3: the Ubuntu Desktop

Getting Started With Unity

Now that youve successfully installed Ubuntu and logged in for the first time, you should be
greeted with a screen that looks something like this:

13
Lecturer notes -
Eng. Roble Mohamed Ali

What Is Unity?

Unity is Ubuntus default desktop environment. In simplest terms, it is what you see when you
log-in to Ubuntu. It is within Unity that you can drag, drop, and click on various icons and
menus to interact with the Ubuntu operating system

The Unity Interface

The Unity interface is made up of four main components:

Desktop

Launcher

Panel

Dash (accessed by the Ubuntu button)

14
Lecturer notes -
Eng. Roble Mohamed Ali

Desktop

The desktop is your main work space and it is here that you can open, run and rearrange multiple
programs and applications.

Launcher

The Launcher is a vertical docking station for your favourite folders and applications. It lives on
the left-hand side of the Unity desktop environment and will automatically hide itself until you
hover your mouse over it. Launcher icons indicate the specific applications that can be run and
managed through the Launcher.

Panel

The panel is the horizontal bar located at the very top of the Unity desktop environment. The
panel is important because it contains the status and application menus which allow you to
control and change settings for your system and programs.

15
Lecturer notes -
Eng. Roble Mohamed Ali

Dash

The Dash is an interface (see figure below) within Unity that allows you to search for and run
any file, folder, or application. To open the Dash, simply click on the Ubuntu button at the top of
your Launcher.

Navigating The Launcher

The Launcher, located on the left-hand side of the Unity desktop environment, allows you to:

Open folders

Run and manage your favourite applications

Access the Dash

Its important to note that the Launcher will automatically hide itself if you are not actively
working with it. To make the Launcher reappear, simply hover your mouse over the left-hand
side of your screen.

Opening Folders & Running Applications From Your Launcher

To open a folder or start an application from your Launcher, simply click on the Launcher icon.
As the application begins to load, the icon will flash and become translucent before returning to
its original colour.

Once an application has loaded, a small white arrow will appear on the left-hand side of the
Launcher icon. In programs where you can have multiple sessions, like web browsers, the

16
Lecturer notes -
Eng. Roble Mohamed Ali

number of arrows on the lefthand side will indicate how many windows you have open. If an
arrow appears on the right-hand side of a Launcher icon, this indicates your active application, or
the one you are currently using.

Adding Applications To Your Launcher

To add an application to your Launcher:

1. Click on the Ubuntu button to open the Dash

2. Type in the name of your software application

3. Drag the software icon to your Launcher

4. Drop the icon where you want to place it

17
Lecturer notes -
Eng. Roble Mohamed Ali

Rearranging Applications On Your Launcher

If you want to change the order or position of an application in your Launcher, you can:

1. Click and drag the Launcher icon that you want to move, and then,

2. Release the mouse button to place the icon in its new location

Removing Applications From The Launcher

The Launcher comes with several default applications that you can rearrange or remove
completely. Removing an icon from your Launcher, however, will not remove or uninstall the
application from your computer. You can still access any program or application from the Dash.

To remove an application from your Launcher:

1. Right-click on the Launcher icon

2. Un-check Keep in Launcher to remove the application

18
Lecturer notes -
Eng. Roble Mohamed Ali

Navigating The Panel

The Panel is the horizontal bar located at the very top of your screen and contains two main
components: the application menu on the left-hand side and status menu on the right-hand side.

Application Menu

The application menu allows you to control the active applications functionality and modify its
settings and preferences. The window title, or name of the active application or folder, is
displayed in bold. To the right of the window title is the application menu (File, Edit, View, etc.).

It is important to note that the application menu will not appear unless you hover your
mouse over the left-hand side of the panel.

This functionality of automatic hiding is called menu discoverability, and while some users may
find it inconvenient, the decision to hide the menus was an aesthetic one so that the panel would
have a clean and uncluttered look.

To close (X), minimize (-) or maximize (?) the application, click on the appropriate window
button. If your application menu is not maximized, however, the window buttons will not appear
in the panel but in the application window instead.

Status Menu & System Indicators

The Status menu, located in the right-hand side of your panel, contains system indicators which
notify you of important changes to your system and allow you to control and change preferences
for the following:
19
Lecturer notes -
Eng. Roble Mohamed Ali

email, chat, and social media messaging

power settings (if using a laptop)

network connection

sound preferences

date and time

user accounts

computer session

The Messaging Indicator

The Messaging indicator is the leftmost indicator in the Panel Status menu. From the Messaging
indicator, you can:

access the Thunderbird application to manage your email

access the Empathy application to manage your chat programs

access the Gwibber application to manage your social networking accounts

access your cloud storage with Ubuntu One

See notifications for all of these services: the envelope turns green whenever a message is
waiting for you.

20
Lecturer notes -
Eng. Roble Mohamed Ali

21
Lecturer notes -
Eng. Roble Mohamed Ali

The Battery Indicator

The Battery indicator is located to the right of the Messaging indicator.

From the Battery indicator, you can:

view power status

view estimated battery life

adjust power settings

The Network indicator

The Network indicator is located to the right of the Battery indicator.

From the Network indicator, you can:

access the Internet by connecting to a wireless network

manage all of your network settings

22
Lecturer notes -
Eng. Roble Mohamed Ali

The Sound indicator

The Sound indicator is located to the right of the Network indicator.

From the Sound indicator, you can:

adjust the volume settings of your computer

access the Banshee Media Player application to manage your music

The Clock indicator

23
Lecturer notes -
Eng. Roble Mohamed Ali

The Clock indicator is located to the right of the Sound indicator.

From the Clock indicator, you can:

adjust your systems date and time settings

add date and time information for other cities

view a monthly calendar

The Account indicator

The Account indicator is located to the right of the Clock indicator.

24
Lecturer notes -
Eng. Roble Mohamed Ali

From the Account indicator, you can:

log out and switch user accounts

manage administrator settings for user accounts

The Session indicator

The Session indicator is the right most indicator in the Panel Status menu.

From the Session indicator, you can:

adjust your system settings (monitor display, themes, hardware, etc)

lock, suspend or hibernate your computer

log out and switch user accounts

shut down or restart your computer

25
Lecturer notes -
Eng. Roble Mohamed Ali

Navigating The Dash

The Dash is an interface within Unity that provides you with fast and easy access to your files
and applications. You can search your computer using titles or keywords and filter your results
based on specific categories. One of the most helpful features of the Dash is that it is able to
recognize what you have opened most recently and most often making access to all of your
favourite things that much faster.

Accessing The Dash

To open the Dash, simply click on the Ubuntu button at the top of your Launcher or click the
Super Key (sometimes called the Windows Key for some reason.)

26
Lecturer notes -
Eng. Roble Mohamed Ali

The Dash Interface

The Dash has a simple interface with a few components. It is basically a large screen where you
type a query in your search bar and are provided with results below. From there, you can click on
any of the search results to open the file or run the program or you can narrow your search using
filters.

When you first click on the Ubuntu button, you will be taken to the Dash home, which contains:

Global search bar

Shortcuts; and

Lenses

The Global search bar is where you type in your query. It is located in the top-left of every Dash
screen and is active right when you open the dash: just start typing to search.

Shortcuts in the Dash home are clickable icons that will quickly take you to the following
programs:

Mozilla Firefox to browse the web

Shotwell Photo Manager to view photos

Mozilla Thunderbird to manage email

Banshee Media playerto listen to music

27
Lecturer notes -
Eng. Roble Mohamed Ali

Lenses are essential elements of the Dash through which you can search for specific types of
files and applications. You can think of a lens as a filter for your search results. There are
currently four lenses which are accessible through icons located at the bottom of the Dash:

Global Search Lens

Applications Lens

Files and Folders Lens

Music Lens

You can also access the Application Lens (Media, Internet, and general applications) and Files
and Folder Lens through shortcut icons in the Dash home.

Find apps, files, music, and more with the Dash

28
Lecturer notes -
Eng. Roble Mohamed Ali

The Dash allows you to search for applications, files, music, and videos, and shows you items
that you have used recently. If you have ever worked on a spreadsheet or edited an image and
forgot where you saved it, you will surely find this feature of the Dash to be useful.

To start using the Dash, click the top icon in the Launcher. This icon has the Ubuntu logo on it.
For faster access, you can just press the Super key.

To hide the Dash, click the top icon again or press Super or Esc.

Browse files and folders


Use the Files file manager to browse and organize the files on your computer. You can also use it
to manage files on storage devices (like external hard disks), on file servers, and on network
shares.

To start the file manager, open Files in the Launcher. You can also search for files and folders
with the Dash in the same way you would search for applications. They will appear under the
heading Files and Folders.

Copy or move files and folders


1. Select the file you want to copy by clicking on it once.

2. Right-click and pick Copy, or press Ctrl+C.

3. Navigate to another folder, where you want to put the copy of the file.

4. Right-click and pick Paste to finish copying the file, or press Ctrl+V. There will now be a
copy of the file in the original folder and the other folder.

Cut and paste files to move them


1. Select the file you want to move by clicking on it once.

2. Right-click and pick Cut, or press Ctrl+X.

3. Navigate to another folder, where you want to move the file.

4. Right-click and pick Paste to finish moving the file, or press Ctrl+V. The file will be
taken out of its original folder and moved to the other folder.

Drag files to copy or move


1. Open the file manager and go to the folder which contains the file you want to copy.

29
Lecturer notes -
Eng. Roble Mohamed Ali

2. Click Files in the top bar, select New Window (or press Ctrl+N) to open a second
window. In the new window, navigate to the folder where you want to move or copy the
file.

Click and drag the file from one window to another. This will move it if the destination is on the
same device, or copy it if the destination is on a different device

Delete files and folders

To send a file to the trash:


1. Select the item you want to place in the trash by clicking it once.

2. Press Delete on your keyboard. Alternatively, drag the item to the Trash in the sidebar.

To permanently delete a file:


1. Select the item you want to delete.

2. Press and hold the Shift key, then press the Delete key on your keyboard.

Because you cannot undo this, you will be asked to confirm that you want to delete the file or
folder

Rename a file or folder

1. Right-click on the item and select Rename, or select the file and press F2.

2. Type the new name and press Enter.

Search for files


1. Open the file manager

2. If you know the files you want are under a particular folder, go to that folder.

3. Click the magnifying glass in the toolbar, or press Ctrl+F.

4. Type a word or words that you know appear in the file name. For example, if you name
all your invoices with the word "Invoice", type invoice. Press Enter. Words are matched
regardless of case.

5. You can narrow your results by location and file type.

30
Lecturer notes -
Eng. Roble Mohamed Ali

o Click Home to restrict the search results to your Home folder, or All Files to
search everywhere.

o Click + and pick a File Type from the drop-down list to narrow the search results
based on file type. Click the x button to remove this option and widen the search
results.

6. You can open, copy, delete, or otherwise work with your files from the search results, just
as you would from any folder in the file manager.

7. Click the magnifying glass in the toolbar again to exit the search and return to the folder.

Sort files and folders

You can sort files in different ways in a folder, for example by sorting them in order of date or
file size.

Manage apps & settings with the menu bar

The menu bar is the dark strip on the top of your screen. It contains the window management
buttons, the app menus, and the status menus.

Window management buttons

The window management buttons are on the top left corner of windows. When maximized, the
buttons are in the top left of the screen. Click the buttons to close, minimize, maximize or restore
windows.

App menus

The app menus are by default located to the right of the window management buttons. Unity
hides the app menus and the window management buttons unless you move your mouse pointer
to the top left of the screen or press Alt+F10. This feature enables you to see more of your
content at once, which is especially valuable on small screens like netbooks.

If you want, you can change the default behavior, and have your menus attached to the window
title bar of respective application instead of the menu bar.

1. Click the icon at the very right of the menu bar and select System Settings.

2. In the Personal section, click Appearance and choose the Behavior tab.

31
Lecturer notes -
Eng. Roble Mohamed Ali

3. Under Show the menus for a window, select In the window's title bar.

Status menus

Ubuntu has several different status menus (sometimes referred to as indicators) on the right side
of the menu bar. The status menus are a convenient place where you can check and modify the
state of your computer and applications.

Log out, power off, switch users

When you've finished using your computer, you can turn it off, suspend it (to save power), or
leave it powered on and log out.

Log out or switch users

To let other users use your computer, you can either log out, or leave yourself logged in and just
switch users.

To log out or switch users, click the system menu at the very right of the menu bar and select the
appropriate option.

Lock the screen

If you're leaving your computer for a short time,

To lock your screen, click the system menu in the menu bar and select Lock Screen

Suspend

To save power, suspend your computer when you aren't using it. To suspend your computer
manually, click the system menu in the menu bar and select Suspend.

Chapter 4: User & system settings

User accounts
Each person that uses the computer should have a different user account. This allows them to
keep their files separate from yours and to choose their own settings. It's also more secure. You
can only access a different user account if you know the password.

32
Lecturer notes -
Eng. Roble Mohamed Ali

Add a new user account and password


You can add multiple user accounts to your computer. Give one account to each person in your
household or company. Every user has their own home folder, documents, and settings.

1. Click the icon at the far right of the menu bar and select System Settings.

2. Open User Accounts.

3. You need administrator privileges to add user accounts. Click Unlock in the top right
corner and type your password.

4. In the list of accounts on the left, click the + button to add a new user account.

5. If you want the new user to have administrative access to the computer, select
Administrator for the account type. Administrators can do things like add and delete
users, install software and drivers, and change the date and time.

6. Enter the new user's full name. The username will be filled in automatically based on the
full name. The default is probably OK, but you can change it if you like.

7. Click Create.

8. The account is initially disabled until you choose what to do about the user's password.
Under Login Options click Account disabled next to Password. Select Set a password
now from the Action drop-down list, and have the user type their password in the New
password and Confirm password fields..

You can also click the button next to the New password field to select a randomly
generated secure password. These passwords are hard for others to guess, but they can be
hard to remember, so be careful.

9. Click Change.

Change your login screen photo


When you log in or switch users, you will see a list of users with their login photos. You can
change your photo to a stock image or an image of your own. You can even take a new login
photo with your webcam.

1. Click the icon at the far right of the menu bar and select System Settings.

2. Open User Accounts.

33
Lecturer notes -
Eng. Roble Mohamed Ali

3. Click the picture next to your name. A drop-down gallery will be shown with some stock
login photos. If you like one of them, click it to use it for yourself.

4. If you'd rather use a picture you already have on your computer, click Browse for more
pictures.

Change your password


It is a good idea to change your password from time to time, especially if you think someone else
knows what your password is.

1. Click the icon at the far right of the menu bar and select System Settings.

2. Open User Accounts.

3. Click the label next to Password.

The label should look like a series of dots or boxes if you already have a password set.

4. Enter your current password, then a new password. Enter your new password again in the
Confirm password field.

You can also click the button next to the New password field to select a randomly
generated secure password. These passwords are hard for others to guess, but they can be
hard to remember, so be careful.

5. Click Change.

Delete a user account


You can add multiple user accounts to your computer..

1. Click the icon at the far right of the menu bar and select System Settings.

2. Open User Accounts.

3. Click Unlock in the top right corner and type your password to make changes. You must
be an administrative user to delete user accounts.

4. Select the user you want to delete and click the - button.

5. Each user has their own home folder for their files and settings. You can choose to keep
or delete the user's home folder. Click Delete Files if you're sure they won't be used
anymore and you need to free up disk space. These files are permanently deleted. They
34
Lecturer notes -
Eng. Roble Mohamed Ali

can't be recovered. You may want to back up the files to an external drive or CD before
deleting them.

Change who has administrative privileges


Administrative privileges are a way of deciding who can make changes to important parts of the
system. You can change which users have admin privileges and which ones don't. They are a
good way of keeping your system secure and preventing potentially damaging unauthorized
changes.

1. Click the icon at the far right of the menu bar and select System Settings.

2. Open User Accounts.

3. Click Unlock and enter your password to unlock the account settings. (To give a user
admin privileges, you must have admin privileges yourself.)

4. Select the user whose privileges you want to change.

5. Click the label Standard next to Account type and select Administrator.

6. Close the User Accounts window. The user's privileges will be changed when they next
log in.

Display & screen


Setting up your screen resolution
One of the most common display related tasks is setting the correct screen resolution for your
desktop monitor or laptop.
To set or check your screen resolution, go to System Settings Displays.- Displays window
detects automatically the type of display and shows your displays name, size

Change the desktop background


You can change the image used for your desktop background, or set it to a simple color or
gradient.

1. Right click on the desktop and select Change Desktop Background.

2. Select an image or color. The settings are applied immediately.

35
Lecturer notes -
Eng. Roble Mohamed Ali

Change the size or rotation of the screen


You can change how big (or how detailed) things appear on the screen by changing the screen
resolution. You can change which way up things appear by changing the rotation.

1. Click the icon on the very right of the menu bar and select System Settings.

2. Open Displays.

3. If you have multiple displays and they are not mirrored, you can have different settings
on each display. Select a display in the preview area.

4. Select your desired resolution and rotation.

5. Click Apply. The new settings will be applied for 30 seconds before reverting back. That
way, if you cannot see anything with the new settings, your old settings will be
automatically restored. If you are happy with the new settings, click Keep This
Configuration.

Change the date and time


If the date and time displayed on the menu bar are incorrect or in the wrong format, you can
change them:

1. To adjust the time and date, click on the clock located in the menu bar and select Date &
Time Settings.

2. Change the system time zone by clicking on the map or entering your city into the
Location box.

By default, Ubuntu periodically synchronizes the clock with a very accurate clock on the Internet
so you don't have to set your clock manually.

Sound

Ubuntu usually detects the audio hardware of the system automatically during installation
Volume icon and Sound Preferences
A volume icon, sitting on the top right corner of the screen, provides quick access to a number of
audio related functions. When you left-click on the volume icon you are greeted with four
options.

Change languages
When you install Ubuntu, the language you select at installation gets installed together with
English, but you can add further languages.
36
Lecturer notes -
Eng. Roble Mohamed Ali

1. Click the icon at the very right of the menu bar and select System Settings.

2. In the Personal section, click Language Support.

3. Click Install / Remove Languages.... The Installed Languages window lists all the
available languages, with the currently installed languages checked.

4. Check the languages you want to install, and uncheck those currently installed languages
you want to remove.

5. Click Apply Changes.

Chapter 5:Working with software


All the applications you need
If you are migrating from a Windows or Mac platform, you may wonder if the programs that you
once used are available for Ubuntu Most of the applications listed in this section are available
via the Software Center.
Office Suites
In Ubuntu you may choose among many office suites. The most popular suite is the LibreOffice
(formerly OpenOffice). Included in the suite:
Writerword processor
Calcspreadsheet
Impresspresentation manager
Drawdrawing program
Basedatabase
Mathequation editor
LibreOffice Suite is installed by default. Note that Base is not installed by
default and it can be installed through Ubuntu Software Center

Email Applications
Linux: Mozilla ,Evolution, KMail
Web Browsers
Linux: Mozilla Firefox, Opera*, Chromium, Google Chrome*, Epiphany
The most popular web browsers can be installed directly from the Ubuntu Software Center.

37
Lecturer notes -
Eng. Roble Mohamed Ali

Install additional software


The Ubuntu development team has chosen a default set of applications that we think makes
Ubuntu very useful for most day-to-day tasks. However, you will certainly want to install more
software to make Ubuntu more useful to you.

To install additional software, complete the following steps:

1. Connect to the Internet using a wireless or wired connection.

2. Click the Ubuntu Software Center icon in the Launcher, or search for Software Center in
the Dash.

3. When the Software Center launches, search for an application, or select a category and
find an application from the list.

4. Select the application that you are interested in and click Install.

5. You will be asked to enter your password. Once you have done that the installation will
begin.

6. The installation usually finishes quickly, but could take a while if you have a slow
Internet connection.

7. A shortcut to your new app will be added to the Launcher. To disable this feature,
uncheck View New Applications in Launcher.

Remove an application
The Ubuntu Software Center helps you to remove software that you no longer use.

1. Click the Ubuntu Software Center icon in the Launcher or search for Software Center in
the Dash.

2. When the Software Center opens, click the Installed button at the top.

3. Find the application that you want to remove by using the search box or by looking
through the list of installed applications.

4. Select the application and click Remove.

5. You may be asked to enter your password. After you have done that, the application will
be removed.

38
Lecturer notes -
Eng. Roble Mohamed Ali

Chapter 6: working with Hardware


.Adjust speed of the mouse and touchpad
If your pointer moves too fast or slow when you move your mouse or use your touchpad, you
can adjust the pointer speed for these devices.

1. Click the icon at the very right of the menu bar and select System Settings.

2. Open Mouse & Touchpad.

3. Adjust the Pointer Speed slider until the pointer motion is comfortable for you.

Connecting and using your printer

Ubuntu supports most new printers. You can add, remove, and change printer properties by
navigating to System Settings Printing. You can also search for Printing from the Dash
search bar. Opening Printing will display the Printing-localhost window. When you want to
add a printer, you will need to make sure that it is switched on, and plugged into your computer
with a USB cable or connected to your network.
Adding a local printer
If you have a printer that is connected to your computer with a USB cable then this is termed a
local printer. You can add a printer by clicking on the Add Printer button. In the left hand pane
of the New Printer window any printers that you can install will be listed. Select the printer
that you would like to install and click Forward.You can now specify the printer name,
description and location. Each of these should remind you of that particular printer so that you
can choose the right one to use when printing. Finally, click Apply.
Adding a network printer
Make sure that your printer is connected to your network either with an Ethernet cable or via
wireless and is turned on. You can add a printer by clicking Add Printer. the New Printer
window will open. Click the +sign next to Network Printer. If your printer is found
automatically it will appear under Network
Printer. Click the printer name and then click Forward. In the text fields you can now specify
the printer name, description and location ,Finally click Apply
39
Lecturer notes -
Eng. Roble Mohamed Ali

Changing printer options


Printer options allow you to change the printing quality, paper size and media type. they can be
changed by right-clicking a printer and choosing Properties. the Printer Properties window
will show; in the le pane, select Printer Options. You can now specify settings by changing the
drop-down entries.

Set the default printer


If you have more than one printer available, you can select which will be your default printer.
You may want to pick the printer you use most often.

1. Click the icon at the far right of the menu bar and select System Settings.

2. Open Printers.

3. Right click your desired default printer from the list of available printers, and click Set as
Default.

Disks & storage


Check with System Monitor
To check the free disk space and disk capacity with System Monitor:

1. Open the System Monitor application from the Dash.

2. Select the File Systems tab to view the system's partitions and disk space usage. The
information is displayed according to Total, Free, Available and Used.

Check your disk's health using the Disks application


1. Open the Disks application from the Dash.

2. Select the disk you want to check from the Storage Devices list. Information and status of
the disk will appear under Drive.

3. SMART Status should say "Disk is healthy".

Click the SMART Data button to view more drive information, or to run a self-test.

View and manage volumes and partitions using the disk utility
You can check and modify your computer's storage volumes with the disk utility.

1. Open the Dash and start the Disk Utility application.


40
Lecturer notes -
Eng. Roble Mohamed Ali

2. In the pane marked Storage Devices, you will find hard disks, CD/DVD drives, and other
physical devices. Click the device you want to inspect.

3. In the right pane, the area labeled Volumes provides a visual breakdown of the volumes
and partitions present on the selected device. It also contains a variety of tools used to
manage these volumes.

Format a removable disk


1. Open the Disks application from the Dash.

2. Select the disk you want to wipe from the Storage Devices list.

Make sure that you have selected the correct disk! If you choose the wrong disk, all of the
files on the other disk will be deleted!

3. In the Volumes section, click Unmount Volume. Then click Format Volume.

4. In the window that pops up, choose a filesystem Type for the disk.

If you use the disk on Windows and Mac OS computers in addition to Linux computers,
choose FAT. If you only use it on Windows, NTFS may be a better option. A brief
description of the file system type will be presented as a label.

5. Give the disk a name and click Format to begin wiping the disk.

6. Once the formatting has finished, safely remove the disk. It should now be blank and
ready to use again.

Chapter 7: working with Networking


This section of the manual will help you to check your connection to the Internet and help you
configure it where needed. Ubuntu can connect to the Internet using a wired, wireless, or dialup
connection. Ubuntu also supports more advanced connection methods, which will be briefly
discussed at the end of this section.
A wired connection is when your computer connects to the Internet using an Ethernet cable. this
is usually connected to a wall socket or a networking devicelike a switch or a router,
A wireless connection is when your computer connects to the Internet using a wireless radio
networkusually known as Wi-Fi. Most routers now come with wireless capability, as do most
laptops and netbooks
41
Lecturer notes -
Eng. Roble Mohamed Ali

A dialup connection is when your computer uses a modem to connect to the Internet through a
telephone
Line
NetworkManager
In order to connect to the Internet using Ubuntu, you need to use the Network Manager utility.
Network Manager allows you to turn network connections on or off, manage wired and wireless
networks, and make other network connections, such as dial up, mobile broadband.

Create a wireless hotspot


to a wired network or over the cellular network.

1. Click the icon at the very right of the menu bar and select System Settings.

2. Open Network and select Wireless on the left.

3. Click the Use as Hotspot button.

4. If you are already connected to a wireless network, you will be asked if you want to
disconnect from that network. A single wireless adapter can only connect to or create one
network at a time. Click Create Hotspot to confirm

Find your internal (network) IP address


1. Click the icon at the very right of the menu bar and select System Settings.

2. Open Network and select Wired or Wireless from the list on the left, depending on which
network connection you want to find the IP address for.

3. Your internal IP address will be displayed in the list of information.

Connect to a wired (Ethernet) network


To set up most wired network connections, all you need to do is plug in a network cable. The
network icon on the menu bar should pulse for a few seconds and then will change to a "socket"
icon when you are connected.

Manually set network settings

To manually set your network settings:


1. Click the network menu on the menu bar and click Edit Connections.

2. Select the network connection that you want to set up manually. For example, if you plug
in to the network with a cable, look at the Wired tab.

42
Lecturer notes -
Eng. Roble Mohamed Ali

3. Click the connection you want to edit to select it, then click Edit.

4. Go to the IPv4 Settings tab and change the Method to Manual.

5. Click Add and type the IP address, network mask and default gateway IP address into the
corresponding columns of the Addresses list. Press Enter or Tab after typing each
address.

These three addresses must be IP addresses; that is, they must be four numbers separated
by periods (e.g., 123.45.6.78).

6. Type the IP addresses of the DNS servers you want to use, separated by commas.

7. Click Save. If you are not connected to the network, click the network icon on the menu
bar and connect. Test the network settings by trying to visit a website or look at shared
files on the network, for example.

Share your desktop


You can let other people view and control your desktop from another computer with a desktop
viewing application. Configure Desktop Sharing to allow others to access your desktop and set
the security preferences.

1. In the Dash, open Desktop Sharing.

2. To let others view your desktop, select Allow other users to view your desktop. This
means that other people will be able to attempt to connect to your computer and view
what's on your screen.

3. To let others interact with your desktop, select Allow other users to control your desktop.
This may allow the other person to move your mouse, run applications, and browse files
on your computer, depending on the security settings which you are currently using.

Chapter 8: Linux shells and Terminals

The shells allow user to directly communicate with the kernel. Shells form the most important
part of TUI or terminal or console. A shell can be described as a command line interpreter.

43
Lecturer notes -
Eng. Roble Mohamed Ali

All the strings that we enter the command line are actually input to that particular shell. Based on
the inputs, it will execute the corresponding process.
The major shells available in the Linux are,

Bash Bourne again shell


Ksh K shell
Csh C shell
TCsh Turbo C shell

In Linux, by default we are logging into the Bash shell.


After log in the Bash shell looks like the following. Go through the labels in the figure to learn
more.

Basic commands
This section will show you the execution of some basic commands in the Bash shell.
uname r
Type and enter the following will display the current kernel version.

Here the current kernel version is displayed below the entered command.
pwd
Present working directory. It will show you in which directory are you currently working on.

ls
List command. It will list the contents of the current directory. If no path is given it will list the
files in the current directory.
Syntax: ls path of the directory to be listed
mkdir
Make directory. It will create a new directory; the following shows the creation of a new
directory called my_linux.
Syntax: mkdir path of directory to be created
44
Lecturer notes -
Eng. Roble Mohamed Ali

Another example of creating a directory called abc, and listing the current directory to find the
abc.

You can see different colours for different names. By default the colours means:

White Files
Blue Folders
Green Executable
Pink Pictures
Red Zip folders
cd
Change directory. It is used to change the working directory.
Syntax: cd path of directory into which to be changed
Following shows the changing into and listing of the directory abc.

cat
Create a text. It can be used to create and edit a text file.
To create a text file
Syntax: cat > filename
To open a text file
Syntax: cat filename
The following shows a basic usage of cat command

cp

45
Lecturer notes -
Eng. Roble Mohamed Ali

Copy paste. It is used to copy files and folders


Syntax: cp source path destination path

In the above example a file calles new_text is copied into the same directory with a different
name new_text2.
mv
Move command. This command is used to cut paste a file or folder into any directory.
Syntax: mv source path destination path
The same command can be used to rename a file or directory by moving them into the same
directory with a different name.

In the above example the name of new_text2 is changed into new_text3.


rm
Remove command.
This command is used to remove a file or directory.
Syntax: rm path to be removed
An example of usage of rm command is shown below.

man
Manual of all commands. This command when used with a standard command, will shows you
the manual page of that command, which includes all the details about that particular command.
Syntax: man command
Example : man ls ( will show you how to use ls command )
man man ( will show you how to use the manual itself
A few important commands
Command Usage
adduser Command for creating a new user
apt-get Command for searching and installing software packages
bzip2 Command for compressing or decompressing files
46
Lecturer notes -
Eng. Roble Mohamed Ali

chmod Access permission of files can be changed using this command


clear Terminal can be cleared using this command
df Command for displaying free disk space
dmesg Command for printing kernel messages
echo To Display a string on the terminal
exit Exit the shell
find Search and find files
grep Files can be searched with patterns matching their contents
gzip Command for compressing a files
gunzip Command for decompressing a file
kill Command for stopping a process
killall Command for stopping a process by their name.
locate Another command for finding files
ls Command for listing contents of a directory
man Show the manual for a command
mkdir Command for making new directory
mount Use to mount a file system
mv Cut and paste or rename files or directories
open Command for opening a file in its default application
passwd Helps to modify a user password
poweroff Command for shut down the system
pwd Command for print the working directory
reboot Command for restarting the system
rm Use to remove files
rmdir Use to remove directories
uname Command for printing system information
useradd Helps to create a new user
vim Command for opening vim text editor
whoami Print the details of the current user

Terminal in Linux
Terminal is a TUI in GUI. It is actually a tool in the GUI for command line access. It is just like
command prompt in Windows.
To get terminal, just Right click > open in terminal or Accessories > Terminal

47
Lecturer notes -
Eng. Roble Mohamed Ali

Linux commands with examples


Obtaining User and System Information
Su to access administrator

who: Lists Users on the System

$ who or w
hostname : to dispay computer name

create new user :

adduser example : adduser roble

password user name

del-r username :to delete user for example : del-r roble

whoami : current user

$ who am i
alex pts/5 Mar 27 12:33

finger: Lists Users on the System

$ finge

Working with files


create, remove, copy and move files using commands like file, touch, rm, cp, mv and rename
touch
48
Lecturer notes -
Eng. Roble Mohamed Ali

One easy way to create a file is with touch


paul@laika:~/test$ touch file1
rm
use rm to remove it.

paul@laika:~/test$ rm BigBattle

rm rf (recursive force)

paul@laika:~$ rm -rf test

cp

To copy a file, use cp with a source and a target argument

paul@laika:~/test$ cp FileA FileB

cp multiple files to directory

cp file1 file2 dir1/file3 dir1/file55 dir2

cp source-file destination-file

The source-file is the name of the file that cp will copy. The destination-file is the

name that cp assigns to the resulting (new) copy of the file.

The cp command line in Figure 5-2 copies the file named memo to memo.copy. The

period is part of the filenamejust another character. The initial ls command shows

that memo is the only file in the directory. After the cp command, a second ls shows

two files in the directory, memo and memo.copy.

Filename completion

tip After you enter one or more letters of a filename (following a command) on a command line,
press

TAB and the Bourne Again Shell will complete as much of the filename as it can. When only one

filename starts with the characters you entered, the shell completes the filename and places a

SPACE after it. You can keep typing or you can press RETURN to execute the command at this
point.

When the characters you entered do not uniquely identify a filename, the shell completes what it

49
Lecturer notes -
Eng. Roble Mohamed Ali

can and waits for more input. When pressing TAB does not change the display, press TAB again
to

display a list of possible completions. For more information refer to Pathname Completion on

page 324.

$ ls

memo

$ cp memo memo.copy

$ ls

memo memo.copy

mv
Use mv to rename a file or to move the file to another directory.

paul@laika:~/test$ mv file100 ABC.txt

When you need to rename only one file then mv is the preferred command to use.

mv wolf.jpg wolf.pdf

practice: working with files


1. List the files in the /bin directory
2. Display the type of file of /bin/cat, /etc/passwd and /usr/bin/passwd.
3a. Download wolf.jpg and LinuxFun.pdf from http://linux-training.be (wget http://
linux-training.be/files/studentfiles/wolf.jpg and wget http://linux-training.be/files/
books/LinuxFun.pdf)
3b. Display the type of file of wolf.jpg and LinuxFun.pdf
3c. Rename wolf.jpg to wolf.pdf (use mv).
3d. Display the type of file of wolf.pdf and LinuxFun.pdf.
4. Create a directory ~/touched and enter it.
5. Create the files today.txt and yesterday.txt in touched.
6. Change the date on yesterday.txt to match yesterday's date.
7. Copy yesterday.txt to copy.yesterday.txt
8. Rename copy.yesterday.txt to kim
9. Create a directory called ~/testbackup and copy all files from ~/touched into it.
10. Use one command to remove the directory ~/testbackup and all files into it.
11. Create a directory ~/etcbackup and copy all *.conf files from /etc into it. Did you

solution: working with files


1. List the files in the /bin directory
ls /bin
2. Display the type of file of /bin/cat, /etc/passwd and /usr/bin/passwd.
50
Lecturer notes -
Eng. Roble Mohamed Ali

file /bin/cat /etc/passwd /usr/bin/passwd


3a. Download wolf.jpg and LinuxFun.pdf from http://linux-training.be (wget http://
linux-training.be/files/studentfiles/wolf.jpg and wget http://linux-training.be/files/
books/LinuxFun.pdf)
wget http://linux-training.be/files/studentfiles/wolf.jpg
wget http://linux-training.be/files/studentfiles/wolf.png
wget http://linux-training.be/files/books/LinuxFun.pdf
3b. Display the type of file of wolf.jpg and LinuxFun.pdf
file wolf.jpg LinuxFun.pdf
3c. Rename wolf.jpg to wolf.pdf (use mv).
mv wolf.jpg wolf.pdf
3d. Display the type of file of wolf.pdf and LinuxFun.pdf.
file wolf.pdf LinuxFun.pdf
4. Create a directory ~/touched and enter it.
mkdir ~/touched ; cd ~/touched
5. Create the files today.txt and yesterday.txt in touched.
touch today.txt yesterday.txt
6. Change the date on yesterday.txt to match yesterday's date.
touch -t 200810251405 yesterday.txt (substitute 20081025 with yesterday)
7. Copy yesterday.txt to copy.yesterday.txt
cp yesterday.txt copy.yesterday.txt
8. Rename copy.yesterday.txt to kim
mv copy.yesterday.txt kim
9. Create a directory called ~/testbackup and copy all files from ~/touched into it.
mkdir ~/testbackup ; cp -r ~/touched ~/testbackup/
10. Use one command to remove the directory ~/testbackup and all files into it.
rm -rf ~/testbackup
11. Create a directory ~/etcbackup and copy all *.conf files from /etc into it. Did you
include all subdirectories of /etc ?

cp -r /etc/*.conf ~/etcbackup
Only *.conf files that are directly in /etc/ are copied.

Working with file contents


In this chapter we will look at the contents of text files with head, tail, cat,
You can add content to a file as follows
login4$ cat > test.txt
head
You can use head to display the first ten lines of a file.
paul@laika:~$ head /etc/passwd

The head command can also display the first n lines of a file.
paul@laika:~$ head -4 /etc/passwd

51
Lecturer notes -
Eng. Roble Mohamed Ali

tail
Similar to head, the tail command will display the last ten lines of a file.
paul@laika:~$ tail /etc/services

cat
The cat command is one of the most universal tools.

paul@laika:~$ cat /etc/resolv.conf

create files
You can use cat to create flat text files. Type the cat > winter.txt command as shown

paul@laika:~/test$ cat > winter.txt

mv: Changes the Name of a File

mv existing-filename new-filename

$ ls
memo
$ mv memo memo.0130

lpr: Prints a File

$ lpr report

grep: Searches for a String

$ grep 'credit' memo


discussed the issue of credit.

sort: Displays a File in Order

$ cat days
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
$ sort days
Friday
Monday
Saturday
Sunday
Thursday
52
Lecturer notes -
Eng. Roble Mohamed Ali

Tuesday
Wednesday
Figure 5-6 sort displays the lines of a file in order

echo: Displays Text


The echo utility copies anything you put on the command line after echo to the
screen.

date: Displays the Time and Date


The date utility displays the current date and time:
$ date

Working with Compresses a File


bzip2

$ bzip2 -v letter_e

$ ls l

bunzip2 and bzcat: Decompress a File

$ bunzip2 letter_e.bz2

gzip:

The gzip (GNU zip) utility is older and less efficient than bzip2.

$ gunzip mak*

practice: file contents


1. Display the first 12 lines of /etc/services.
2. Display the last line of /etc/passwd.
3. Use cat to create a file named count.txt that looks like this:
One
Two
Three
Four
Five
4. Use cp to make a backup of this file to cnt.txt.
5. Use cat to make a backup of this file to catcnt.txt.
6. Display catcnt.txt, but with all lines in reverse order (the last line first).
7. Use more to display /var/log/messages.
8. Display the readable character strings from the /usr/bin/passwd command.
9. Use ls to find the biggest file in /etc.

53
Lecturer notes -
Eng. Roble Mohamed Ali

solution: file contents


1. Display the first 12 lines of /etc/services.
head -12 /etc/services
2. Display the last line of /etc/passwd.
tail -1 /etc/passwd
3. Use cat to create a file named count.txt that looks like this:
cat > count.txt
One
Two
Three
Four
Five (followed by Ctrl-d)
4. Use cp to make a backup of this file to cnt.txt.
cp count.txt cnt.txt
5. Use cat to make a backup of this file to catcnt.txt.
cat count.txt > catcnt.txt
6. Display catcnt.txt, but with all lines in reverse order (the last line first).
tac catcnt.txt
7. Use more to display /var/log/messages.
more /var/log/messages
8. Display the readable character strings from the /usr/bin/passwd command.
strings /usr/bin/passwd
9. Use ls to find the biggest file in /etc.
ls -lrS /etc
10. Open two terminal windows (or tabs) and make sure you are in the same directory
in both. Type echo this is the first line > tailing.txt in the first terminal, then issue
tail -f tailing.txt in the second terminal. Now go back to the first terminal and type
echo This is another line >> tailing.txt (note the double >>), verify that the tail -f
in the second terminal shows both lines. Stop the tail -f with Ctrl-C.
11. Use cat to create a file named tailing.txt that contains the contents of tailing.txt
followed by the contents of /etc/passwd.
cat /etc/passwd >> tailing.txt
12. Use cat to create a file named tailing.txt

Working with directories


To list the contents of a directory, use the ls command

login4$ ls

To see all files and directories, including hidden ones use the -a flag with the ls command.
Hidden files have a . in front of them

login4$ ls a

To print the name of the current/working directory, use the pwd command

54
Lecturer notes -
Eng. Roble Mohamed Ali

login4$ pwd

To make a new directory, use the mkdir command

login4$ mkdir ssc222

To change your working directory, use the cd command

login4$ cd ssc222

(The command above copies a file to the sub-directory junk)

login4$ cp test.txt ./junk/test2.txt

You can also use the rmdir command to remove an empty directory

login4$ rmdir junk2

cp -r

To copy complete directories,

paul@laika:~/test$ cp -r MyDir MyDirB

Use the man command to get more information about a command it is like using help in
Windows

login4$ man rmdir

cd/directory name to enter a folder

cd.. to previous folder

working with directory Access Permissions


ls l: Displays Permissions

$ ls -l student

chmod: Changes Access Permissions

$ chmod a+rw student

$ chmod o-rx student

Exercise -1

Run the following commands to make a directory:

login1$ mkdir ssc229


55
Lecturer notes -
Eng. Roble Mohamed Ali

login1$ cd ssc229

Run the following commands in the ssc229 directory

login1$ cp test.txt test2.txt

login1$ mkdir junk

login1$ mkdir junk2

login1$ cp test2.txt ./junk/test2.txt

login1$ cp test2.txt ./junk2/test2.txt

login1$ ls

Working with Computer devices


chkconfig list
df-h
free-mt

Working with Computer network

finger: Displays Information About Remote Users

kudos]$ finger @bravo

telnet: Logs In on a Remote System

[bravo]$ telnet kudos

ping: Tests a Network Connection

$ ping roble computer

If config

56
Lecturer notes -
Eng. Roble Mohamed Ali

57