SlideShare a Scribd company logo
Document Number: Copy Number:
TATA CONSULTANCY SERVICES
PRE ILP – Unix LOUNGE
Content Manual Version 1.0
March 2014
DOCUMENT RELEASE NOTICE
Notice No.
Client
Project
Document details
Name Version No. Author Description
Revision details:
Action taken
(add/del/chg
)
Preceding
page No.
New
page No.
Revision
description
Change Register serial numbers covered:
The documents or revised pages are subject to document control.
Please keep them up-to-date using the release notices from the distributor of the document.
These are confidential documents. Unauthorised access or copying is prohibited.
Approved by : ________________________________ Date: _________
Authorised by: ________________________________ Date: _________
TCS PreILP - Unix Lounge Content Manual – Ver. 1.0
DOCUMENT REVISION LIST
Client
Project
Document Name
Release Notice Reference (for release)
Rev.
No.
Revision
date
Revision
description
Page
No.
Prev
page
No.
Action
taken
Addenda
/New
page
Release
Notice
reference
TCS PreILP - Unix Lounge Content Manual – Ver. 1.0
CONTENTS
CHAPTER 3 - UNIX USERS AND FILE PERMISSIONS......................................................V
3.1 Objective...........................................................................................................v
3.2 Course Content.................................................................................................v
3.2.1 Types of users in Unix...............................................................................v
3.2.2 Managing users and groups.....................................................................vi
3.2.3 File Permission: Ownerships level............................................................vi
3.2.4 File Permission Types (Mode).................................................................vii
3.2.5 Unix - File Permission / Access Modes...................................................vii
3.2.6 Changing Permissions (chmod)..............................................................viii
3.2.6.1 Using chmod in Symbolic Mode........................................................viii
3.2.6.2 Using chmod in Absolute(octal) Mode................................................ix
3.3 Video 3 : Users, File Permission ......................................................................x
3.4 Quiz Time..........................................................................................................x
CHAPTER 4 - UNIX DIRECTORY COMMANDS..............................................................XI
4.1 Objective..........................................................................................................xii
4.2 Course Content................................................................................................xii
4.2.1 Introduction..............................................................................................xii
4.2.2 mkdir(make directory) command:...........................................................xii
4.2.3 cd (Change Directory) command:...........................................................xiii
4.2.4 cp command:...........................................................................................xiv
4.2.5 mv Command:.........................................................................................xiv
4.2.6 rmdir(remove directory) command:.........................................................xv
4.2.7 rm (remove files) command: ...................................................................xv
4.2.8 Video 4: Directory commands.................................................................xvi
4.3 Quiz Time.......................................................................................................xvi
CHAPTER 3 - UNIX USERS AND FILE
PERMISSIONS
3.1 Objective
To understand about the different users in UNIX and their access rights.
3.2 Course Content
 Type of users
 File permissions
 Changing permissions using symbolic mode
 Changing permissions using octal mode
3.2.1 Types of users in Unix
There are three types of accounts on a Unix system:
- Root Account
- System Account
- User Account
Root System User
● This is also called
superuser and would
have complete and
unfettered control of the
system.
● A superuser can run
any commands without
any restriction. This
user should be
assumed as a system
administrator.
● System accounts are
those needed for the
operation of system-
specific components for
example mail accounts
and the sshd accounts.
● These accounts are
usually needed for
some specific function
on your system, and
any modifications to
them could adversely
affect the system.
● User accounts provide
interactive access to
the system for users
and groups of users.
● General users are
typically assigned to
these accounts and
usually have limited
access to critical
system files and
directories.
3.2.2 Managing users and groups
 Unix supports a concept of Group which logically groups a number of
accounts.
 Every account would be a part of any group.
 Unix groups plays important role in handling file permissions and process
management.
 Grouping of users allows to grant and revoke file permissions collectively.
/etc/passwd: Keeps user account and password information.
/etc/shadow: Holds the encrypted password of the corresponding account. Not
all the system support this file.
/etc/group: This file contains the group information for each account.
/etc/gshadow: This file contains secure group account information.
3.2.3 File Permission: Ownerships level
File ownership is an important component of Unix that provides a secure method
for storing files. Every file in Unix has the following attributes:
Permission Symbol Description
Owner
Permissions
u The owner's permissions determine what actions the
owner of the file can perform on the file.
Group
Permissions
g The group's permissions determine what actions a
user, who is a member of the group that a file
belongs to, can perform on the file.
Other
Permissions
o The permissions for others indicate what action all
other users can perform on the file.
3.2.4 File Permission Types (Mode)
Three type of permissions can be set any ownership level:
Read, Write and Execute
 Three modes or permissions have different meaning for file and directory;
3.2.5 Unix - File Permission / Access Modes
Consider the output of the command ls -l
 Out of 9 columns in output, 1st column indicates the file type and its
permissions.
 This Column contains 10 characters.
 Character 1 : Represents File Type ( 'd' : Directory; '-' : Regular File )
 Character 2-4 : Represents Permission for owner(user) of file
 Character 5-7 : Represents Permission for group user belongs to.
 Character 8-10 : Represents Permission for other
Mode Sym
bol
For File For Directory
Read r Allows to view the content Allows to view the directory
content using ls command
Write
w Allows edit and save changes. Create and delete files in the
directory
Execute
x Allows to run program or script Allows to access the files in the
directory
3.2.6 Changing Permissions (chmod)
To change file or directory permissions, the chmod (change mode) command is
used.
There are two ways to use chmod:
 Symbolic mode
 Absolute mode
