The document provides an overview of the Linux operating system. It discusses key Linux concepts like the kernel, shell, file structure, users and permissions. It also summarizes common Linux commands for file management, editing, users, groups, software installation and services. Key tools covered include vi editor, rpm, tar, useradd/del, service and chkconfig. The document is intended as part of an introductory Linux presentation.
2. •
•
•
•
•
•
•
•
•
•
•
•
•
Overview of Linux System
Vi editor
Basic Commands
Redirect, Append, and Pipe
Relative & Absolute Path
File System & Partitions
Permissions
Process Management
User Management
Group
Software Management
Backup and restore
Managing installed services
Outline
3. Overview of Linux System
Linux is an Operating system (OS).
Linux system is described as kernel & shell.
Kernel is the main program of Linux system. It controls hardware,
CPU, memory, hard disk, network card etc.
Shell is an interface between user and kernel. Shell interprets your
input as commands and pass them to kernel.
4. Overview of Linux System
Multiuser & Multiprocess:
Many people can use one machine at the same time.
File & Process:
Data, directory, process, hard disk etc (almost everything) are
expressed as a file.
Process is an running program identified by a unique id (PID).
5. Overview of Linux System
Directory Structure
Files are put in a directory.
All directories are in a hierarchical structure (tree structure).
User can create and remove any directories on the tree.
Top directory is “/”, which is called slash or root.
Users have the own directory. (home directory)
7. Overview of Linux System
Important Directories:/bin- This contains files that are essential for correct operation of the
system. These are available for all users to use.
/mnt- Provides a location for mounting devices, such as remote file
systems and removable media
/home- This is where user home directories are stored.
/var- This directory is used to store files which change frequently, and
must be available to be written to.
/etc- Various system configuration files are stored here.
8. Overview of Linux System
/dev- This contains various devices as files, e.g. harddisk, CDROM drive,
etc.
/root- This is the root (administrator) user's home directory
/sbin- Binaries which are only expected to be used by the super user.
/tmp- Temporary files.
/boot Has the bootable Linux kernel and bootloader configuration
files(GRUB)
/usr- Contains user documentation, games, graphical files,
libraries(lib),etc..
9. Overview of Linux System
Normal user and Super user
In Linux system, there is one special user for administration, who can
do anything. This special user is called root or superuser.
Case Sensitivity
Linux operating system is case sensitive.
10. Overview of Linux System
Run levels in Linux- refers to the mode of operation in the Linux
operating systems
Following are the run levels of some popular Linux versions
Following are the seven run levels in Ubuntu
0 ->halt
1 ->Single user mode
2 ->Graphical multi-user with networking
3 – 5 -> Unused but configured the same as runlevel 2
6 -> Reboot
11. Overview of Linux System
Following are the seven run levels in Red Hat Linux and Fedora
0 ->halt
1 ->Single user text mode(without networking)
2 ->Not used (user definable)
3 -> Full multi-user text mode
4 -> Not used (user definable)
5 -> Full multi-user graphical mode (with an X-based login screen)
6 -> Reboot
12. VI Editor
• Programs & configuration files are text files.
• There are two popular text editors vi and Emacs.
• vi is a screen-oriented text editor originally created for
the Unix operating system.
13. Basic Commands
How to run commands
When you log on Linux machine, you will see,
[cseos@hyperion001 srinu]$
start typing the command next to the $ symbol
One command consists of three parts, i.e. command name, options,
arguments.
Between command name, options and arguments, space is necessary.
For Example
[srinu~]$ command-name optionA optionB argument1 argument2
15. Basic Commands
Basic useful Commands
ls - show files in current position
cd - change directory
cp - copy file or directory
mv - move file or directory
rm - remove file or directory
pwd - show current position
mkdir - create directory
rmdir - remove directory
cat - display file contents
less - display file contents pagewise
16. Basic Commands
man - display online manual
su - switch user
passwd - change password
useradd - create new user account
userdel - delete user account
mount - mount a file system
umount - unmount a mounted file system
df - show disk space usage
shutdown - reboot or turn off machine
17. Redirect, Append and Pipe
Redirect and append
Output of command is displayed on screen by redirecting to a file.
Using “>”, you can redirect the output from screen to a file.
Using “>>” you can append the output to the bottom of the file.
Pipe
Some commands require input from a file or other commands.
Using “|”, you can use output from other command as input to the
command.
18. Redirect, Append and Pipe
Commands
head - show first several lines and omit other lines.
tail - show last several lines and omit other lines.
grep - show lines matching a pattern
Working with commands:
In home directory, type
->ls .bash_profile
->cp .bash_profile sample.txt
->less sample.txt
19. Redirect, Append and Pipe
Using redirect.
->head 3 sample.txt
->head 3 sample.txt > redirect.txt
Using append.
->tail 3 sample.txt tail 3
->sample.txt >> redirect.txt less redirect.txt
Using pipe.
less redirect.txt
grep PATH redirect.txt
tail redirect.txt | grep PATH
rm sample.txt
rm redirect.txt
20. Relative & Absolute Path
Path means a position in the directory tree.
To express a path, you can use relative path or absolute path.
In relative path expression, the path is not defined uniquely, it
depends on your current path.
In absolute path expression, the path is defined uniquely, it does not
depend on your current path.
21. File System & Partitions
Everything is a file in linux.
Mounting
Files related to mounting in linux
/etc/mtab(Current files mounted)
/etc/fstab(info about permanent mounting points)
22. File System & Partitions
Partitions
Commands to view existing partitions
fdisk –l
parted –l
Partition administration using fdisk
fdisk <partition name with location> eg:- fdisk /dev/sda.
Various options for fdisk are n,p,q,t,v,w,etc..
Updating the partition without restarting :partrobe /dev/sda or partx /dev/sda
Formatting a partition with file systems(eg- ext4 system)
mkfs.<file system type> <partition name>
Eg - mkfs.ext4 /dev/sda
Note:-After formatting the partition must me mounted in ordered to use
23. File System & Partitions
Mounting Partitions:-
Temporary mounting
mount <device name> <directory name(mount point)>
Eg:- mount /dev/sda oslab
Permanent mounting
Add the parameters for mounting point in the file /etc/fstab as follows
Umounting the partition
umount <mount point directory>
Eg:- umount /oslab
To view mount points use the command mount
Assigning label to the partition(giving some name to partition)
e2label <partition name> <label>
Eg:- e2label </dev/sda> <os>
24. File System & Partitions
Mounting a partition using label
mount LABEL=<label name> <partition name>
Eg:- mount LABEL=os /oslab
LVM(Logical volume management)
25. File System & Partitions
Components of LVM
Physical volume (PV)
Physical Extend (PE)
Volume Group (VG)
Logical Volume (LV)
Logical Extend (LE)
Commands in LVM
pvs, vgs, lvs – displays all PVs, VGs, and LVs in the system
Display detailed information
pvdisplay, vgdisplay, lvdisplay
creating PVs, VGs, LVs
pvcreate, vgcreate, and lvcreate
26. File System & Partitions
lvresize – resizes a logical volume
lvreduce – reduces a logical volume
vgreduce – reduces a volume group
Removing/deleting PVs, VGs, LVs
pvremove, vgremove, lvremove
27. Permissions
All the files and directories have the permissions and owner assigned
to them.
There are three types of permission readable, writeable and
executable.
Permissions are given to three kinds of groups namely owner, group
member and others.
Example[cswug@hyperion001 cswug]$ ls l .bash_profile
-rw-r--r-- 1 cswug cswug 191 Jan 4 13:11 .bash_profile
Note-r : readable, w:writable, x: executable
28. Permissions
Commandschmod- change file mode, add or remove permission
chown- change owner of the file
Examplechmod a+w filename - add writable permission to all users
chmod o-x filename - remove executable permission from others
Note- u: user (owner), g: group, o: others a: all
29. Permissions
acl- access control lists
More secure way to secure the files.
The file system have to be mounted with the option acl in /etc/fstab
file.
Files with acls can be read only using the getfacl command.
Writing or changing acls can be done with setfacl or /usr/bin/setfacl.
To remove an acl of a file system use –x option for setfacl command.
30. Process Management
Process is a unit of running program.
Each process has some information, like process ID, owner, priority, etc.
CommandsKill - Sends specified signal to specified process .The process is specified by
process ID.
Killall – kills all the process with a particular name. The program is
specified by command name.
ps - Show process status
top - Show system usage statistics
31. Process Management
Check your process.
ps
ps –u
Check process of all users.
top (To quit top, press “q”)
ps –e
ps –ef
Find your process.
ps –ef | grep cseos
33. User Management
Commands to know
whoami – Gives the current Username.
who – gives the information about who is logged on the system.
who am i – gives the details about current session in a line.
w – shows you who is logged on and what they are doing.
id – gives the user id, primary group id, and a list of the groups that
you belong to.
34. User Management
Root user-The root user is also called the superuser is the most
powerful account on the Linux system(userid 0)
User management on any Unix can be done in three ways.
1. Graphical
2. Command line tools
3. Edit the local configuration files
35. User Management
Important files in user management/etc/shadow- User passwords are encrypted and kept in /etc/shadow
/etc/passwd –Contains the local user database on Linux
/etc/default/useradd - contains some default user options.
Home directories(Two ways of creating home directories)
1. useradd –m to create a home directory for user.
2. Create a directory using mkdir and setting the owner as user using
chmod and restricting the permissions.
36. User Management
Commands for user management
useradd- to add a user
usermod – to modify the properties of a user
gpasswd – to manage the users
userdel – to delete a user
passwd – to manage passwords for users).
chage – to change the attributes of the passwords of users
su – allows a user to run a shell of other users
Sudo-The sudo program allows a user to start a program with the credentials
of another user.
37. Group
Users can be listed in groups.
Groups allows you to set permissions on the group level instead of having to
set permissions for every individual user.
/etc/group – file in which group membership is defined.
Commands for group management
group – to view the list of groups to which user belongs to.
groupadd – to add new groups
usermod - Group membership can be modified
groupmod – to change the group name
groupdel – to remove a group permanently
38. Software Management
RPM utility is used to manage soft wares in linux
RPM – Red Hat Package Manager
Tool used for installing, uninstalling, verifying, querying, and updating software packages.
Commands for RPM
rpm –qa (q- query and a- all) > gives all the installed packages on the system
rpm –q <package name>
> to check whether a package is installed or not.
rpm –ivh <package name> > to install a package(i-install, v- verbose view, hhash progress)
Note:- to install a package, first navigate to the directory in which packages are
stored
rpm –e <package name> >to uninstall/ remove a package(e- erase)
39. Software Management
rpm –qf <package directory> > to install the package forcefully
rpm –qlc <packager name>
> to see the configuration files of installed
package(q-query, l-local, c-configuration)
rpm –qld <package name>
> to see which directory is associated with a
particular package (q-query, l- local, d- directory)
Dependency- some packages requires some other packages to be installed
before it can be installed.
rpm -ivh <package name> --nodeps > to install packages without dependicies.
rpm -uvh <package name>
> to update a package(u- update, v-verbose, h-hash
progress)
40. Backup and restore
Backup using tar
tar – cvf <destination and name to be> <source file>
>creating a tar backup
for source file (note: c-create, v-verbose, f-name of tar file)
eg:- tar – cvf /opt/etc.tar /etc
gzip <file name> >applying gzip on the tar file
eg:- gzip /opt/etc.tar
scp <gzip file> <destination address> > transferring the file to another system
using secure copy (scr) (destination address is the IP address of the target system
followed by the target directory)
eg:- scp /opt/etc.tar.gz 192.XXX.XX.X/root/
gunzip <file name> > to unzip the file
tar – xvf <file name> > to untar the file (x-remove)
eg:- tar – xvf etc.tar
41. Managing installed services
Services/programs
Two commands to control the services
1. Service
Temporary control(changes only for current session / after booting the
changes will be erased from the service)
Commands
service <name of the service> status -> used to check the status of the service
service <name of the service> start -> used to start the service
service <name of the service> stop -> used to stop the service
service <name of the service> reload -> used to reload the service
service <name of the service> restart -> used to restart the service
42. Managing installed services
2. Chkconfig
Permanent control(changes are carried until they are changed again no
matter of booting).
Commands
chkconfig - - list >to check the availability of the service
chkconfig <service> on > to make the service available after restart
chkconfig <service> off > to make the service unavailable after restart