You are on page 1of 22

Introduction to Linux

Linux
Basic Commands
Linux Introduction
• Linux is a computer operating system.
– free software (open-source)
– source code is available to the public
• freely use
• Modify
• redistribute it.

• Primarily developed and used by individual enthusiasts.

• Since then, Linux has gained the support of major corporations such as IBM, Hewlett-
Packard, and Novell for use in servers and is gaining popularity in the desktop
market.

• Originally developed for Intel 386 microprocessors. Now


– embedded systems
– personal computers
– supercomputers.

2
What is Linux?
• Free i.e. free of charge, freedom to use Linux, and free Software applications, programming
languages, and development tools etc.
• Unix Like: i.e. Like Unix, Linux runs on different hardware platform; e.g. Intel x86 processor
(Celeron/PII/PIII/PIV/Old-Pentiums/80386/80486)
– Macintosh PC's, Cyrix processor, AMD processor, Sun Microsystems Sparc processor, Alpha
Processor (Compaq)
– Like Unix its also Multi-user/Multitasking/32 or 64 bit Network OS.
• Open Source Linux is developed under the GNU Public License – referred to as “copyleft”
(not a copyright)
• Different vendors and volunteer developers share source code and build on each other’s
work.
• The source code is available, freely modifiable, developed, and so forth.
• There are only a few restrictions on the use of the code.
– If you make changes to the programs, you have to make those changes available to
everyone.
• Network operating system it is Internetwork and Internet-aware

3
How to get Linux?

• Linux available for download over the net, this


is useful if your internet connection is fast.
• Another way is the installation from CD-ROM
which is fast/automatic.
• Various Linux distributions available.
Following are important Linux distributions.

4
Various Linux distribution

Linux distributions Website/Logo


Red Hat Linux: http://www.redhat.com/

SuSE Linux: http://www.suse.com/

Mandrake Linux: http://www.mandrakesoft.com/

Caldera Linux: http://www.calderasystems.com/

Debian GNU/Linux: http://www.debian.org/

Slackware Linux: http://www.slackware.com/


5
How to use Linux?

• use Linux :
– as Server Os
– as stand alone Os on your PC.

6
What is Kernel?

• Kernel is the core of Linux Os


(Operating System).
• It acts as an intermediary
between the computer
hardware and various
programs/application/shell.

7

What is X-Windows?
X-Windows is the most common graphical interface for Linux / Unix

8
What is Linux Shell/Console ?

• Shell is a command-line
interface to the kernel.
• It is a user program that
provide user interaction
i.e. traditional user
interface.
• Shell is a command
language interpreter that
executes commands read
from the standard input
device (keyboard) or from
a file.

9
How to use Shell ?

• From X Windows, click the right hand button


of the mouse.
• Choose: Open Terminal
• Type the shell command at the prompt…

10
What is a directory?
• Directory is group of files. It is used to
organize your data files and programs more
efficiently.
• It is divided into two types:
– Root directory (shown by / and have only one in
your system)
– Sub directory (other directory under root, can be
created and renamed by the user).

11
Linux File
System
Structure

12
Linux Basic Commands
• A way to “do things” in Linux / Unix
• Commands are typed at the command prompt / console
• In Linux / Unix, everything (including commands) is case-sensitive

[prompt]$ <command> <flags> <args>


[kpu01@localhost ~]$ls –l -a unix-tutorial

Comman (Optional) arguments


Command Prompt
d (Optional) flags
Note: You’re expected to know what you’re doing. Many
commands will print a message only if something went wrong.

13
The Shell prompts
• Usually the prompts defined as:
– Username
– Host name (machine name)
– Name of the directory
• Example:
[kpu01@localhost ~]$
The Command Prompt

14
File Handling commands
• mkdir – make directories
 Usage: mkdir [OPTION] DIRECTORY...
 eg. mkdir csc1100
• ls – Display a listing of all the files in the current directory (called “folders”
in other OS)
 Usage: ls [OPTION]... [FILE]...
 eg. ls, or ls -al, or ls csc1100
 The l option means to give a listing in one column.
 The a option means to show all files.
• cd – changes directories
 Usage: cd [DIRECTORY]
 eg. cd csc1100
• cp – used to copy the files
– cp File1 dir-name/new-filename
Linux Introduction

• Most commands have many


options
• ls –la List all files, long
format
• File names starting in dot are
normally hidden
• Permissions are; Read, Write,
eXecute
• Columns are owner, group,
and all

16
File Handling commands
• pwd print name of current working directory
Usage: pwd
• ps – report a snapshot of the current processes
 Usage: ps [OPTION]
 eg. ps, ps el
• cat – concatenate files and print on the standard output
 Usage: cat [OPTION] [FILE]...
 eg. cat file1.txt file2.txt
• locate – find or locate a file
 Usage: locate [OPTION]... FILE...
 eg. locate file1.txt
File Handling(contd...)
• rm – remove files or directories
 Usage: rm [OPTION]... FILE...
 eg. rm file1.txt , rm rf some_dir
• find – search for files in a directory hierarchy
 Usage: find [OPTION] [path] [pattern]
 eg. find file1.txt, find name file1.txt
• history – prints recently used commands
 Usage: history
•clear - clear the screen .
 Usage:clear
Editor commands
• kate – KDE Advanced Text Editor
 Usage: kate [options][file(s)]
 eg. kate file1.txt file2.txt
• vim – Vi Improved, a programmers text editor
 Usage: vim [OPTION] [file]...
 e.g. vi hello.c e.g. vim file1.txt

• gedit – A text Editor. Used to create and edit files.


 Usage: gedit [OPTION] [FILE]...
 eg. gedit
Example
• To create a directory named test1
[kpu01@localhost ~]$mkdir test1
• To move to that directory
• [kpu01@localhost ~]$cd test1

• To move up one directory level (the parent


directory).
[kpu01@localhost ~]$cd ..
• To copy the file named contoh1.txt in
directory home into directory test1 and give a
new name test2.cpp
$cp contoh1.txt test1/test2.cpp
Sources to learn commands??
• Primary – man(manual) pages.
man <command> shows all information about the
command
<command> help - shows the available options for
that command
• Secondary – Books and Internet
Self test

1. Write a shell command to display all the files


and directories in the current directory.
2. Write a shell command to display a long list
of all files and directories in the current
directory.

You might also like