chmod command options:
3.2.6.1 Using chmod in Symbolic Mode
With symbolic representation, permission set can be added, deleted, or specified
using the operators in the following table:
For example, to give everyone execute permission for a file, you can use :
$chmod ugo+x filename
or
$chmod a+x filename
For example, to remove execute permission from others and retain the
Syntax:
$ chmod [OPTION] MODE FILENAME
$ chmod [OPTION] OCTAL-MODE FILENAME
-f, --silent, --quiet suppress most error messages
-R, --recursive change files and directories recursively
--help display this help and exit
chmod operators Description
+ Adds the designated permission(s) to a file or directory.
- Removes the designated permission(s) from a file or directory.
= Sets the designated permission(s).
existing permissions for all for a file, you can use :
$chmod o-x filename
In the above example,
$ chmod u+wx,g+wx abc , adds execute permission to user and group to the file
abc
$ chmod g-x abc, removes execute permission from group from the file abc.
$ chmod o=r-- abc, provides read permission and removes write and execute
permission from others for file abc
3.2.6.2 Using chmod in Absolute(octal) Mode
 The second way to modify permissions with the chmod command is to use
a number to specify each set of permissions for the file.
 Each permission is assigned a value, as the following table shows, and
the total of each set of permissions provides a number for that set.
Examples:
-bash-3.2$ ls -l abc
-rw-r--r-- 1 735873 oinstall 0 Feb 7 12:37 abc
-bash-3.2$ chmod 0 abc
-bash-3.2$ ls -l abc
---------- 1 735873 oinstall 0 Feb 7 12:37 abc
-bash-3.2$ chmod 743 abc
-bash-3.2$ ls -l abc
-rwxr---wx 1 735873 oinstall 0 Feb 7 12:37 abc
-bash-3.2$ chmod 755 abc
-bash-3.2$ ls -l abc
-rwxr-xr-x 1 735873 oinstall 0 Feb 7 12:37 abc
-bash-3.2$ chmod 777 abc
-bash-3.2$ ls -l abc
-rwxrwxrwx 1 735873 oinstall 0 Feb 7 12:37 abc
3.3 Video 3 : Users, File Permission
http://www.youtube.com/watch?v=zRw0SKaXSfI
3.4 Quiz Time
Q1. Which is the superuser for Unix
A. system
B. root
Number Octal Permission Representation Ref
0 No permission ---
1 Execute permission --x
2 Write permission -w-
3 Execute and write permission: 1 (execute) + 2 (write) = 3 -wx
4 Read permission r--
5 Read and execute permission: 4 (read) + 1 (execute) = 5 r-x
6 Read and write permission: 4 (read) + 2 (write) = 6 rw-
7 All permissions: 4 (read) + 2 (write) + 1 (execute) = 7 rwx
C. all users
D. there's no such user
Answer :B
Q2. What is stored in the /etc/passwd file?
A. user account information
B. user password
C. Both A and B
D. password configuration details
Answer: C
Q3. Which command is used to change the file permissions in Unix?
A. perm
B. sysconfig
C. systemconfig
D. chmod
Answer: D
Q4. Unix logically groups the users.
A. True
B. False
C. Not completely
D. Sometimes
Answer: A
CHAPTER 4 - UNIX DIRECTORY COMMANDS
4.1 Objective
 To provide overview of the most common commands to work with
directories. These commands are available on any Linux (or Unix) system.
4.2 Course Content
The commands discussed include:
 mkdir
 cd
 cp
 mv
 rmdir
 rm
4.2.1 Introduction
What is a directory?
When a user interacts with the UNIX shell, the shell considers the user to
be located somewhere within a filesystem. Every item in the UNIX
filesystem tree is either a file, or a directory. A directory is like a file
folder. A directory can contain files, and other directories. A directory
contained within another is called the child of the other. A directory in
the filesystem tree may have many children, but it can only have one
parent. A file can hold information, but cannot contain other files, or
directories. A directory is actually implemented as a file that has one line
for each item contained within the directory. Each line in a directory file
contains only the name of the item, and a numerical reference to the
location of the item. The reference is called an i-number(inode), and is an
index to a table known as thei-list. The i-list is a complete list of all the
storage space available to the file system. The place in the file system
tree where an user is located is called the current working directory.
 A file in unix file system which contains information about other files .
 It contains information about files and directories through which UNIX
looks up to obtain information about a particular file.
 As we login, we are put in our home directory.
 At a time where the user is located is called the current working
