SDP Basic Ubuntu

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 33

Introduction to Ubuntu &

Basic Commands
Ms. Roopal Mamtora
(Asst. Prof. CE Dept)

Dt: 19 June 2017


First Half : Introduction
 What is Ubuntu

 Understanding Ubuntu structure

 Installing Ubuntu

19-06-2017 2
Second Half
 Basic Commands

 Understanding files & folders

 Understanding user and permission

 Opening a command shell / terminal

19-06-2017 3
Ubuntu Vs. Windows
 Linux is developed by Open Source Development whereas
Windows is developed by Microsoft.

 Linux is an open source whereas Windows source code is closed.

 Linux is written in C whereas Windows is written in Assembly ,


C ,C++

 Linux is virus free (less prone to get infected by viruses) , possibly


malware free, causes and costs no money whereas windows is
plaugued with viruses and malware and is expensive

 Ubuntu encourages users to choose official repositories as the main


source of software (which are safe)

19-06-2017 4
Ubuntu Vs. Windows
 Ubuntu has built-in security

 firewall rules, anti-virus scanners, network monitoring,


two-factor authentication, etc...

 Security teams come-out with updates to fix these


vulnerabilities regularly.

 Ubuntu has it's own security team that releases


updates and advices for systems administrators.

19-06-2017 5
Ubuntu
 Linux is a Operating System.

 Linux is not Unix.

 Linux was written by Linus Trovald and was available


around 1991-1994.

 Specially for server systems / super computers.

 Linux is open source (Unix was not).


 Any body could see the source code and could modify it
according to their need (customize).

19-06-2017 6
Ubuntu
 Linux comes in many varieties/versions
which are called distributions :
 Ubuntu

 Fedora

 Mint

 Debian

 Most popular one is Ubuntu.


19-06-2017 7
Understanding Ubuntu Structure
 The standard Ubuntu directory structure mostly follows
the Filesystem Hierarchy Standard which organizes files
in a hierarchical tree.

 Directories can contain other directories as well


as regular files

 ‘/’ identifies the root directory, which contains all other


directories and files

 In every directory, there are two special directories


called . and .. , which refer respectively to the directory
itself, and to its parent directory.
19-06-2017 8
Understanding Ubuntu Structure

19-06-2017 9
Understanding Ubuntu Structure
 /bin: for terminal commands,like ls,mount,rm,etc.
 /boot : files required to boot (such as the kernel, etc)
 /dev : your devices (everything from drives to displays)
 /etc : just about every configuration file for your system.
 /home : locally stored user files and folders
 /lib : system libraries
 /media : intended as a mount point for external devices,
such as hard drives or removable media (floppies, CDs,
DVDs).
 /mnt :dedicated specifically to "temporarily mounted"
devices, such as network filesystems.

19-06-2017 10
Understanding Ubuntu Structure
 /opt :can be used to store additional software for your system
 /root :is the superuser's home directory
 /sbin :contains important administrative commands that should
generally only be employed by the superuser.
 /srv :for data directories of services such as HTTP (/srv/www/) or
FTP.
 /tmp :for temporary files used by applications.
 /usr :contains of user utilities and applications, and partly replicates
the root directory structure e.g: /usr/bin & /usr/lib.
 /var : mainly logs, databases, etc.
 it contains a notable directory : /var/log where system log files are kept

19-06-2017 11
Installing Ubuntu
 Go to the boot option by pressing F12.

 Select legacy boot as CD/DVD…

 If a system is to be made dual boot


 Select the option “something else”

 Select the free space option to install ubuntu.

 Select mount point as “/”

 Select the location fot time settings

 Select the language as english (US).

 Set the systemname & password which will be used during loggin.
19-06-2017 12
Installing additional packages
 Install the acl(access control link)
package:

 $sudo apt-get install acl

19-06-2017 13
MBR & different boot loaders
 BIOS needs someplace where it can load the initial boot program
that starts the process of loading the operating system.

 The place where this information is stored is called the master boot
record (MBR), also referred to as the master boot sector or even
just the boot sector .

 The master boot record is always located at cylinder 0, head 0, and


