SlideShare a Scribd company logo
1 of 86
Download to read offline
BASICS OF LINUX
SPEAKER
SAIF
CSE @ BMSCE
LinkedIn
Github
LINUX DISTRIBUTIONS
Linux is an Operating System
Linux OS = Linux Distribution
Distro/Flavor = Collection of applications bundled
together and distributed as one OS
Common -> Kernel
Kernel is the core/heart to the Linux System.
Linux kernel + Apps = Distro
Kernel sits between hardware and applications
OTHER COMPONENTS OTHER
THAN KERNEL
User interfaces
System libraries
GUI
Email utilities
POPULAR DISTROS
Redhat Enterprise Linux - popular in banks, airlines,
telecoms, healthcare license is required for
commercial use
CentOS (CentOS = RHEL - branding/logos)
Ubuntu - startups, SaaS, Social Networks, Cloud
Based
LINUX IS LINUX: YOU CAN'T MAKE
A "WRONG" CHOICE!
Linux concepts are universal.
Each distro is slightly different.
You can accomplish the same goals on most linux
distros.
GETTING CONNECTED
Log into the GUI
Log into the command line
Command to exit out of the linux terminal
$ exit
GETTING CONNECTED OVER THE
NETWORK
SSH
Windows PuTTY SSH Client
Mac - Terminal/SSH Command Line Utility Linux
commands are case-sensitive.
$ ssh user1@mylinux
$ ssh mylinux.example.com
$ ssh 192.168.1.12
COMMON LINUX DIRECTORIES
/ "Root", the top of the
file system hierarchy
/bin Binaries and other
executable programs
/etc System configuration
files
/home Home directories
/opt Optional or third
party software
/tmp temprary space,
typically cleared on
reboot
/usr User related programs
/var Variable data, most
notably log files
/boot Files needed to boot
the OS
/cdrom Mount point for CD-
ROMS
/cgroup Control Groups
hierarchy
/dev Device files,
typically controlled by
the OS and the system
administrators
/export Shared file
systems
/lib System libraries
/lib64 System Libraries,
64 bit
/lost+found Used by the
file system to store
recovered files after a
file system check has been
performed
/media Used to mount
removable media like CD-
ROMs
/mnt Used to mount
external file systems
/opt Optional or third
party software
/proc Provides info about
running processes
/root The home directory
for the root account
/sbin System
administration binaries
/selinux Used to display
information about SELinux
/srv Contains data which
is served by the system
/srv/www Webserver files
/srv/ftp FTP files
/sys used to display and
sometimes configured the
devices known to the Linux
kernel
/tmp Temporary space,
typically cleared on
reboot.
/usr/bin Binaries and
other executable programs
/usr/lib Libraries
/usr/local Locally
installed software that is
not part of the base
operating system
/usr/sbin System
administration binaries
/var/log Log files
/usr/local/crashplan/bin
/usr/local/crashplan/etc
/usr/local/crashplan/lib
/usr/local/crashplan/log
/opt/avg/bin
/opt/avg/etc
/opt/avg/lib
/opt/avg/log
/etc/opt/myapp
/opt/myapp/bin
/opt/myapp/lib
/var/opt/myapp
/usr/local/bin/myapp
/usr/local/etc/myapp.conf
/usr/local/lib/libmyapp.so
/opt/acme
/opt/acme/bin
/opt/acme/etc
/opt/google
/opt/google/chrome
/opt/google/earth
/opt/web-
team/opt/acme/web-team
/usr/local/acme/web-team
THE SHELL
Also called a command line interpreter(cli)
Shell is the default interface to linux
A program that accepts your commands and
executes those commands
CLI VS GUI
The command line is more powerful
There will always be a command line
Server distributions do not include GUIs
Desktop distributions have GUIs and CLIs
COMMAND LINE WEB BROWSERS
ELinks
Lynx
w3m
THE PROMPT
[saif@mylinux ~]$ <- normal
user
[root@mylinux: ~]# <- superuser
This root is a user and not a directory
ROOT, THE SUPERUSER
Root is all powerful
Normal accounts can only do a subset of the things
root can do
Root access is typically restricted to system
administrators
Root access may be required to install, start or stop
an application.
sudo su -
whoami
sudo su - user
saif@mylinux $
[saif@mylinux /tmp]$
mylinux:/home/saif>
saif@mylinux: ~>
[10:21:16 mylinux ~]$
$
%
>
MULTILINE PROMPT
mylinux:[/home/saif]
$
[Mon 15/07/18 05:12 EST]
[pts/0]
<saif@mylinux:~>
zsh 14 %
SHORTHAND FOR DIRECTORIES
Tilde ~ is the shorthand representation of the home
diretory of the current account
~saif = /home/saif
~bob = /home/bob
~root = /root
~ftp = /srv/ftp
BASIC LINUX COMMANDS
ls - Lists directory contents
cd - Changes the current directory
pwd - Displays the present working directory
cat - Concatenates and displays files
echo - Displays arguments to the screen
man - Displays the online manual
exit - Exits the shell or your current session
clear - clears the screen
ls is sometimes color-coded
ls -l
LS
Ls
lS
cd Foldername
cd foldername
cat sales-report.txt
echo $PATH
echo $OLDPWD
man ls
Spacebar: next page
q: quit
clear
cd
pwd
exit
NAVIGATING THROUGH THE FILE
SYSTEM
. This directory
.. The parent directory
cd - Change to previous directory
DIRECTORY SEPARATOR IN LINUX:
/ (forward slash)
GETTING HELP
--help
-h
gzip -h
man
How to navigate man pages?
Enter: Next line
Spacebar: Next page
g: Move to the top
G: Move to the bottom
q: Quit
SEARCHING MAN PAGES
man -k SEARCH-TERM man -k calendar
ENVIRONMENT VARIABLES
Storage location has a name and a value
Typically uppercase
To access the contents: echo $VAR_NAME
PATH - An environment variable
Controls the command search path
Contains a list of directories
echo $PATH
HOW DO I ADD ENVIRONMENT
VARIABLES?
To set variable only for current shell:
Edit /etc/Environment and add a newline
VARNAME="my value"
which command
which cat
which tac
cat file.txt
/bin/cat file.txt
mkdir Creates a directory
rmdir Removes an empty directory
rm -rf Recursively removes directories
Note- There is no recycle bin/undo option
DECODING LS -L OUTPUT
$ls -l
-rw-rw-r-- 1 saif users 11300 Sep 03
03:22 file.txt Permissions -rw-rw-r--
Number of links 1
Owner name saif
Group name users
Number of bytes in the file 11300
last modification time Sep 03 03:22
File name file.txt
ls -a to see hidden files
hidden files starts with a period ls -l -a
ls - la
ls -al
ls -F to reveal file types
/ Directory
@ Link
Exectutable
Symbolic Links
A link is a point to the actual file or directory.
Use the link as if it were the file
A link can be used to create a shortcut
Use for long file or directory names
Use to indicate the current version of software
ls -t list files by time
ls -r reverse order
ls -latr long listing including all files reverse
sorted by time
WORKING WITH SPACES IN
NAMES
Alternatives:
hyphens -
underscores _
CamelCase
Encapsulate the entire filename in quotes single or
double
Use backslash  to escape spaces
FILE AND DIRECTORY
PERMISSIONS
Symbol type
- : Regular file
d : Directory
l : Symbolic link
r : Read (cat)
w : Write (modify/change)
x : Execute (run as program)
-rw-rw-r-- 1 saif users 11300 Sep 03 03:22 file.txt
read
file - allows a file to be read
direcory - allows filenames in the directory to be read
write
file - allows a file to modified
directory - allows entries to be modified within the
directory
execute
file -allows the execution of a file
directory - allows access to contents and metadata for
entries
The character in the first position, a dash (-), indicates
that this is a file and not a directory. Directories are
marked with a d, as in drwxr-x---
- rw- r-- r--
user, group, other
Permissions = Modes
PERMISSION CATEGORIES
u : User (owner)
g : Group
o : Other
a : All
GROUPS
Every user is in atleast one group
Users can belong to many groups
Groups are used to organize users
The groups command displays a user's groups
You can also use id -Gn
chgrp newgroup myfile
groups
groups saif
groups user
groups saif user
chmod: change mode command
ugoa: User category: user, group, other, all
+-=: Add, subtract, or set permissions
rwx: Read, Write, Execute
chmod g+w file.txt
chmod g-w file.txt
chmod g+wx file.txt
chmod u+rwx, g-x file.txt
chmod a=r file.txt
chmod u=rwx, g=rx, o= file.txt
| r | w | x |
| 0 | 0 | 0 |
| 1 | 1 | 1 |
| 4 | 2 | 1 |
| Octal | Binary | String | Description |
| 0 | 0 | --- | No permissions |
| 1 | 1 | --x | Execute only |
| 2 | 10 | -w- | write only |
| 3 | 11 | -wx | write and execute |
| 4 | 100 | r-- | read only |
| 5 | 101 | r-x | read and execute |
| 6 | 110 | rw- | read and write |
| 7 | 111 | rwx | read, write and execute |
U G O
Symbolic rwx r-x r--
Binary 111 101 100
Decimal 7 5 4
Symbolic Octal
-rwx------ 700
-rwxr-xr-x 755
-rw-rw-r-- 664
-rw-rw---- 660
-rw-r--r-- 644
FILE CREATION MASK
File creation mask determines default permissions
If no mask were used permissions would be
777 for directories
666 for files
THE UMASK COMMAND
umask [-S] [mode]
S = symbolic notation
Sets the file creation mask to mode, if given.
Use -S to for symbolic notation.
directory file
Base Permissions 777 666
Subtract Umask -022 -022
Creations Permission 755 644
SEARCHING FOR FILES AND
DIRECTORIES
Recursively finds files in path that match expression. If
no arguments are supplied it will find all files in the
current directory.
find [path...] [expression]
-name patttern
Find files and directories that match pattern
-iname pattern
Like -name, but ignores case
-mtime days Finds file that are days old
-size num Finds file that are of size num
-newer file Finds files that are newer than file
-ls Performs an ls on each of the found items
-exec command {} ;
Run command against all the files that are found.
LOCATE
Lists files that match pattern
Faster than the find command
Queries an index
Results are not in real time
May not be enabled on all systems
COPYING, MOVING, RENAMING
rm file
removes directory and its contents recursively
force removal and never prompts for confirmation
rm -r dir
rm -f file
ls s*
rm s*
ls -d .*
rm .*
cp source destination
cp srcfile1 [srcfileN ...] dest_dir
cp -i Run in interactive mode
cp file1 file2
cp file1 file2 dir
cp -r source_directory destination
Copy src_directory recursively to
destination/destination direcory is created
mv dir firstdir
mv file1 file1.renamed
mv file1.renamed firstdir
mv file1 file2 //overwrites
mv -i file1.renamed file2
CREATING A COLLECTION OF
FILES
tar cf tps.tar tpsreports
tar tf tps.tar
cd /tmp
tar xf /home/saf/tps.tar
ls -l tps
CRONJOBS
To edit the crontab file:
crontab -e
This cron job will run every minute, all the time:
This cron job will run at minute zero, every hour (i.e. an
hourly cron job):
This is also an hourly cron job but run at minute 15
instead (i.e. 00:15, 01:15, 02:15 etc.):
This will run once a day, at 2:30am:
* * * * * [command]
0 * * * * [command]
15 * * * * [command]
30 2 * * * [command]
This will run once a month, on the second day of the
month at midnight (i.e. January 2nd 12:00am,
February 2nd 12:00am etc.):
This will run on Mondays, every hour (i.e. 24 times in
one day, but only on Mondays):
Dash can be used to specify a range. This will run once
every hour between 5:00am and 10:00am:
0 0 2 * * [command]
0 * * * 1 [command]
0 5-10 * * * [command]
Also there is a special keyword that will let you run a
cron job every time the server is rebooted:
@reboot [command]
THANK YOU