directory.
4.2.2 mkdir(make directory) command:
The mkdir command creates a directory with specified name in the present
working directory or specified path.
Syntax: $ mkdir <dir_name> [ <dir_name2> ]
4.2.3 cd (Change Directory) command:
cd command provides navigation between directories.
$ cd / : Takes you to root directory
$ cd ~ : Takes you to home Directory (/home/userid)
$ cd .. : Takes you to current parent Directory
$ cd <dir_name> : Takes you to the desired directory
$ mkdir Games
$ ls
Games
$
$ mkdir Games/Indoor Games/Outdoor
$ ls Games
Indoor Outdoor
$
The above command creates two directories, Indoor and Outdoor in
specified path under Games
$ pwd
/home/amit
$ cd /
$ pwd
/
$
$ pwd
$ /
$ cd ~
$ pwd
/home/amit
$
$ pwd
/home/amit
$ cd ..
$ pwd
/home
$
4.2.4 cp command:
The command cp with -r option copies a directory and all its contents(sub-
directory and files) recursively to another.
Syntax:
cp -r <source_directory> <destination_path>
4.2.5 mv Command:
Moves the contents of a file or directory.
If the source and destination path is same it renames the file or directory.
Syntax: $ mv <source_dir> <destination_dir>
$ pwd
/home
$ cd amit
$ pwd
/home/amit
$cd Games/Indoor
$ pwd
/home/amit/Games/Indoor
$ ls
Dir1 Games
$ cp -r Games Dir1
$ ls Dir1
Games
$ ls
Dir1 Games
Copies Games into Dir1
Directory Dir1 now contains a copy of Games
One copy of Games still exist in source path
$ ls
Dir1 Games
$ mv Games Sports
$ ls
Dir1 Sports
$ mv Sports Dir1
$ ls Dir1
Games Sports
$ ls
Dir1
$
Command mv renames Games to Sports
Now Directory Sports moved into Dir1
4.2.6 rmdir(remove directory) command:
To remove any existing empty directory.
Syntax: rmdir <dir_name>
Remark: To delete a Directory with content/which is not empty rm command can
be used.
Syntax: rm -R /path
4.2.7 rm (remove files) command:
Removes existing files and directories.
Syntax: rm filename
Remark: The file being deleted may contain important information,so “-i” option is
recommended to be used along with rm command.
$ ls
Dir1 Games
$ ls Games
Indoor Outdoor
$ rmdir Games
rmdir: Directory not empty
$ rmdir Games/Indoor
$ rmdir Games/Outdoor
$ rmdir Games
$ ls
Dir1
$
Directory can be removed
only if it is empty
Contents of Games removed
Directory Games removed now
List the file in current directory
Interactive Deletion Performed
File testRm is removed
4.2.8 Video 4: Directory commands
http://www.youtube.com/watch?v=VPgrtk0HQB0&list=PL8A83A276F0D85E70
http://www.youtube.com/watch?v=HsBEzs6Q7w4&list=PL8A83A276F0D85E70
4.3 Quiz Time
Q1. Which command in Unix will help in creating new directories?
A. mkdir
B. makedir
C. create
D. new
Answer: A
Q2. Which command will help in deleting an empty directory?
A. delete
B. deletedir
C. remove
D. rmdir
Answer: D
Q3. Which command will help in moving a directory?
A. move
B. dirmover
C. mv
D. mvdir
Answer: C
Q4. Which command is used to rename a directory?
A. rename
B. changename
C. remdir
D. mv
Answer: D
Q5. Which option when used with cp will copy an directory will all its contents?
A. -R
B. -a
C. -m
D. -f
Answer: A

More Related Content

What's hot

Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
meashi
 
Unix Command Line Productivity Tips
Unix Command Line Productivity TipsUnix Command Line Productivity Tips
Unix Command Line Productivity Tips
Keith Bennett
 
58518522 study-aix
58518522 study-aix58518522 study-aix
58518522 study-aix
homeworkping3
 
Operating system lab manual
Operating system lab manualOperating system lab manual
Operating system lab manual
Meerut Institute of Technology
 
Basic Unix
Basic UnixBasic Unix
Basic Unix
Rajesh Kumar
 
Unix features, posix and single unix specification
Unix features, posix and single unix specificationUnix features, posix and single unix specification
Unix features, posix and single unix specification
sudha rani
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
Sudharsan S
 
Linux commands
Linux commandsLinux commands
Linux commands
Meenu Chopra
 
Unix Basics For Testers
Unix Basics For TestersUnix Basics For Testers
Unix Basics For Testers
nitin lakhanpal
 
02 linux desktop usage
02 linux desktop usage02 linux desktop usage
02 linux desktop usage
Shay Cohen
 
Introduction to unix
Introduction to unixIntroduction to unix
Introduction to unix
sudheer yathagiri
 
Bozorgmeh os lab
Bozorgmeh os labBozorgmeh os lab
Bozorgmeh os lab
FS Karimi
 
Unix practical file
Unix practical fileUnix practical file
Unix practical file
Soumya Behera
 
Os lab manual
Os lab manualOs lab manual
Os lab manual
Neelamani Samal
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
Teja Bheemanapally
 
5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables
Gautam Raja
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
Dima Gomaa
 
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERSVTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
vtunotesbysree
 
Unix ppt
Unix pptUnix ppt
User and groups administrator
User  and  groups administratorUser  and  groups administrator
User and groups administrator
Aisha Talat
 

What's hot (20)

Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
 
Unix Command Line Productivity Tips
Unix Command Line Productivity TipsUnix Command Line Productivity Tips
Unix Command Line Productivity Tips
 
58518522 study-aix
58518522 study-aix58518522 study-aix
58518522 study-aix
 
Operating system lab manual
Operating system lab manualOperating system lab manual
Operating system lab manual
 
Basic Unix
Basic UnixBasic Unix
Basic Unix
 
