You are on page 1of 30

_Change_Document_Information“ macro.

An Introduction to Linux

-Abhishek Chinnan

Last updated: December 8, 2021 at 08:00


For internal use
Unique document identifier (ID) / Version number / Life cycle status
1 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

What is Linux

Linux refers to the family of Unix-like computer operating systems using


the Linux kernel. Linux can be installed on a wide variety of computer
hardware, ranging from mobile phones, tablet computers and video game
consoles, to mainframes and supercomputers. Linux is a leading server
operating system, and runs the 10 fastest supercomputers in the world.
• The development of Linux is one of the most prominent examples of free and open source software collaboration

• Linus Torvalds is the Father of Linux

• Linux Availability and Portability is the reason it is widely adopted

• When installing Linux on a PC only “Kernel” is copied and rest all applications are installed on an individual machine.

• Linux is a derivative of Unix and is Open Source Software.

• Open Source Software means the it permits the users to change and improve the Software and to redistribute the modified and
ummodified forms.

• And its Significant because of the growing popularity and its freely Available.

• Compilers Like C, C++, Fortran


• Network Tools Like telnet, ftp, ping, traceroute
Multi-user, Multitasking, Multiprocessor
Coexists with other Operating Systems

Runs on multiple platforms

Includes the Source Code

For internal use


Unique document identifier (ID) / Version number / Life cycle status
2 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Where did it come from?

Linus Torvalds created it


• with assistance from programmers around the world
• first posted on Internet in 1991
Linux 1.0 in 1994; 2.2 in 1999
Today used on 7-10 million computers
• with 1000’s of programmers working to enhance it

For internal use


Unique document identifier (ID) / Version number / Life cycle status
3 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Open Source Software

 When programmers on the Internet can read, redistribute, and modify the
source for a piece of software.
 People improve it, people adapt it, people fix bugs. And this can happen
at a speed that, compared to conventional software development.

Kernel
The kernel is a program that constitutes the central core of a computer operating
system. It has complete control over everything that occurs in the system.

A kernel can be constrasted or communicates with a shell (such as bash, csh or ksh
in Unix-like operating systems), which is the outermost part of an operating system
and a program that interacts with user commands. The kernel itself does not interact
directly with the user, but rather interacts with the shell and other programs as well as
with the hardware devices on the system, including the processor.

For internal use


Unique document identifier (ID) / Version number / Life cycle status
4 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Why is it significant?

Growing popularity
Powerful
• Runs on multiple hardware platforms
• Users like its speed and stability
• No requirement for latest hardware
It’s “free”
• Licensed under GPL
• Vendors are distributors who package Linux
• Fedora

For internal use


Unique document identifier (ID) / Version number / Life cycle status
5 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

The Linux System

User commands includes executable


programs and scripts

The shell interprets user commands. It is User commands


responsible for finding the commands
and starting their execution. Several Shell
different shells are available. Bash is
popular, Kernel File Systems

Device Drivers

The kernel manages the hardware resources Hardware


for the rest of the system.

For internal use


Unique document identifier (ID) / Version number / Life cycle status
6 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Boot Loader

 In order for the BIOS to load an OS it looks for instructions on the first
sector of a hard drive.

 On the first sector of the hard drive resides the master boot record (MBR),
and is where a boot loader is initialized.

 Depending on the boot loader, additional files may be stored and read from
a partition on the hard drive.

 After this step the boot loader begins to start the operating system, and is
not used again until the next boot.

For internal use


Unique document identifier (ID) / Version number / Life cycle status
7 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Shells

 A shell provides an interface between the user and the operating system kernel.

 Either a command interpreter or a graphical user interface.

 Usually started automatically when you log in or open a terminal.

- The Bash Shell


Linux’s most popular command interpreter is called bash
 The Bourne-Again Shell
 Can be run as sh, as a replacement for the original Unix shell
 Gives you a prompt and waits for a command to be entered

- A shell is any program that takes input from the user, translates it into instructions that the
operating system can understand, and conveys the operating system's output back to the user.

For internal use


Unique document identifier (ID) / Version number / Life cycle status
8 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Partition Structure

/(root)
/home – All user’s home Directories are stored
/boot – All the Boot Files
/usr – All executable Files
/var – Databases of all services, entire shared information in
the directory
Swap – Virtual memory Management