More Related Content

What's hot

Linux presentation
Linux presentationLinux presentation
Linux presentation
Nikhil Jain
 
Some basic unix commands
Some basic unix commandsSome basic unix commands
Some basic unix commands
aaj_sarkar06
 

What's hot (20)

Linux basic commands tutorial
Linux basic commands tutorialLinux basic commands tutorial
Linux basic commands tutorial
 
Terminal Commands (Linux - ubuntu) (part-1)
Terminal Commands  (Linux - ubuntu) (part-1)Terminal Commands  (Linux - ubuntu) (part-1)
Terminal Commands (Linux - ubuntu) (part-1)
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command Shell
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Linux basics
Linux basicsLinux basics
Linux basics
 
BASIC COMMANDS OF LINUX
BASIC COMMANDS OF LINUXBASIC COMMANDS OF LINUX
BASIC COMMANDS OF LINUX
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
 
Operating Systems 1
Operating Systems 1Operating Systems 1
Operating Systems 1
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command Line
 
Linux Command Suumary
Linux Command SuumaryLinux Command Suumary
Linux Command Suumary
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Basic Linux commands
Basic Linux commandsBasic Linux commands
Basic Linux commands
 
Linux day 2.ppt
Linux day  2.pptLinux day  2.ppt
Linux day 2.ppt
 