Unix features, posix and single unix specification
Unix features, posix and single unix specificationUnix features, posix and single unix specification
Unix features, posix and single unix specification
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Unix Basics For Testers
Unix Basics For TestersUnix Basics For Testers
Unix Basics For Testers
 
02 linux desktop usage
02 linux desktop usage02 linux desktop usage
02 linux desktop usage
 
Introduction to unix
Introduction to unixIntroduction to unix
Introduction to unix
 
Bozorgmeh os lab
Bozorgmeh os labBozorgmeh os lab
Bozorgmeh os lab
 
Unix practical file
Unix practical fileUnix practical file
Unix practical file
 
Os lab manual
Os lab manualOs lab manual
Os lab manual
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
 
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERSVTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
 
Unix ppt
Unix pptUnix ppt
Unix ppt
 
User and groups administrator
User  and  groups administratorUser  and  groups administrator
User and groups administrator
 

Viewers also liked

1_Editors_in_Unix
1_Editors_in_Unix1_Editors_in_Unix
1_Editors_in_Unix
Gautam Raja
 
SharePoint Summit Toronto - Practical Information Architecture Tools and Tech...
SharePoint Summit Toronto - Practical Information Architecture Tools and Tech...SharePoint Summit Toronto - Practical Information Architecture Tools and Tech...
SharePoint Summit Toronto - Practical Information Architecture Tools and Tech...
Richard Harbridge
 
Why Permissions Drive your Governance Strategy
Why Permissions Drive your Governance StrategyWhy Permissions Drive your Governance Strategy
Why Permissions Drive your Governance Strategy
Christian Buckley
 
Active Directory File Permissions. Get Fast Answers to Who? What?
Active Directory File Permissions. Get Fast Answers to Who? What?Active Directory File Permissions. Get Fast Answers to Who? What?
Active Directory File Permissions. Get Fast Answers to Who? What?
SolarWinds
 
Linux files and file permission
Linux files and file permissionLinux files and file permission
Linux files and file permission
U.P Police
 
Data-Ed Webinar: Data Governance Strategies
Data-Ed Webinar: Data Governance StrategiesData-Ed Webinar: Data Governance Strategies
Data-Ed Webinar: Data Governance Strategies
DATAVERSITY
 
Data Governance: Keystone of Information Management Initiatives
Data Governance: Keystone of Information Management InitiativesData Governance: Keystone of Information Management Initiatives
Data Governance: Keystone of Information Management Initiatives
Alan McSweeney
 
Ibm data governance framework
Ibm data governance frameworkIbm data governance framework
Ibm data governance framework
kaiyun7631
 
Data Governance Best Practices
Data Governance Best PracticesData Governance Best Practices
Data Governance Best Practices
Boris Otto
 
Data, Information And Knowledge Management Framework And The Data Management ...
Data, Information And Knowledge Management Framework And The Data Management ...Data, Information And Knowledge Management Framework And The Data Management ...
Data, Information And Knowledge Management Framework And The Data Management ...
Alan McSweeney
 
How to Build & Sustain a Data Governance Operating Model
How to Build & Sustain a Data Governance Operating Model How to Build & Sustain a Data Governance Operating Model
How to Build & Sustain a Data Governance Operating Model
DATUM LLC
 
SharePoint Permissions Worst Practices
SharePoint Permissions Worst PracticesSharePoint Permissions Worst Practices
SharePoint Permissions Worst Practices
Bobby Chang
 
Implementing Effective Data Governance
Implementing Effective Data GovernanceImplementing Effective Data Governance
Implementing Effective Data Governance
Christopher Bradley
 
Review of Data Management Maturity Models
Review of Data Management Maturity ModelsReview of Data Management Maturity Models
Review of Data Management Maturity Models
Alan McSweeney
 

Viewers also liked (14)

1_Editors_in_Unix
1_Editors_in_Unix1_Editors_in_Unix
1_Editors_in_Unix
 
SharePoint Summit Toronto - Practical Information Architecture Tools and Tech...
SharePoint Summit Toronto - Practical Information Architecture Tools and Tech...SharePoint Summit Toronto - Practical Information Architecture Tools and Tech...
SharePoint Summit Toronto - Practical Information Architecture Tools and Tech...
 
Why Permissions Drive your Governance Strategy
Why Permissions Drive your Governance StrategyWhy Permissions Drive your Governance Strategy
Why Permissions Drive your Governance Strategy
 
Active Directory File Permissions. Get Fast Answers to Who? What?
Active Directory File Permissions. Get Fast Answers to Who? What?Active Directory File Permissions. Get Fast Answers to Who? What?
Active Directory File Permissions. Get Fast Answers to Who? What?
 
Linux files and file permission
Linux files and file permissionLinux files and file permission
Linux files and file permission
 
Data-Ed Webinar: Data Governance Strategies
Data-Ed Webinar: Data Governance StrategiesData-Ed Webinar: Data Governance Strategies
Data-Ed Webinar: Data Governance Strategies
 
Data Governance: Keystone of Information Management Initiatives
Data Governance: Keystone of Information Management InitiativesData Governance: Keystone of Information Management Initiatives
Data Governance: Keystone of Information Management Initiatives
 
Ibm data governance framework
Ibm data governance frameworkIbm data governance framework
Ibm data governance framework
 
Data Governance Best Practices
Data Governance Best PracticesData Governance Best Practices
Data Governance Best Practices
 