For internal use


Unique document identifier (ID) / Version number / Life cycle status
9 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Command Options

Command options allow you to control a command to a certain degree


Conventions:
• Usually being with a single dash and are a single letter (“-l”)
• Sometimes have double dashes followed by a keyword (“--help”)
• Sometimes follow no pattern at all

For internal use


Unique document identifier (ID) / Version number / Life cycle status
10 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Common Commands

pwd - print (display) the working directory


cd <dir> - change the current working directory to dir
ls - list the files in the current working directory
ls -l - list the files in the current working directory in long format

For internal use


Unique document identifier (ID) / Version number / Life cycle status
11 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

More Commands

who
• List who is currently logged on to the system
whoami
• Report what user you are logged on as
ps
• List your processes on the system
ps aux
• List all the processes on the system

For internal use


Unique document identifier (ID) / Version number / Life cycle status
12 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

More Commands

grep - Searches files for one or more pattern arguments. It does plain
string, basic regular expression, and extended regular expression
searching

 grep has a few useful options: -


-i makes the matching case-insensitive
-r searches through files in specified directories, recursively
-l prints just the names of files which contain matching lines
-c prints the count of matches in each file
-n numbers the matching lines in the output

For internal use


Unique document identifier (ID) / Version number / Life cycle status
13 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Files and Directories

 A directory is a collection of files and/or other directories


- Because a directory can contain other directories, we get a directory
hierarchy
 The ‘top level’ of the hierarchy is the root directory
