SlideShare a Scribd company logo
1 of 36
Day 2
Unix Fundamental &
Name of
Commands
presentation
Ananthi Murugesan
• Company name
Module 1

Module 1
Unix Basic Commands

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

2
The Online Manual
Syntax:
man –[k|X] keyword

in which X is the number of one of the
manual sections
Examples:
$ man ls
Display the “ls" man page.
$ man -k cat Display entries with keyword "cat".
$ man passwd Display the "passwd" man page-Section 1.
$ man 4 passwd Display the "passwd" man page-Section 4.

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Getting help about commands
The Unix manual, usually called man pages, is available on-line
to explain the usage of the Unix system and commands.
How to use
Syntax:
man [options] command_name
Common Options
-k keyword list command synopsis line for all keyword
matches
-M path path to man pages
-a show all matching man pages (SVR4)
info command_name - help for the internal commands
help -– command_name– gives command synatx

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Id command

Syntax:
id
Displays effective user and
group identification for session

Example:
$id
uid =303 (user3) gid=300 (class)

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Who & whoami
Syntax:
who

Reports information about users who are
currently logged on to a system

Examples:
$ who
root
tty1p5 Jul 01 08:01
user11 tty1p4 Jul 01 09:59
user12 tty0p3 Jul 01 10:01
$ who am i
user12 tty0p3 Jul 01 10:01
$ whoami
user12
www.ananthim.wordpress.com

Author :- Ananthi Murugesan
The cal command

Syntax:
cal Reports the calendar of 2005 September(Current
month)

Example:
$ cal 8 2005 for Aug 2005
$ cal 2005 for the full calendar of year 2005

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
The Finger command
Finger: Displays information about the users
currently logged on

Eg:
$ finger user1

Login name: user1
Directory: /export/home/user1 shell:/usr/bin/sh
On since Sep 05 09:10:12 on tty1
No plan

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
The password Command

Syntax:
passwd Assigns a login password

Example:
$ passwd
Changing password for user1
Old password:
New password:
Re-enter new password:

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

9
The clear Command

Syntax:
clear

Clears terminal
screen

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

10
Module 2
File System

11
What Is a File System?
Collection of control structures and Data blocks that occupy
the space defined by a partition and allow for the storage
and management of data.

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

12
File Types
Common File Types
Ordinary files: regular files

Directory files: table of contents, that stores a list of
files/directories within that directory
Device files: For every device there is a device file used by
kernel to interact with the device.
Symbolic Link: Its link to other files

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

13
Ordinary Files

A regular file simply holds data.
Regular files can hold ASCII text, binary data, image data,
databases, application-related data, and more.

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

14
Directory Files

Directory
name inum
d1 4
f1 10

Inode Table
# type mode links user group
4 dir 755 2
user1 group1
10 file 644 1
user1 group1

www.ananthim.wordpress.com

date
Sep 5 9:30
Sep 5 9:45

size
512
12

Author :- Ananthi Murugesan

loc

15
Symbolic Links
contains the path of the file to which it links
Exists even after the source file is removed and is exactly
similar to Windows shortcut

Syntax: ln –s sourcefile linkfile
Eg: ln -s /f1 f1.lnk

Overcomes 2 limitations of Hard Link:
1. possible across filesystems
2. can link to a directory

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

16
Device files

A device file provides access to a device.

# cd /devices/pci@1f,0/pci@1,1/ide@3
# ls -l
brw------- 1 root sys 136, 0 Apr 3 11:11 dad@0,0:a
Two types of device files:
block device files
character device file

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

17
Listing the directory contents

ls
Syntax
ls [options] [file….]
Options
-l
list in long format
-a
list all file including those
beginning with a dot
-i
list node no of file in first column
-s
reports disk blocks occupied by file
-R
recursively list all sub
-F
mark type of each file
-C
display files in columns

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Meta characters
• 0 or more characters
?

1 character

[-]

matches any one character between the brackets

[^ ]

not matches any one character in the brackets

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Module 3
Managing Files
www.ananthim.wordpress.com