sector 1, the first sector on the disk.

 This is the consistent starting point that the disk will always use.

 When a computer starts and the BIOS boots the machine, it will
always look at this first sector for instructions and information on
how to proceed with the boot process and load the operating
system.
19-06-2017 14
Boot Process
 Pressing the power button  Login screen

19-06-2017 15
Boot Process
 BIOS(Basic Input/Output System):
 Performs some system integrity checks
 Searches(floppy/cd-rom/hard drive), loads(memory),
and executes the boot loader program loads and
executes the MBR boot loader.

 MBR(Master Boot Record):


 It is located in the 1st sector of the bootable disk & is
less than 512 bytes in size
 contains information about GRUB loads and executes
the GRUB boot loader.

19-06-2017 16
Boot Process
 GRUB(Grand Unified Bootloader):
 loads the default kernel image as specified in the
configuration fileloads and executes Kernel and
initrd(Initial RAM Disk) images.

 Kernel:
 Mounts the root file system as specified in the “root=” in
grub.conf
 Kernel executes the /sbin/init program
 initrd is used by kernel as temporary root file system
untill the real file system is up.

19-06-2017 17
Boot Process
 Init:
 Looks at the /etc/inittab file to decide the Linux
run level.
 Following are the available run levels
 0 – halt
 1 – Single user mode

 2 – Multiuser, without NFS

 3 – Full multiuser mode (default)

 4 – unused

 5 – X11 (default)

 6 – reboot

19-06-2017 18
Boot Process
 Runlevel program:
 Depending on your default init level setting, the system
will execute the programs from one of the following
directories.
 Run level 0 – /etc/rc.d/rc0.d/
 Run level 1 – /etc/rc.d/rc1.d/
 Run level 2 – /etc/rc.d/rc2.d/
 Run level 3 – /etc/rc.d/rc3.d/
 Run level 4 – /etc/rc.d/rc4.d/
 Run level 5 – /etc/rc.d/rc5.d/
 Run level 6 – /etc/rc.d/rc6.d/
 Under the /etc/rc.d/rc*.d/ directories, you would see
programs that start with S-startup(used during startup)
and K-kill(used during shutdown).
19-06-2017 19
Basic Commands
 Sudo:SuperUserDo
 It is used before each command that requires root permissions
 $ sudo su

 ls (list):
 shows all the files and folders of the directory that you're working in.
 ls [-l/-a/-R]
 -l:List file with permission
 -a:list with hidden files
 -R:List directories , sub directories

 man (manual):
 used to display helpful information about commands
 Man [-k]
 -k : search by command description rather than command name
 $ man cp
19-06-2017 20
Basic Commands
 cd (Changing directory):
 type the name of the folder you want to go in from your current
directory
 to go up the hierarchy just do it by giving double dots (..) as
the parameter.
 /home $ cd usr  /home/usr $
 cd .. -->To a directory one level up (parent directory)
 cd - -->To your previous working directory
 cd / -->To the / (root) directory

 mkdir (make directory):


 to create a new folder or subfolder.
 $ mkdir folderName
19-06-2017 21
Basic Commands
 cp (copy):
 Used to copy-and-paste the file from source to destination
 $ cp src des
 siesgst@kau44:~$ cd guest
 siesgst@kau44:~/guest$ cat >> abc.txt
 Hi!! Hw are u??
 siesgst@kau44:~/guest$ cd ..
 siesgst@kau44:~$ cp guest/abc.txt new/
 It is used to organize files .

 rm (remove file) / rmdir (remove directory):


 Used to remove your file or even your directory
 $ rm myfile.txt
 $ rmdir dir1
 rm [-f / -r]
 -f: if the file need root permission to be removed.
 -r :to do recursive removal to remove your folder
19-06-2017 22
Basic Commands
 mv (move):
 used to move files from one folder to another and rename files
and directories .
 mv src dest
 $mv file1 file2 (file1 is renamed to file2)

 apt-get :
 This command differs distro-by-distro.
 In Debian based Linux distributions, to install, remove and