Data, Information And Knowledge Management Framework And The Data Management ...
Data, Information And Knowledge Management Framework And The Data Management ...Data, Information And Knowledge Management Framework And The Data Management ...
Data, Information And Knowledge Management Framework And The Data Management ...
 
How to Build & Sustain a Data Governance Operating Model
How to Build & Sustain a Data Governance Operating Model How to Build & Sustain a Data Governance Operating Model
How to Build & Sustain a Data Governance Operating Model
 
SharePoint Permissions Worst Practices
SharePoint Permissions Worst PracticesSharePoint Permissions Worst Practices
SharePoint Permissions Worst Practices
 
Implementing Effective Data Governance
Implementing Effective Data GovernanceImplementing Effective Data Governance
Implementing Effective Data Governance
 
Review of Data Management Maturity Models
Review of Data Management Maturity ModelsReview of Data Management Maturity Models
Review of Data Management Maturity Models
 

Similar to 4_Users_and_File_Permission_and_Directory_Commands

FILE PERMISSION OR ACCESS MODE
 FILE PERMISSION OR ACCESS MODE FILE PERMISSION OR ACCESS MODE
FILE PERMISSION OR ACCESS MODE
Vpmv
 
04-1-Linux.ppt
04-1-Linux.ppt04-1-Linux.ppt
04-1-Linux.ppt
EidTahir
 
Basic Linux
Basic LinuxBasic Linux
Basic Linux
Tan Huynh Cong
 
Lession1 Linux Preview
Lession1 Linux PreviewLession1 Linux Preview
Lession1 Linux Preview
leminhvuong
 
Linux Security
Linux SecurityLinux Security
Linux Security
Mahdi Cherif
 
Access control list acl - permissions in linux
Access control list acl  - permissions in linuxAccess control list acl  - permissions in linux
Access control list acl - permissions in linux
Sreenatha Reddy K R
 
Basics of Linux
Basics of LinuxBasics of Linux
Basics of Linux
SaifUrRahman180
 
Unix Administration 3
Unix Administration 3Unix Administration 3
Unix Administration 3
Information Technology
 
Most frequently used unix commands for database administrator
Most frequently used unix commands for database administratorMost frequently used unix commands for database administrator
Most frequently used unix commands for database administrator
Dinesh jaisankar
 
OS Unit IV.ppt
OS Unit IV.pptOS Unit IV.ppt
OS Unit IV.ppt
FarhanaMariyam1
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
sbmguys
 
Linux Operating System. Unix_Lec-6.pptx
Linux Operating System.  Unix_Lec-6.pptxLinux Operating System.  Unix_Lec-6.pptx
Linux Operating System. Unix_Lec-6.pptx
HITENKHEMANI
 
File Access Permission
File Access PermissionFile Access Permission
File Access Permission
BIT DURG
 
File permissions
File permissionsFile permissions
File permissions
Varnnit Jain
 
Shell-Scripting-1.pdf
Shell-Scripting-1.pdfShell-Scripting-1.pdf
Shell-Scripting-1.pdf
aznabi
 
Basic Linux day 2
Basic Linux day 2Basic Linux day 2
Basic Linux day 2
Saikumar Daram
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
Harish R
 
101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3
Acácio Oliveira
 
06 users groups_and_permissions
06 users groups_and_permissions06 users groups_and_permissions
06 users groups_and_permissions
Shay Cohen
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
Lilesh Pathe
 

Similar to 4_Users_and_File_Permission_and_Directory_Commands (20)

FILE PERMISSION OR ACCESS MODE
 FILE PERMISSION OR ACCESS MODE FILE PERMISSION OR ACCESS MODE
FILE PERMISSION OR ACCESS MODE
 
04-1-Linux.ppt
04-1-Linux.ppt04-1-Linux.ppt
04-1-Linux.ppt
 
Basic Linux
Basic LinuxBasic Linux
Basic Linux
 
Lession1 Linux Preview
Lession1 Linux PreviewLession1 Linux Preview
Lession1 Linux Preview
 
Linux Security
Linux SecurityLinux Security
Linux Security
 
Access control list acl - permissions in linux
Access control list acl  - permissions in linuxAccess control list acl  - permissions in linux
Access control list acl - permissions in linux
 
Basics of Linux
Basics of LinuxBasics of Linux
Basics of Linux
 
Unix Administration 3
Unix Administration 3Unix Administration 3
Unix Administration 3
 
Most frequently used unix commands for database administrator
Most frequently used unix commands for database administratorMost frequently used unix commands for database administrator
Most frequently used unix commands for database administrator
 
OS Unit IV.ppt
OS Unit IV.pptOS Unit IV.ppt
OS Unit IV.ppt
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
 
Linux Operating System. Unix_Lec-6.pptx
Linux Operating System.  Unix_Lec-6.pptxLinux Operating System.  Unix_Lec-6.pptx
Linux Operating System. Unix_Lec-6.pptx
 
File Access Permission
File Access PermissionFile Access Permission
File Access Permission
 
File permissions
File permissionsFile permissions
File permissions
 
Shell-Scripting-1.pdf
Shell-Scripting-1.pdfShell-Scripting-1.pdf
Shell-Scripting-1.pdf
 
Basic Linux day 2
Basic Linux day 2Basic Linux day 2
Basic Linux day 2
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
 
101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3
 