Author :- Ananthi Murugesan

20
Files & Directories - Objectives

File Permissions
Directory Related Commands
File Related Commands

Introduction to editors

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
File access permissions

• Refers to the permissions associated with a
file with respect to the following
• Permission Levels
– User (owner) (u)
– Group (wheel, staff, daemon, etc.) (g)
– World (guest, anonymous and all other
users) (o)
www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Permission settings

Permission Settings

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Changing permissions - chmod
chmod u+x file_name
Syntax:

chmod <category> <operation> <permission>
<filename(s)>
Or
chmod <octal number> filename
Eg - chmod 755 result.txt
Octal Number
Read(r) = 4
Write(W) = 2
Execute (X) = 1
www.ananthim.wordpress.com

Author :- Ananthi Murugesan
$ ls –l
-rwxr-xr-x
-rwxr-xr-x
drwxr-xr-x
-rwxr--r-x

1user1 training
3 user1 faculty
3 user1 faculty
3 user1 faculty

12373 Dec 15 14:45 a.out
4096 Dec 15 11:56 awkpro
4096 Dec 15 11:56 test
4096 Dec 15 11:56 latest

Owner Groups

Others

File Type

www.ananthim.wordpress.com

Meaning

-

Ordinary File

D

Directory File

C

Character
Special File

B

Block Special
File

L

drwxr-xr-x

File Type

Symbolic special
File

Author :- Ananthi Murugesan
Changing permissions - Calculation

In case we need to set the full access for the owner and read
and Execute for the user for the groups and other
Here is the calculation
( read = 4 )+( Write = 3 )+( Execute = 1 ) - 7

( read = 4 )+( Write = 0 )+( Execute = 1 ) - 5
( read = 4 )+( Write = 0 )+( Execute = 1 ) - 5
So to change the file permission we need to set the chmod
value as 755
Eg , chmod 755 result.txt

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Directory creation

Command Syntax
mkdir [OPTION] DIRECTORY
$mkdir <path>/<directory>
$mkdir –m <directory>
$mkdir –p <directory1>/<directory2>/<directory3>
Example:
◦mkdir project1
This creates a directory project1 under current directory
Note:
Write and execute permissions are needed for the user to
create a directory
www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Directory Removal

rmdir command removes directory
Syntax
– rmdir <directory name>
Example
Removes project1 directory in the current directory
rmdir project1
Remove multiple directories
rmdir pos1 pos2
Remove the directory recursively
rmdir –p dir1/dir2/dir2
Rule: rmdir can be executed to a directory if it is empty and
not the current directory
www.ananthim.wordpress.com

Author :- Ananthi Murugesan
File Related Commands
File operation

Commands

Copying File

cp

Moving a file

mv

Removing a file

rm

Displaying a file

cat

Prints the first few line of the file

head

Prints the last few line of the file

tail

Display the file at one successful screen

more

Cut out the selected fields of each line of a file

Cut

Merge lined of the file

paste

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Commands - cp
Used to copy files across directories
Syntax
cp <source file> <new file name>
Example
cp file1 file2
Note:
cp -r /dev/tty myfile
-r
Recursive copy; copy subdirectories under the
directory if any
-f
force

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Commands – rm

Used to remove a file
Syntax
rm file

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Commands – cat
Reads one or more files and prints them to the standard
output
Syntax
cat <redirection operator> <file name>
EX: cat filename.txt Displays the file content
-n -> print the line numbers
-b -> no number for non empty lines
-s -> suppress the repeated blank lines
Operators:
> - overwrite existing content of file
>> - appends the content with new content
www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Commands – head/tail
head:
-n -> n lines from top
head -23 file -> 23 lines from top
head –n -23 -> prints total – 23 lines i.e., prints all lines
except 23 lines from end of file.
-c 23 -> prints 23 bytes from top
tail:
-c 23 -> prints 23 bytes from bottom
-n -> n lines from bottom
-n +23 -> prints from 23rd line to till end
-n -23 -> prints 23 lines from last(reverse direction count)
head -23 file | tail -5 -> prints 5 lines from 23 lines

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Commands – more/less
More:
More is a filter for paging through text one
screenful at a time.