upgrade any package we've Advanced Packaging Tool (APT)
package manager .
 Fedora used to have yum but now it has dnf.
 $sudo apt-get update
 $ sudo dnf update
19-06-2017 23
Basic Commands
 grep:
 to help finding the file based on given keywords.
 $ grep user /etc/passwd

 Cat:
 View the text inside the file ($ cat file1 )
 Create a file ($ cat > file1 )
 Append text to a file ($ cat >> file1 )

 pwd (Present Working Directory)


 displays the full pathname of the current directory
 guest-aURPab@siesgst-OptiPlex-380:~$ pwd
 /tmp/guest-aURPab
19-06-2017 24
Basic Commands (File Permission)
 There are 3 tasks that can be performed:
 r (read) : for read access.

 w (write) : for write/edit access.

 x (execute):for execution as program.

 There are 3 classes to whom we can grant permissions:


 u (user) :owner of a file

 g (group) :group to which the file belongs

 o (other) all others

19-06-2017 25
Basic Commands (File Permission)
 For example ,if we want to give the following permissions to a file:

 chmod :used to change/modify the permissions of a file.


 chmod u+rwx g+rx o+r filename/directoryname
 OR
 chmod 754 filename/directoryname

19-06-2017 26
Basic Commands (File Permission)
 One can also remove certain permissions:
 Remove group read permission of a file
 $ chmod g-r filename

 The default permission of a newly created file in our home will be


664 (-rw-rw-r--).

 We are only allowed to change permissions, groups or ownership of


a file that is our's.

 Only root can change permissions for all files.

 This is why we have to use sudo when editing permission of files


that are not our's

19-06-2017 27
Basic Commands (File Permission)

 Chown (changeowner):To change a file


ownership.

 Chgrp (changegroup):To change a file's


group

 $sudo chown owner1 owner2


 $sudo chgrp owner1 owner2

19-06-2017 28
Basic Commands (File Permission)
 Sticky Bits:
 The sticky bit applies only to directories, and is typically
used on publicly-writeable directories.

 Within a directory upon which the sticky bit is applied,


users are prevented from deleting or renaming any files
that they do not personally own.

 To add or remove the sticky bit, use chmod with the "t"
flag:
 chmod +t <directory>
 chmod -t <directory>

19-06-2017 29
Basic Commands (File Permission)
 Making a public directory
 $ mkdir folder
 $ chmod 777 folder
 $ ls -l
 Output :
 total 3
 drwxrwxrwx 2 user user ….

 Adding the sticky bit (note the "t" in the other execute field):
 $ chmod +t folder
 ls -l
 Output :
 total 3
 drwxrwxrwt 2 user user ….
19-06-2017 30
Basic Commands (Vi editor)
 Vi is a powerful text editor

 Vi is a terminal application, so you’ll have to start it from


a terminal window
 $vi /path/to/file

 Has following modes:


 Command mode
 select, copy, cut and paste text in command mode
 Move the cursor with arrow keys

 Insert mode
 allows you to insert text in Vi.
 press the i key to enter the insert mode
 press the escape key to return to command mode.
19-06-2017 31
Basic Commands (Vi editor)
 Saving & quitting:
 You can save and quit vi from command mode.

 Type :wq and press enter to write the file to disk and quit vi

 type :w and press enter to write the file to disk without quitting

 type :q to quit vi without saving the file.

 Vi won’t let you quit if you’ve modified the file since you last
saved, but you can type :q! and press enter to ignore this
warning.

19-06-2017 32
References
 https://askubuntu.com/questions/37198/why-arent-viruses-an-issue
 https://citricks.net/introduction-ubuntu-server-cli/
 https://freedompenguin.com/wp-content/uploads/2015/10/linux-filesy
stem.png
 https://help.ubuntu.com/community/LinuxFilesystemTreeOverview
 http://www.ubuntugeek.com/linux-or-ubuntu-directory-structure.html
 http://www.linuxandubuntu.com/home/10-basic-linux-commands-tha
t-every-linux-newbies-should-remember
 http://www.thegeekstuff.com/2011/02/linux-boot-process

19-06-2017 33

You might also like