06 users groups_and_permissions
06 users groups_and_permissions06 users groups_and_permissions
06 users groups_and_permissions
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
 

More from Gautam Raja

5_Practice_Exercise_-_1
5_Practice_Exercise_-_15_Practice_Exercise_-_1
5_Practice_Exercise_-_1
Gautam Raja
 
4_Unix_Command_Usage_-_3
4_Unix_Command_Usage_-_34_Unix_Command_Usage_-_3
4_Unix_Command_Usage_-_3
Gautam Raja
 
3_Unix_Command_Usage_-_2
3_Unix_Command_Usage_-_23_Unix_Command_Usage_-_2
3_Unix_Command_Usage_-_2
Gautam Raja
 
2_Unix_Command_Usage_-_1
2_Unix_Command_Usage_-_12_Unix_Command_Usage_-_1
2_Unix_Command_Usage_-_1
Gautam Raja
 
1_Introduction_to_shell
1_Introduction_to_shell1_Introduction_to_shell
1_Introduction_to_shell
Gautam Raja
 
3_Use_of_WinSCP
3_Use_of_WinSCP3_Use_of_WinSCP
3_Use_of_WinSCP
Gautam Raja
 
2_Connecting_to_Unix_Server
2_Connecting_to_Unix_Server2_Connecting_to_Unix_Server
2_Connecting_to_Unix_Server
Gautam Raja
 
1_Introduction_To_Unix_and_Basic_Unix_Commands
1_Introduction_To_Unix_and_Basic_Unix_Commands1_Introduction_To_Unix_and_Basic_Unix_Commands
1_Introduction_To_Unix_and_Basic_Unix_Commands
Gautam Raja
 

More from Gautam Raja (8)

5_Practice_Exercise_-_1
5_Practice_Exercise_-_15_Practice_Exercise_-_1
5_Practice_Exercise_-_1
 
4_Unix_Command_Usage_-_3
4_Unix_Command_Usage_-_34_Unix_Command_Usage_-_3
4_Unix_Command_Usage_-_3
 
3_Unix_Command_Usage_-_2
3_Unix_Command_Usage_-_23_Unix_Command_Usage_-_2
3_Unix_Command_Usage_-_2
 
2_Unix_Command_Usage_-_1
2_Unix_Command_Usage_-_12_Unix_Command_Usage_-_1
2_Unix_Command_Usage_-_1
 
1_Introduction_to_shell
1_Introduction_to_shell1_Introduction_to_shell
1_Introduction_to_shell
 
3_Use_of_WinSCP
3_Use_of_WinSCP3_Use_of_WinSCP
3_Use_of_WinSCP
 
2_Connecting_to_Unix_Server
2_Connecting_to_Unix_Server2_Connecting_to_Unix_Server
2_Connecting_to_Unix_Server
 
1_Introduction_To_Unix_and_Basic_Unix_Commands
1_Introduction_To_Unix_and_Basic_Unix_Commands1_Introduction_To_Unix_and_Basic_Unix_Commands
1_Introduction_To_Unix_and_Basic_Unix_Commands
 