Operating Systems 2
Operating Systems 2Operating Systems 2
Operating Systems 2
 
Some basic unix commands
Some basic unix commandsSome basic unix commands
Some basic unix commands
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 

Similar to Basics of Linux

An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
Dimas Prasetyo
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
southees
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
Dima Gomaa
 
The one page linux manual
The one page linux manualThe one page linux manual
The one page linux manual
Craig Cannon
 

Similar to Basics of Linux (20)

An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
Linux
LinuxLinux
Linux
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
Linux shell scripting
Linux shell scriptingLinux shell scripting
Linux shell scripting
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Linux
LinuxLinux
Linux
 
Linux file system nevigation
Linux file system nevigationLinux file system nevigation
Linux file system nevigation
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
Linux command line cheatsheet
Linux command line cheatsheetLinux command line cheatsheet
Linux command line cheatsheet
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
Directories description
Directories descriptionDirectories description
Directories description
 
The one page linux manual
The one page linux manualThe one page linux manual
The one page linux manual
 
The one page linux manual
The one page linux manualThe one page linux manual
The one page linux manual
 
Unix Basics Commands
Unix Basics CommandsUnix Basics Commands
Unix Basics Commands
 
Introduction to linux day-3
Introduction to linux day-3Introduction to linux day-3
Introduction to linux day-3
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
 
