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
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
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
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
43. NAVIGATING THROUGH THE FILE
SYSTEM
. This directory
.. The parent directory
cd - Change to previous directory
DIRECTORY SEPARATOR IN LINUX:
/ (forward slash)
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
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
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 .*
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]