0% found this document useful (0 votes)
27 views60 pages

Basic Linux Commands

Uploaded by

doremonsuzuki7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views60 pages

Basic Linux Commands

Uploaded by

doremonsuzuki7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 60

Linux Systems

Linux Systems
Introduction - Let us ponder

• What exactly is an Operating System (OS)?


• Why do we need OS?
• How would the OS would look like?
• Is it possible for a team of us (in the room) to create an
OS of our own?
• Is it necessary to have an OS running in a Embedded
System?
• Will the 05 ever stop at all?
Linux Systems
Introduction - Operating System
Linux
Systems
Introduction - What is Linux?

• Linux is a free and open source operating system that is


causing a revolution in the computer world
• Originally created by Linus Torvalds with the assistance of
developers called community
• This operating system in only a few short years
is beginning to dominate markets worldwide
• Today right from hand-held devices (ex: Android) to
high end systems (ex: Stock exchange servers) use
Linux
Linux Systems

Introduction - Why use Linux?

• Free Et Open Source -GPL license, no cost


• Reliability -Build systems with 99.9996 upstream
• Secure -Monolithic kernel offering high security
• Scalability -From mobile phone to stock market servers
Linux Systems

Introduction - What is Open


Source?
Linux
Systems
Introduction - Open Source-How it all started7

• With GNU (GNU is not UNIX)


• Richard Stallman made the initial announcement in 1983, Free
Software Foundation (FSF) got formed during 1984
• Volunteer driven GNU started developing multiple projects,
but making it as an operating system was always a challenge
• During 1991 a Finnish Engineer LJnus Torvalds developed core OS
functionality, called it as “Linux Kernel”
• Linux Kernel got licensed under GPL, which laid strong
platform for the success of Open Source
• Rest \s history!
Linux
Systems
Introduction - Open Source How it evolved?
• Multiple Linux distributions started emerging around the Kernel
• Some applications became platform Independent
• Community driven software development started picking up
• Initially seen as a "geek-phenomenon”, eventually turned out to be an
engineering marvel
° Centered around Internet
° Building a business around open source started becoming viable
° Redhat set the initial trend in the OS business ;
Linux Systems
Introduction - Open Source - Where it stands now’

WIK
I

Comum eCommer
er ce
ñ•”,•• .c..

.a...n. vas

LibreOffic
e
Linux Systems
Introduction - Open Source vs Freeware

OSS Freeware

“ Users have the right to access & Freeware is usually distributed in a


form of binary at 'Free of Charge', but
itself.
“ does not open source codes
“ Developer of freeware could abandon
modify the source codes
development at any EimP and then
“ In case original programmer final version will be the last version
disappeared, users & developer of the freeware. No
group of the S/W usually keep its enhancements will be made by others.
support to the SM. Possibility of changing its licensing
“ OSS usually has the strong users b
developers group that manage and
maintain the project
Linux Systems