4_Users_and_File_Permission_and_Directory_Commands

  • 1. Document Number: Copy Number: TATA CONSULTANCY SERVICES PRE ILP – Unix LOUNGE Content Manual Version 1.0 March 2014
  • 2. DOCUMENT RELEASE NOTICE Notice No. Client Project Document details Name Version No. Author Description Revision details: Action taken (add/del/chg ) Preceding page No. New page No. Revision description Change Register serial numbers covered: The documents or revised pages are subject to document control. Please keep them up-to-date using the release notices from the distributor of the document. These are confidential documents. Unauthorised access or copying is prohibited. Approved by : ________________________________ Date: _________ Authorised by: ________________________________ Date: _________ TCS PreILP - Unix Lounge Content Manual – Ver. 1.0
  • 3. DOCUMENT REVISION LIST Client Project Document Name Release Notice Reference (for release) Rev. No. Revision date Revision description Page No. Prev page No. Action taken Addenda /New page Release Notice reference TCS PreILP - Unix Lounge Content Manual – Ver. 1.0
  • 4. CONTENTS CHAPTER 3 - UNIX USERS AND FILE PERMISSIONS......................................................V 3.1 Objective...........................................................................................................v 3.2 Course Content.................................................................................................v 3.2.1 Types of users in Unix...............................................................................v 3.2.2 Managing users and groups.....................................................................vi 3.2.3 File Permission: Ownerships level............................................................vi 3.2.4 File Permission Types (Mode).................................................................vii 3.2.5 Unix - File Permission / Access Modes...................................................vii 3.2.6 Changing Permissions (chmod)..............................................................viii 3.2.6.1 Using chmod in Symbolic Mode........................................................viii 3.2.6.2 Using chmod in Absolute(octal) Mode................................................ix 3.3 Video 3 : Users, File Permission ......................................................................x 3.4 Quiz Time..........................................................................................................x CHAPTER 4 - UNIX DIRECTORY COMMANDS..............................................................XI 4.1 Objective..........................................................................................................xii 4.2 Course Content................................................................................................xii 4.2.1 Introduction..............................................................................................xii 4.2.2 mkdir(make directory) command:...........................................................xii 4.2.3 cd (Change Directory) command:...........................................................xiii 4.2.4 cp command:...........................................................................................xiv 4.2.5 mv Command:.........................................................................................xiv 4.2.6 rmdir(remove directory) command:.........................................................xv 4.2.7 rm (remove files) command: ...................................................................xv 4.2.8 Video 4: Directory commands.................................................................xvi 4.3 Quiz Time.......................................................................................................xvi
  • 5. CHAPTER 3 - UNIX USERS AND FILE PERMISSIONS 3.1 Objective To understand about the different users in UNIX and their access rights. 3.2 Course Content  Type of users  File permissions  Changing permissions using symbolic mode  Changing permissions using octal mode 3.2.1 Types of users in Unix There are three types of accounts on a Unix system: - Root Account - System Account - User Account Root System User ● This is also called superuser and would have complete and unfettered control of the system. ● A superuser can run any commands without any restriction. This user should be assumed as a system administrator. ● System accounts are those needed for the operation of system- specific components for example mail accounts and the sshd accounts. ● These accounts are usually needed for some specific function on your system, and any modifications to them could adversely affect the system. ● User accounts provide interactive access to the system for users and groups of users. ● General users are typically assigned to these accounts and usually have limited access to critical system files and directories.
  • 6. 3.2.2 Managing users and groups  Unix supports a concept of Group which logically groups a number of accounts.  Every account would be a part of any group.  Unix groups plays important role in handling file permissions and process management.  Grouping of users allows to grant and revoke file permissions collectively. /etc/passwd: Keeps user account and password information. /etc/shadow: Holds the encrypted password of the corresponding account. Not all the system support this file. /etc/group: This file contains the group information for each account. /etc/gshadow: This file contains secure group account information. 3.2.3 File Permission: Ownerships level File ownership is an important component of Unix that provides a secure method for storing files. Every file in Unix has the following attributes: Permission Symbol Description Owner Permissions u The owner's permissions determine what actions the owner of the file can perform on the file. Group Permissions g The group's permissions determine what actions a user, who is a member of the group that a file belongs to, can perform on the file. Other Permissions o The permissions for others indicate what action all other users can perform on the file.
  • 7. 3.2.4 File Permission Types (Mode) Three type of permissions can be set any ownership level: Read, Write and Execute  Three modes or permissions have different meaning for file and directory; 3.2.5 Unix - File Permission / Access Modes Consider the output of the command ls -l  Out of 9 columns in output, 1st column indicates the file type and its permissions.  This Column contains 10 characters.  Character 1 : Represents File Type ( 'd' : Directory; '-' : Regular File )  Character 2-4 : Represents Permission for owner(user) of file  Character 5-7 : Represents Permission for group user belongs to.  Character 8-10 : Represents Permission for other Mode Sym bol For File For Directory Read r Allows to view the content Allows to view the directory content using ls command Write w Allows edit and save changes. Create and delete files in the directory Execute x Allows to run program or script Allows to access the files in the directory
  • 8. 3.2.6 Changing Permissions (chmod) To change file or directory permissions, the chmod (change mode) command is used. There are two ways to use chmod:  Symbolic mode  Absolute mode chmod command options: 3.2.6.1 Using chmod in Symbolic Mode With symbolic representation, permission set can be added, deleted, or specified using the operators in the following table: For example, to give everyone execute permission for a file, you can use : $chmod ugo+x filename or $chmod a+x filename For example, to remove execute permission from others and retain the Syntax: $ chmod [OPTION] MODE FILENAME $ chmod [OPTION] OCTAL-MODE FILENAME -f, --silent, --quiet suppress most error messages -R, --recursive change files and directories recursively --help display this help and exit chmod operators Description + Adds the designated permission(s) to a file or directory. - Removes the designated permission(s) from a file or directory. = Sets the designated permission(s).
  • 9. existing permissions for all for a file, you can use : $chmod o-x filename In the above example, $ chmod u+wx,g+wx abc , adds execute permission to user and group to the file abc $ chmod g-x abc, removes execute permission from group from the file abc. $ chmod o=r-- abc, provides read permission and removes write and execute permission from others for file abc 3.2.6.2 Using chmod in Absolute(octal) Mode  The second way to modify permissions with the chmod command is to use a number to specify each set of permissions for the file.  Each permission is assigned a value, as the following table shows, and the total of each set of permissions provides a number for that set.
  • 10. Examples: -bash-3.2$ ls -l abc -rw-r--r-- 1 735873 oinstall 0 Feb 7 12:37 abc -bash-3.2$ chmod 0 abc -bash-3.2$ ls -l abc ---------- 1 735873 oinstall 0 Feb 7 12:37 abc -bash-3.2$ chmod 743 abc -bash-3.2$ ls -l abc -rwxr---wx 1 735873 oinstall 0 Feb 7 12:37 abc -bash-3.2$ chmod 755 abc -bash-3.2$ ls -l abc -rwxr-xr-x 1 735873 oinstall 0 Feb 7 12:37 abc -bash-3.2$ chmod 777 abc -bash-3.2$ ls -l abc -rwxrwxrwx 1 735873 oinstall 0 Feb 7 12:37 abc 3.3 Video 3 : Users, File Permission http://www.youtube.com/watch?v=zRw0SKaXSfI 3.4 Quiz Time Q1. Which is the superuser for Unix A. system B. root Number Octal Permission Representation Ref 0 No permission --- 1 Execute permission --x 2 Write permission -w- 3 Execute and write permission: 1 (execute) + 2 (write) = 3 -wx 4 Read permission r-- 5 Read and execute permission: 4 (read) + 1 (execute) = 5 r-x 6 Read and write permission: 4 (read) + 2 (write) = 6 rw- 7 All permissions: 4 (read) + 2 (write) + 1 (execute) = 7 rwx
  • 11. C. all users D. there's no such user Answer :B Q2. What is stored in the /etc/passwd file? A. user account information B. user password C. Both A and B D. password configuration details Answer: C Q3. Which command is used to change the file permissions in Unix? A. perm B. sysconfig C. systemconfig D. chmod Answer: D Q4. Unix logically groups the users. A. True B. False C. Not completely D. Sometimes Answer: A CHAPTER 4 - UNIX DIRECTORY COMMANDS 4.1 Objective  To provide overview of the most common commands to work with directories. These commands are available on any Linux (or Unix) system. 4.2 Course Content The commands discussed include:  mkdir  cd
  • 12.  cp  mv  rmdir  rm 4.2.1 Introduction What is a directory? When a user interacts with the UNIX shell, the shell considers the user to be located somewhere within a filesystem. Every item in the UNIX filesystem tree is either a file, or a directory. A directory is like a file folder. A directory can contain files, and other directories. A directory contained within another is called the child of the other. A directory in the filesystem tree may have many children, but it can only have one parent. A file can hold information, but cannot contain other files, or directories. A directory is actually implemented as a file that has one line for each item contained within the directory. Each line in a directory file contains only the name of the item, and a numerical reference to the location of the item. The reference is called an i-number(inode), and is an index to a table known as thei-list. The i-list is a complete list of all the storage space available to the file system. The place in the file system tree where an user is located is called the current working directory.  A file in unix file system which contains information about other files .  It contains information about files and directories through which UNIX looks up to obtain information about a particular file.  As we login, we are put in our home directory.  At a time where the user is located is called the current working directory. 4.2.2 mkdir(make directory) command: The mkdir command creates a directory with specified name in the present working directory or specified path. Syntax: $ mkdir <dir_name> [ <dir_name2> ]
  • 13. 4.2.3 cd (Change Directory) command: cd command provides navigation between directories. $ cd / : Takes you to root directory $ cd ~ : Takes you to home Directory (/home/userid) $ cd .. : Takes you to current parent Directory $ cd <dir_name> : Takes you to the desired directory $ mkdir Games $ ls Games $ $ mkdir Games/Indoor Games/Outdoor $ ls Games Indoor Outdoor $ The above command creates two directories, Indoor and Outdoor in specified path under Games $ pwd /home/amit $ cd / $ pwd / $ $ pwd $ / $ cd ~ $ pwd /home/amit $ $ pwd /home/amit $ cd .. $ pwd /home $
  • 14. 4.2.4 cp command: The command cp with -r option copies a directory and all its contents(sub- directory and files) recursively to another. Syntax: cp -r <source_directory> <destination_path> 4.2.5 mv Command: Moves the contents of a file or directory. If the source and destination path is same it renames the file or directory. Syntax: $ mv <source_dir> <destination_dir> $ pwd /home $ cd amit $ pwd /home/amit $cd Games/Indoor $ pwd /home/amit/Games/Indoor $ ls Dir1 Games $ cp -r Games Dir1 $ ls Dir1 Games $ ls Dir1 Games Copies Games into Dir1 Directory Dir1 now contains a copy of Games One copy of Games still exist in source path $ ls Dir1 Games $ mv Games Sports $ ls Dir1 Sports $ mv Sports Dir1 $ ls Dir1 Games Sports $ ls Dir1 $ Command mv renames Games to Sports Now Directory Sports moved into Dir1
  • 15. 4.2.6 rmdir(remove directory) command: To remove any existing empty directory. Syntax: rmdir <dir_name> Remark: To delete a Directory with content/which is not empty rm command can be used. Syntax: rm -R /path 4.2.7 rm (remove files) command: Removes existing files and directories. Syntax: rm filename Remark: The file being deleted may contain important information,so “-i” option is recommended to be used along with rm command. $ ls Dir1 Games $ ls Games Indoor Outdoor $ rmdir Games rmdir: Directory not empty $ rmdir Games/Indoor $ rmdir Games/Outdoor $ rmdir Games $ ls Dir1 $ Directory can be removed only if it is empty Contents of Games removed Directory Games removed now List the file in current directory Interactive Deletion Performed File testRm is removed
  • 16. 4.2.8 Video 4: Directory commands http://www.youtube.com/watch?v=VPgrtk0HQB0&list=PL8A83A276F0D85E70 http://www.youtube.com/watch?v=HsBEzs6Q7w4&list=PL8A83A276F0D85E70 4.3 Quiz Time Q1. Which command in Unix will help in creating new directories? A. mkdir B. makedir C. create D. new Answer: A Q2. Which command will help in deleting an empty directory? A. delete B. deletedir C. remove D. rmdir
  • 17. Answer: D Q3. Which command will help in moving a directory? A. move B. dirmover C. mv D. mvdir Answer: C Q4. Which command is used to rename a directory? A. rename B. changename C. remdir D. mv Answer: D Q5. Which option when used with cp will copy an directory will all its contents? A. -R B. -a C. -m D. -f Answer: A