Commands and shell programming (3)
Commands and shell programming (3)Commands and shell programming (3)
Commands and shell programming (3)
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Basics of Linux

  • 4. LINUX DISTRIBUTIONS Linux is an Operating System Linux OS = Linux Distribution Distro/Flavor = Collection of applications bundled together and distributed as one OS Common -> Kernel Kernel is the core/heart to the Linux System. Linux kernel + Apps = Distro Kernel sits between hardware and applications
  • 5. OTHER COMPONENTS OTHER THAN KERNEL User interfaces System libraries GUI Email utilities
  • 6. POPULAR DISTROS Redhat Enterprise Linux - popular in banks, airlines, telecoms, healthcare license is required for commercial use CentOS (CentOS = RHEL - branding/logos) Ubuntu - startups, SaaS, Social Networks, Cloud Based
  • 7. LINUX IS LINUX: YOU CAN'T MAKE A "WRONG" CHOICE! Linux concepts are universal. Each distro is slightly different. You can accomplish the same goals on most linux distros.
  • 8. GETTING CONNECTED Log into the GUI Log into the command line Command to exit out of the linux terminal $ exit
  • 9. GETTING CONNECTED OVER THE NETWORK SSH Windows PuTTY SSH Client Mac - Terminal/SSH Command Line Utility Linux commands are case-sensitive. $ ssh user1@mylinux $ ssh mylinux.example.com $ ssh 192.168.1.12
  • 10. COMMON LINUX DIRECTORIES / "Root", the top of the file system hierarchy /bin Binaries and other executable programs /etc System configuration files /home Home directories
  • 11. /opt Optional or third party software /tmp temprary space, typically cleared on reboot /usr User related programs /var Variable data, most notably log files
  • 12. /boot Files needed to boot the OS /cdrom Mount point for CD- ROMS /cgroup Control Groups hierarchy /dev Device files, typically controlled by the OS and the system administrators
  • 13. /export Shared file systems /lib System libraries /lib64 System Libraries, 64 bit /lost+found Used by the file system to store recovered files after a file system check has been performed /media Used to mount removable media like CD- ROMs /mnt Used to mount external file systems /opt Optional or third party software /proc Provides info about running processes
  • 14. /root The home directory for the root account /sbin System administration binaries /selinux Used to display information about SELinux /srv Contains data which is served by the system
  • 15. /srv/www Webserver files /srv/ftp FTP files /sys used to display and sometimes configured the devices known to the Linux kernel /tmp Temporary space, typically cleared on reboot.
  • 16. /usr/bin Binaries and other executable programs /usr/lib Libraries /usr/local Locally installed software that is not part of the base operating system /usr/sbin System administration binaries
  • 23. THE SHELL Also called a command line interpreter(cli) Shell is the default interface to linux A program that accepts your commands and executes those commands
  • 24. CLI VS GUI The command line is more powerful There will always be a command line Server distributions do not include GUIs Desktop distributions have GUIs and CLIs
  • 25. COMMAND LINE WEB BROWSERS ELinks
  • 26. Lynx
  • 27. w3m
  • 28. THE PROMPT [saif@mylinux ~]$ <- normal user [root@mylinux: ~]# <- superuser This root is a user and not a directory
  • 29. ROOT, THE SUPERUSER Root is all powerful Normal accounts can only do a subset of the things root can do Root access is typically restricted to system administrators Root access may be required to install, start or stop an application. sudo su - whoami sudo su - user
  • 31. MULTILINE PROMPT mylinux:[/home/saif] $ [Mon 15/07/18 05:12 EST] [pts/0] <saif@mylinux:~> zsh 14 %
  • 32. SHORTHAND FOR DIRECTORIES Tilde ~ is the shorthand representation of the home diretory of the current account ~saif = /home/saif ~bob = /home/bob ~root = /root ~ftp = /srv/ftp
  • 33. BASIC LINUX COMMANDS ls - Lists directory contents cd - Changes the current directory pwd - Displays the present working directory cat - Concatenates and displays files echo - Displays arguments to the screen man - Displays the online manual exit - Exits the shell or your current session clear - clears the screen
  • 34. ls is sometimes color-coded ls -l LS Ls lS
  • 38. man ls Spacebar: next page q: quit
  • 39. clear
  • 40. cd
  • 41. pwd
  • 42. exit
  • 43. NAVIGATING THROUGH THE FILE SYSTEM . This directory .. The parent directory cd - Change to previous directory DIRECTORY SEPARATOR IN LINUX: / (forward slash)
  • 45. man How to navigate man pages? Enter: Next line Spacebar: Next page g: Move to the top G: Move to the bottom q: Quit
  • 46. SEARCHING MAN PAGES man -k SEARCH-TERM man -k calendar
  • 47. ENVIRONMENT VARIABLES Storage location has a name and a value Typically uppercase To access the contents: echo $VAR_NAME
  • 48. PATH - An environment variable Controls the command search path Contains a list of directories echo $PATH
  • 49. HOW DO I ADD ENVIRONMENT VARIABLES? To set variable only for current shell: Edit /etc/Environment and add a newline VARNAME="my value"
  • 50. which command which cat which tac cat file.txt /bin/cat file.txt
  • 51. mkdir Creates a directory rmdir Removes an empty directory rm -rf Recursively removes directories Note- There is no recycle bin/undo option
  • 52. DECODING LS -L OUTPUT $ls -l -rw-rw-r-- 1 saif users 11300 Sep 03 03:22 file.txt Permissions -rw-rw-r-- Number of links 1 Owner name saif Group name users Number of bytes in the file 11300 last modification time Sep 03 03:22 File name file.txt
  • 53. ls -a to see hidden files hidden files starts with a period ls -l -a ls - la ls -al
  • 54. ls -F to reveal file types / Directory @ Link Exectutable
  • 55. Symbolic Links A link is a point to the actual file or directory. Use the link as if it were the file A link can be used to create a shortcut Use for long file or directory names Use to indicate the current version of software
  • 56. ls -t list files by time ls -r reverse order ls -latr long listing including all files reverse sorted by time
  • 57. WORKING WITH SPACES IN NAMES Alternatives: hyphens - underscores _ CamelCase Encapsulate the entire filename in quotes single or double Use backslash to escape spaces
  • 58. FILE AND DIRECTORY PERMISSIONS Symbol type - : Regular file d : Directory l : Symbolic link r : Read (cat) w : Write (modify/change) x : Execute (run as program) -rw-rw-r-- 1 saif users 11300 Sep 03 03:22 file.txt
  • 59. read file - allows a file to be read direcory - allows filenames in the directory to be read
  • 60. write file - allows a file to modified directory - allows entries to be modified within the directory
  • 61. execute file -allows the execution of a file directory - allows access to contents and metadata for entries
  • 62. The character in the first position, a dash (-), indicates that this is a file and not a directory. Directories are marked with a d, as in drwxr-x--- - rw- r-- r-- user, group, other Permissions = Modes
  • 63. PERMISSION CATEGORIES u : User (owner) g : Group o : Other a : All
  • 64. GROUPS Every user is in atleast one group Users can belong to many groups Groups are used to organize users The groups command displays a user's groups You can also use id -Gn chgrp newgroup myfile
  • 66. chmod: change mode command ugoa: User category: user, group, other, all +-=: Add, subtract, or set permissions rwx: Read, Write, Execute
  • 67. chmod g+w file.txt chmod g-w file.txt chmod g+wx file.txt chmod u+rwx, g-x file.txt chmod a=r file.txt chmod u=rwx, g=rx, o= file.txt
  • 68. | r | w | x | | 0 | 0 | 0 | | 1 | 1 | 1 | | 4 | 2 | 1 | | Octal | Binary | String | Description | | 0 | 0 | --- | No permissions | | 1 | 1 | --x | Execute only | | 2 | 10 | -w- | write only | | 3 | 11 | -wx | write and execute | | 4 | 100 | r-- | read only | | 5 | 101 | r-x | read and execute | | 6 | 110 | rw- | read and write | | 7 | 111 | rwx | read, write and execute |
  • 69. U G O Symbolic rwx r-x r-- Binary 111 101 100 Decimal 7 5 4
  • 70. Symbolic Octal -rwx------ 700 -rwxr-xr-x 755 -rw-rw-r-- 664 -rw-rw---- 660 -rw-r--r-- 644
  • 71. FILE CREATION MASK File creation mask determines default permissions If no mask were used permissions would be 777 for directories 666 for files
  • 72. THE UMASK COMMAND umask [-S] [mode] S = symbolic notation Sets the file creation mask to mode, if given. Use -S to for symbolic notation.
  • 73. directory file Base Permissions 777 666 Subtract Umask -022 -022 Creations Permission 755 644
  • 74. SEARCHING FOR FILES AND DIRECTORIES Recursively finds files in path that match expression. If no arguments are supplied it will find all files in the current directory. find [path...] [expression]
  • 75. -name patttern Find files and directories that match pattern -iname pattern Like -name, but ignores case -mtime days Finds file that are days old -size num Finds file that are of size num -newer file Finds files that are newer than file -ls Performs an ls on each of the found items -exec command {} ; Run command against all the files that are found.
  • 76. LOCATE Lists files that match pattern Faster than the find command Queries an index Results are not in real time May not be enabled on all systems
  • 77. COPYING, MOVING, RENAMING rm file removes directory and its contents recursively force removal and never prompts for confirmation rm -r dir rm -f file ls s* rm s* ls -d .* rm .*
  • 78. cp source destination cp srcfile1 [srcfileN ...] dest_dir cp -i Run in interactive mode
  • 79. cp file1 file2 cp file1 file2 dir cp -r source_directory destination Copy src_directory recursively to destination/destination direcory is created
  • 80. mv dir firstdir mv file1 file1.renamed mv file1.renamed firstdir mv file1 file2 //overwrites mv -i file1.renamed file2
  • 81. CREATING A COLLECTION OF FILES tar cf tps.tar tpsreports tar tf tps.tar cd /tmp tar xf /home/saf/tps.tar ls -l tps
  • 82. CRONJOBS To edit the crontab file: crontab -e
  • 83. This cron job will run every minute, all the time: This cron job will run at minute zero, every hour (i.e. an hourly cron job): This is also an hourly cron job but run at minute 15 instead (i.e. 00:15, 01:15, 02:15 etc.): This will run once a day, at 2:30am: * * * * * [command] 0 * * * * [command] 15 * * * * [command] 30 2 * * * [command]
  • 84. This will run once a month, on the second day of the month at midnight (i.e. January 2nd 12:00am, February 2nd 12:00am etc.): This will run on Mondays, every hour (i.e. 24 times in one day, but only on Mondays): Dash can be used to specify a range. This will run once every hour between 5:00am and 10:00am: 0 0 2 * * [command] 0 * * * 1 [command] 0 5-10 * * * [command]
  • 85. Also there is a special keyword that will let you run a cron job every time the server is rebooted: @reboot [command]