EX: more filename
less:
Opposite of more
Less is a program similar to more (1), but which allows
backward movement in the file as well as forward
movement. Also, less does not have to read the entire
input file before starting, so with large input files it starts
up faster than text editors like vi.
EX: less filename.txt
www.ananthim.wordpress.com

Author :- Ananthi Murugesan
cut command

Used to cut fields from each line of a file or columns of a table
cut –d: -f1,5 /etc/passwd
cut –c2 test
second character of each line
cut –c-2 test
first 2 characters of each line

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

35
Unix - Stop and Think

Do you have any questions ?

Catch me @ www.ananthim.wordpress.com

More Related Content

Viewers also liked

LDAP - Lightweight Directory Access Protocol
LDAP - Lightweight Directory Access ProtocolLDAP - Lightweight Directory Access Protocol
LDAP - Lightweight Directory Access ProtocolS. Hasnain Raza
 
Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems senthilamul
 
7th sem it_CSVTU
7th sem it_CSVTU7th sem it_CSVTU
7th sem it_CSVTUnksharma128
 
Ldap system administration
Ldap system administrationLdap system administration
Ldap system administrationAli Abdo
 
Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab FileKandarp Tiwari
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Noé Fernández-Pozo
 
Grep - A powerful search utility
Grep - A powerful search utilityGrep - A powerful search utility
Grep - A powerful search utilityNirajan Pant
 
Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrepTri Truong
 
Hill-climbing #2
Hill-climbing #2Hill-climbing #2
Hill-climbing #2Mohamed Gad
 
Linux 101-hacks
Linux 101-hacksLinux 101-hacks
Linux 101-hacksshekarkcb
 
Hillclimbing search algorthim #introduction
Hillclimbing search algorthim #introductionHillclimbing search algorthim #introduction
Hillclimbing search algorthim #introductionMohamed Gad
 
Unix
UnixUnix
UnixErm78
 

Viewers also liked (18)

LDAP - Lightweight Directory Access Protocol
LDAP - Lightweight Directory Access ProtocolLDAP - Lightweight Directory Access Protocol
LDAP - Lightweight Directory Access Protocol
 
Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems
 
Unix File System
Unix File SystemUnix File System
Unix File System
 
Unix training session 1
Unix training   session 1Unix training   session 1
Unix training session 1
 
Unix - Filters/Editors
Unix - Filters/EditorsUnix - Filters/Editors
Unix - Filters/Editors
 
7th sem it_CSVTU
7th sem it_CSVTU7th sem it_CSVTU
7th sem it_CSVTU
 
Grep
GrepGrep
Grep
 
Learning Grep
Learning GrepLearning Grep
Learning Grep
 
Ldap system administration
Ldap system administrationLdap system administration
Ldap system administration
 
Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab File
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
 
Grep - A powerful search utility
Grep - A powerful search utilityGrep - A powerful search utility
Grep - A powerful search utility
 
Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrep
 
Hill-climbing #2
Hill-climbing #2Hill-climbing #2
Hill-climbing #2
 
Linux 101-hacks
Linux 101-hacksLinux 101-hacks
Linux 101-hacks
 
Hillclimbing search algorthim #introduction
Hillclimbing search algorthim #introductionHillclimbing search algorthim #introduction
Hillclimbing search algorthim #introduction
 
Unix
UnixUnix
Unix
 
Basic Unix
Basic UnixBasic Unix
Basic Unix
 