- The root directory is referred to as /
- Other directories are referred to by name, and their names are separated
by slashes (/

For internal use


Unique document identifier (ID) / Version number / Life cycle status
14 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Current Directory

 Your shell has a current directory — the directory in which you are
currently working
 Commands like ls use the current directory if none is specified
 Use the pwd (print working directory) command to see what your current
directory is:
$ pwd
/home/chinnan
 Use cd without specifying a path to get back to your home directory

For internal use


Unique document identifier (ID) / Version number / Life cycle status
15 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Making and Deleting Directories

 The mkdir command makes new, empty, directories


For example, to make a directory for storing company accounts:
$ mkdir Accounts
 To delete an empty directory, use rmdir:
$ rmdir OldAccounts
 Use rm with the -r (recursive) option to delete directories and all the files
they contain:
$ rm -r OldAccounts

For internal use


Unique document identifier (ID) / Version number / Life cycle status
16 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Creating a new user

Use the useradd abhishek


Use the passwd abhishek and set the Password and confirm
Try it… and logon as a new user

[root@localhost]# useradd abhishek


[root@localhost]# passwd abhishek
Changing password for user abhishek
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated
successfully
[root@localhost]#
For internal use
Unique document identifier (ID) / Version number / Life cycle status
17 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Users and Groups

Users are identified by user identifications (UIDs), each of which is associated with an
integer in the range of 0 to 4 294 967 295 (X’FFFFFFFF’). Users with UID=0 are given
superuser privileges.
Users are placed in groups, identified by group identifications (GIDs). Each GID is
associated with an integer in the range from 0 to 4 294 967 295
Let the system assign UID to avoid duplicates
Use id to display your user and group information

uid=500(neale) gid=500(neale) groups=500(neale),3(sys),4(adm)

For internal use


Unique document identifier (ID) / Version number / Life cycle status
18 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Using the new user

Now logoff using the exit command


login as the new user

Linux 2.2.13 (penguinvm.princeton.edu) (ttyp2)

penguinvm login: scully


Password:
[scully@penguinvm scully]$

For internal use


Unique document identifier (ID) / Version number / Life cycle status
19 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

File Permissions

 Having different types of permission, we can apply different sets of


permissions to different sets of people
 A file (or directory) has an owner and a group owner
 The r, w, x permissions are specified separately for the owner, for the
group owner, and for everyone else (the ‘world’)
 The ls -l command allows you to look at the permissions on a file:
e.g # ls -l
drwxr-x--- 9 root root 4096 Jan12 12:57 nokia
-rw-rw-r-- 1 root root 11170 Feb 9 14:11 test1
 One character for the file type: d for directories, - for plain files
 Three characters of rwx permissions for the owner (or a dash if the
permission isn’t available)
 Three characters of rwx permissions for the group owner
 Three characters of rwx permissions for everyone else
For internal use
Unique document identifier (ID) / Version number / Life cycle status
20 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Interpreting File Permissions

-rwxrwxrwx
Other permissions
Group permissions
Owner permissions
Directory flag (d=directory; l=link)

For internal use


Unique document identifier (ID) / Version number / Life cycle status
21 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

File Permissions

The long version of a file listing (ls -l) will display the file permissions:

-rwxrwxr-x 1 rvdheij rvdheij 5224 Dec 30 03:22 hello


-rw-rw-r-- 1 rvdheij rvdheij 221 Dec 30 03:59 hello.c
-rw-rw-r-- 1 rvdheij rvdheij 1514 Dec 30 03:59 hello.s
drwxrwxr-x 7 rvdheij rvdheij 1024 Dec 31 14:52 posixuft

Permissions Group

Owner
For internal use
Unique document identifier (ID) / Version number / Life cycle status
22 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Changing File and Directory Permissions: chmod

 The chmod command changes the permissions of a file or directory


 A file’s permissions may be changed only by its owner or by the
superuser
 Can be specified in many flexible (but correspondingly complex) ways
example
$chmod a+x new-program
adds (+) executable permission (x) for all users (a) on the file new-
program

For internal use


Unique document identifier (ID) / Version number / Life cycle status
23 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Changing File Permissions

Use the chmod command to change file permissions


• The permissions are encoded as an octal number

chmod 755 file # Owner=rwx Group=r-x Other=r-x


chmod 500 file2 # Owner=r-x Group=--- Other=---
chmod 644 file3 # Owner=rw- Group=r-- Other=r--

chmod +x file # Add execute permission to file for all


chmod o-r file # Remove read permission for others
chmod a+w file # Add write permission for everyone

For internal use


Unique document identifier (ID) / Version number / Life cycle status
24 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Create, Monitor, and Kill Processes

 The kernel considers each program running on your system to be a


process
 A process ‘lives’ as it executes, with a lifetime that may be short or long
 A process is said to ‘die’ when it terminates
 The kernel identifies each process by a number known as a process id,
or pid
 The kernel keeps track of various properties of each process

For internal use


Unique document identifier (ID) / Version number / Life cycle status
25 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Process Properties

 A process has a user id (uid) and a group id (gid) which together specify
what permissions it has
 A process has a parent process id (ppid) — the pid of the process which
created it
 The kernel starts an init process with pid 1 at boot-up
 Every other process is a descendant of pid 1
 Each process has its own working directory, initially inherited from its
parent process
 There is an environment for each process — a collection of named
environment variables

For internal use


Unique document identifier (ID) / Version number / Life cycle status
26 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Processes

Daemons
• Background processes for system administration are referred to as
“daemons”
• These processes are usually started during the boot process
• The processes are not assigned any terminals

UID PID PPID C STIME TTY TIME CMD


root 5 1 0 1999 ? 00:00:14 [kswapd]
bin 254 1 0 1999 ? 00:00:00 [portmap]
root 307 1 0 1999 ? 00:00:23 syslogd -m 0
root 350 1 0 1999 ? 00:00:34 httpd
For internal use
Unique document identifier (ID) / Version number / Life cycle status
27 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Processes - PID

PID
• A process ID is a unique identifier assigned to a process while it runs
• Each time you run a process, it has a different PID (it takes a long
time for a PID to be reused by the system)
• You can use the PID to track the status of a process with the ps
command or the jobs command, or to end a process with the kill
command

For internal use


Unique document identifier (ID) / Version number / Life cycle status
28 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

For internal use


Unique document identifier (ID) / Version number / Life cycle status
29 © Nokia Siemens Networks 2011 Dept. / Author / Date
_Change_Document_Information“ macro.

Processes - PPID

PPID
• A process that creates a new process is called a parent process; the new
process is called a child process
• The parent process (PPID) becomes associated with the new child
process when it is created
• The PPID is not used for job control

For internal use


Unique document identifier (ID) / Version number / Life cycle status
30 © Nokia Siemens Networks 2011 Dept. / Author / Date

You might also like