Introduction - GPL
Basic right under the GPL- access to source code ,right to make
derivative works
• Reciprocity/Copy-left
• Purpose is to increase amount of publicly
available software and ensure compatibility
• Licensees have right to modify, use or
distribute software, and to access the source code
Linux
Systems
Introduction - GPL - Issues
• Linking to GPL programs
• No explicit patent grant
• Does no discuss trademark rights
• Does not discuss duration
• Silent on sub-licensing
• Relies exclusively on license law, not contract
Linux Systems
Introduction - Linux Properties
What has made Linux so popular to scale from mobile devices to powering 901
of world's super computer? Here are the key properties of Linux
• Multitasking:
—Ability to handle muttipte tasks across single/multiple
processors
• Multi-user
Have got users vritfi different level of privileges for secured
access
• Protected Memory
—Clear distinction called 'user-space' and 'kernel' space
thereby having protected
memory access. Th s makes Linux Super secure comparing
with other operating systems
• Hierarchical File System
Well organized file system that handles various types of files. This also
makes handling various inputs very simple
Linux Systems
Introduction - Linux
° Hardware Controllers: This subsystem is
Components comprised of all the possible physical
devices in a Linux installation - CPU,
memory hardware, hard disks
° Linux Kernel: The kernel abstracts and
mediates access to the hardware
resources, Including the CPU. A kernel is the
core of thB D mating system
• O/S Services: These are services that are
typically considered part of the operating
system (e.g. Endowing system, command
shell)
• User App\1cations: The set of applications in
use on a particular Linux system (e.g. web
browserj
Linux Systems
Introduction - Linux Directory Structure
Essential user command binaries
Static boot-able images
Device files
- Host specific configuration
User home directories
' Essential shared libraries and kernel modules
Mount point for removable media
Mount point for temporarily mounted file systems
Virtual FS documenting kernel and process status
Root user's home directory
Essential super user command binaries
Add-on application software packages

’ Variable files
Temporary (Logs)
files
Mufti user utilities and application
Linux Systems
User Interface - GUI

• In graphical mode the user will be given a GUI using which he / she will
be able to use the system using mouse
• Similar to windows based system that exist n other operating systems
like MS Windows Et Apple MAC OS
Linux Systems
User Interface - CLI
• Textual mode used to execute requested commands
Linux Systems

User Interface - The Shell-Introduction


• Shell 1s an application, works as a command Interpreter
• Gets a command from user, gets it executed from OS
• Gives a programming environment to write scripts using
interpreted language
• It has been inherited from UNIX operating system, which was
predecessor to Linux
Linux Systems

User Interface - The Shell - Types

• Login
- Starts after a successful login
- It is executed under user ID during login process
- It picks up user specific configuration and loads them
Linux Systems

User Interface - The Shell - Types


• Non Login
- A Non login shell is started by a program without a login
—In this case, the program just passes the name of the shell
executable
—For example, for a Bash shell it will be simply bash
- Following are examples of Non-login shells:
• sh
• bash
• ksh
• csh
Linux Systems
User Interface - The Shell Invocation
• The main task of a shell is providing a user environment
Linux Systems
User Interface - The Shell Bash
• Bash - The command interpreter
• GNU Project's shell
• Bash is the Bourne Again Shell
• Some features of bash are
• Command line editing
• Unlimited size command history
• Job Control
• Shell Functions and Aliases
• Indexed arrays of unlimited size
• Integer arithmetic in any base from two to sixty-four
Linux Systems

Basic Shell Commands - Points to be Noted


• It is assumed you follow the slides sequence, since some of

the commands explained assumes, you have executed them


before trying the next one

• After typing the command its expected you press an


enter key
Linux Systems

Basic Shelf Commands - pwd


• As soon as we open an terminal we are taken to the users
home directory
• This can be known with the pwd command

• Basically, the pwd command tells you about current


working directory
Linux Systems
Basic Shelf Commands - Is
• Well, we come to know where we are, how do we know
what do we have there?

• The fist command Is helps us here. The ls display the


contents of the current directory.
• Well one question should pop up about the category of these
files?
• From the above image, can tell which is a directory, file
etc..?
Linux Systems
Basic Shelf Commands - man
• So how do we come to know about different listing
options?

• You may use man command, which stands for manual


• The most useful command which acts as reference
manual if you work in Linux system
• Almost all the installed applications, libraries and all
would have its own manual entry
• Even man has its own man page!

• This helps us to know how read man pages and different


sections in it
Linux
Systems
Basic Shelf Commands - man
• Hey, what? It looks too complex!!
• Well, yes as starter most of the things looks complex, that
too a technical documentation
• Habit of reading it would certainly make it easy.
Linux
Systems
Basic Shelf Commands - man
• So from man page of Is we get the following option

• Wher
e
Linux Systems
Basic ShelLCommands - Anatomy of a Command
Linux Systems

Basic Shell Commands - Types of commands


• An executable program like all those files can have in
/usr/bin.
• A command built into the shell itself. bash provides a number
of commands internally called shell built-ins The cd command,
for example, is a shell built-in
• A shell func tion. These are miniature shell scripts
incorporated into the environment.
• An alias. Commands that you can define yourselves, built from
other commands.
Linux Systems
Basic Shelf Commands - Types of commands
• To know the type of a command, you may try the
following

• Few examples
Linux
Systems
Basic Shelf Commands - cd
• cd to change directory. A shell built-in command

• The above example changes the directory to Documents


• Now how to go back?!
• We need to understand the concept of the path, which is
explained in the next slide
Linux Systems

Basic Shelf Commands - Path


• Path is the location where a particular file is located in
the directory (tree) structure
• It starts with the root (‘/’) directory and goes into
appropriate directory
• The path depends on the reference point from where you
take it up:
— Absolute Path: Specifies the location with reference from
root directory
- Relative Path: Specifies the location with reference to
present working directory (pwd)
• As the name says relative path will vary depending on your
present working directory
Linux Systems
Basic Shelf Commands - Path

.
Linux Systems

Basic Shell Commands - PathRelative


Linux Systems
Basic Shelf Commands - Relative
Path

«
Linux Systems
Basic Shelf Commands - Path - Absoulte

.
Linux Systems
Basic Shell Commands - mkdir
• mkdir to create directories

• Creates the directory(ies), if they do not already exists

• Well, # reoresents start of comment in shell, anything


written after that would be seen as comment!
Linux Systems
Basic Shell Commands - rmdir
• rmdir to remove empty directories

• Removes the directory(ies), if they are empty


Linux
Systems
Basic Shell Commands - rm
• The previous slide leads to a question on how to delete a
non empty directory?
• rm to remove files or directories
• Removes each specified file. By default, it does not
remove directories.

• Then how??, Well we need to refer the man pages


Linux
Systems
Basic Shell Commands - rm
• From the man page or rm you find a option -r which
stands for recursive

• Note, once deleted, you loose the files permanently!, its


equivalent to Shift + Delete
• Now what if you delete a file or a folder mistakenly?
Wouldn't you like that the shell ask you before you
delete? So that you avoid these types of issues!
• Well will see it in the next slide
Linux Systems
Basic Shell Commands - rm
• The -i option provides interactivity

• Did you observe from the above screen shot that the shell
prompts before you take any action!, you may say y or n
• There is always a second chance
• But what if you forget -i?
Linux
Systems
Basic Shell Commands - alias
• The solution the question in the previous slide is alias
• An builtin bash command, which helps us to name an
operation (command), literally anything
• Some built aliases are as shown below

• List varies based on your system installation


• Well how do we create one? How does it solve our issue?
Linux
Systems
Basic Shell Commands - alias
• We may create our own alias with required options as
shown below

• Note our alias at the end


• A new command (operation) named rm 1s created, when used
henceforth will be rm -i
Linux
Systems
Basic Shell Commands - alias
• Lets repeat all the steps again to test our new command

• Observe that, this time we didn't provide the -i option!


• How does it work?, its the because of our alias we
created.
• The name of new command can be anything, but let it be
meaningful
Linux
Systems
Basic Shell Commands - alias
• The only issue of the new command is that, it is only
available on the terminal it is created??
• As soon as we close the terminal its all gone!!. So what is the
point. How do we make it permanent??
• For that we need to about some of the files used by Bash
Linux Systems
Basic Shell Commands - Bash Files
• Hidden files used by the login as well as non-login shells
• Found in users home directory

• These are some configuration files which gets sourced to


bash on every new instance is created
Linux
Systems
Basic Shell Commands - Bash Files.bash_prof1fe
• Used by the login shell

• Any action which is to be carried out while logging in


through login shell can be put here
• Found in the users home directory, if not could be
created
Linux
Systems
Basic Shell Commands - Bash Files .bash_logout
• Any action which is to be carried out while logging out
through login shell can be put here
• Found in the users home directory
Linux
Systems
Basic Shell Commands - Bash Files.bashrc
• Used by the non login shell
• Any action which is to be carried after you logged into your
machine and open a new terminal window
• This is executed on every new instance of the new
terminal even if it is in a form of tabs
• So all those the stuff you would like to get sourced the bash
while starting, then this would be right file
Linux Systems

Basic Shell Commands - Bash Files.bash_history


• A file which store all the user activity on the command
prompt for future reference.
• The history command shows the entries of this file
Linux Systems
Basic Shelf Commands - touch
• An command which helps us to update the timestamp of
the existing files
• If the file argument that does not exist is created empty

• Observe that the directory was empty, using touch command It created
the mentioned files
• As mentioned it is generally used to update the time stamp, so you
wonder what would be the use of it?
• Well, they are used by some advanced commands like make
Linux Systems
Basic Shell Commands - touch
• The scope of this topic is to create some empty files which
wilt help learning some of the commands we are going cover
next slides
• But lets see the behavior of the command a bit

• Note the creation time of all the files


Linux
Systems
Basic Shell Commands - cp
• cp to copy files and directory
• Accepts to 2 arguments as the source and destiny

• The source and destiny are the path of files to be copied from
and to
Linux Systems
Basic Shell Commands - cp
• While copying the directory the -r option has to be used
Linux
Systems
Basic Shell Commands - mv
• mv to move of rename files and directories
• Accepts to 2 arguments as the source and destiny

• The source and destiny are the path of files to be moved or


renamed from and to

• Note the above context, the file gets moved


Linux Systems
Basìc Shell Commands - mv

• In this context, the file gets renamed

You might also like