Recently uploaded

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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 WorkerThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Recently uploaded (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Unix Basic Commands

  • 1. Day 2 Unix Fundamental & Name of Commands presentation Ananthi Murugesan • Company name
  • 2. Module 1 Module 1 Unix Basic Commands www.ananthim.wordpress.com Author :- Ananthi Murugesan 2
  • 3. The Online Manual Syntax: man –[k|X] keyword in which X is the number of one of the manual sections Examples: $ man ls Display the “ls" man page. $ man -k cat Display entries with keyword "cat". $ man passwd Display the "passwd" man page-Section 1. $ man 4 passwd Display the "passwd" man page-Section 4. www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 4. Getting help about commands The Unix manual, usually called man pages, is available on-line to explain the usage of the Unix system and commands. How to use Syntax: man [options] command_name Common Options -k keyword list command synopsis line for all keyword matches -M path path to man pages -a show all matching man pages (SVR4) info command_name - help for the internal commands help -– command_name– gives command synatx www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 5. Id command Syntax: id Displays effective user and group identification for session Example: $id uid =303 (user3) gid=300 (class) www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 6. Who & whoami Syntax: who Reports information about users who are currently logged on to a system Examples: $ who root tty1p5 Jul 01 08:01 user11 tty1p4 Jul 01 09:59 user12 tty0p3 Jul 01 10:01 $ who am i user12 tty0p3 Jul 01 10:01 $ whoami user12 www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 7. The cal command Syntax: cal Reports the calendar of 2005 September(Current month) Example: $ cal 8 2005 for Aug 2005 $ cal 2005 for the full calendar of year 2005 www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 8. The Finger command Finger: Displays information about the users currently logged on Eg: $ finger user1 Login name: user1 Directory: /export/home/user1 shell:/usr/bin/sh On since Sep 05 09:10:12 on tty1 No plan www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 9. The password Command Syntax: passwd Assigns a login password Example: $ passwd Changing password for user1 Old password: New password: Re-enter new password: www.ananthim.wordpress.com Author :- Ananthi Murugesan 9
  • 10. The clear Command Syntax: clear Clears terminal screen www.ananthim.wordpress.com Author :- Ananthi Murugesan 10
  • 12. What Is a File System? Collection of control structures and Data blocks that occupy the space defined by a partition and allow for the storage and management of data. www.ananthim.wordpress.com Author :- Ananthi Murugesan 12
  • 13. File Types Common File Types Ordinary files: regular files Directory files: table of contents, that stores a list of files/directories within that directory Device files: For every device there is a device file used by kernel to interact with the device. Symbolic Link: Its link to other files www.ananthim.wordpress.com Author :- Ananthi Murugesan 13
  • 14. Ordinary Files A regular file simply holds data. Regular files can hold ASCII text, binary data, image data, databases, application-related data, and more. www.ananthim.wordpress.com Author :- Ananthi Murugesan 14
  • 15. Directory Files Directory name inum d1 4 f1 10 Inode Table # type mode links user group 4 dir 755 2 user1 group1 10 file 644 1 user1 group1 www.ananthim.wordpress.com date Sep 5 9:30 Sep 5 9:45 size 512 12 Author :- Ananthi Murugesan loc 15
  • 16. Symbolic Links contains the path of the file to which it links Exists even after the source file is removed and is exactly similar to Windows shortcut Syntax: ln –s sourcefile linkfile Eg: ln -s /f1 f1.lnk Overcomes 2 limitations of Hard Link: 1. possible across filesystems 2. can link to a directory www.ananthim.wordpress.com Author :- Ananthi Murugesan 16
  • 17. Device files A device file provides access to a device. # cd /devices/pci@1f,0/pci@1,1/ide@3 # ls -l brw------- 1 root sys 136, 0 Apr 3 11:11 dad@0,0:a Two types of device files: block device files character device file www.ananthim.wordpress.com Author :- Ananthi Murugesan 17
  • 18. Listing the directory contents ls Syntax ls [options] [file….] Options -l list in long format -a list all file including those beginning with a dot -i list node no of file in first column -s reports disk blocks occupied by file -R recursively list all sub -F mark type of each file -C display files in columns www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 19. Meta characters • 0 or more characters ? 1 character [-] matches any one character between the brackets [^ ] not matches any one character in the brackets www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 21. Files & Directories - Objectives File Permissions Directory Related Commands File Related Commands Introduction to editors www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 22. File access permissions • Refers to the permissions associated with a file with respect to the following • Permission Levels – User (owner) (u) – Group (wheel, staff, daemon, etc.) (g) – World (guest, anonymous and all other users) (o) www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 24. Changing permissions - chmod chmod u+x file_name Syntax: chmod <category> <operation> <permission> <filename(s)> Or chmod <octal number> filename Eg - chmod 755 result.txt Octal Number Read(r) = 4 Write(W) = 2 Execute (X) = 1 www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 25. $ ls –l -rwxr-xr-x -rwxr-xr-x drwxr-xr-x -rwxr--r-x 1user1 training 3 user1 faculty 3 user1 faculty 3 user1 faculty 12373 Dec 15 14:45 a.out 4096 Dec 15 11:56 awkpro 4096 Dec 15 11:56 test 4096 Dec 15 11:56 latest Owner Groups Others File Type www.ananthim.wordpress.com Meaning - Ordinary File D Directory File C Character Special File B Block Special File L drwxr-xr-x File Type Symbolic special File Author :- Ananthi Murugesan
  • 26. Changing permissions - Calculation In case we need to set the full access for the owner and read and Execute for the user for the groups and other Here is the calculation ( read = 4 )+( Write = 3 )+( Execute = 1 ) - 7 ( read = 4 )+( Write = 0 )+( Execute = 1 ) - 5 ( read = 4 )+( Write = 0 )+( Execute = 1 ) - 5 So to change the file permission we need to set the chmod value as 755 Eg , chmod 755 result.txt www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 27. Directory creation Command Syntax mkdir [OPTION] DIRECTORY $mkdir <path>/<directory> $mkdir –m <directory> $mkdir –p <directory1>/<directory2>/<directory3> Example: ◦mkdir project1 This creates a directory project1 under current directory Note: Write and execute permissions are needed for the user to create a directory www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 28. Directory Removal rmdir command removes directory Syntax – rmdir <directory name> Example Removes project1 directory in the current directory rmdir project1 Remove multiple directories rmdir pos1 pos2 Remove the directory recursively rmdir –p dir1/dir2/dir2 Rule: rmdir can be executed to a directory if it is empty and not the current directory www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 29. File Related Commands File operation Commands Copying File cp Moving a file mv Removing a file rm Displaying a file cat Prints the first few line of the file head Prints the last few line of the file tail Display the file at one successful screen more Cut out the selected fields of each line of a file Cut Merge lined of the file paste www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 30. Commands - cp Used to copy files across directories Syntax cp <source file> <new file name> Example cp file1 file2 Note: cp -r /dev/tty myfile -r Recursive copy; copy subdirectories under the directory if any -f force www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 31. Commands – rm Used to remove a file Syntax rm file www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 32. Commands – cat Reads one or more files and prints them to the standard output Syntax cat <redirection operator> <file name> EX: cat filename.txt Displays the file content -n -> print the line numbers -b -> no number for non empty lines -s -> suppress the repeated blank lines Operators: > - overwrite existing content of file >> - appends the content with new content www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 33. Commands – head/tail head: -n -> n lines from top head -23 file -> 23 lines from top head –n -23 -> prints total – 23 lines i.e., prints all lines except 23 lines from end of file. -c 23 -> prints 23 bytes from top tail: -c 23 -> prints 23 bytes from bottom -n -> n lines from bottom -n +23 -> prints from 23rd line to till end -n -23 -> prints 23 lines from last(reverse direction count) head -23 file | tail -5 -> prints 5 lines from 23 lines www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 34. Commands – more/less More: More is a filter for paging through text one screenful at a time. EX: more filename less: Opposite of more Less is a program similar to more (1), but which allows backward movement in the file as well as forward movement. Also, less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi. EX: less filename.txt www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 35. cut command Used to cut fields from each line of a file or columns of a table cut –d: -f1,5 /etc/passwd cut –c2 test second character of each line cut –c-2 test first 2 characters of each line www.ananthim.wordpress.com Author :- Ananthi Murugesan 35
  • 36. Unix - Stop and Think Do you have any questions ? Catch me @ www.ananthim.wordpress.com