SlideShare una empresa de Scribd logo
1 de 36
Day 2
Unix Fundamental &
Name of
Commands
presentation
Ananthi Murugasen
• Company name
Module 1

Module 1
Unix Basic Commands

www.ananthim.wordpress.com

Author :- Ananthi Murugasen

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 Murugasen
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 Murugasen
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 Murugasen
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 Murugasen
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 Murugasen
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 Murugasen
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 Murugasen

9
The clear Command

Syntax:
clear

Clears terminal
screen

www.ananthim.wordpress.com

Author :- Ananthi Murugasen

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 Murugasen

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 Murugasen

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 Murugasen

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 Murugasen

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 Murugasen

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 Murugasen

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 Murugasen
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 Murugasen
Module 3
Managing Files
www.ananthim.wordpress.com

Author :- Ananthi Murugasen

20
Files & Directories - Objectives

File Permissions
Directory Related Commands
File Related Commands

Introduction to editors

www.ananthim.wordpress.com

Author :- Ananthi Murugasen
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 Murugasen
Permission settings

Permission Settings

www.ananthim.wordpress.com

Author :- Ananthi Murugasen
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 Murugasen
$ 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 Murugasen
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 Murugasen
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 Murugasen
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 Murugasen
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 Murugasen
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 Murugasen
Commands – rm

Used to remove a file
Syntax
rm file

www.ananthim.wordpress.com

Author :- Ananthi Murugasen
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 Murugasen
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 Murugasen
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 Murugasen
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

35
Catch me @ www.ananthim.wordpress.com

Más contenido relacionado

Destacado

Petsil petrofisica
Petsil petrofisicaPetsil petrofisica
Petsil petrofisicafigempa uce
 
Ambiental Matematica i
Ambiental Matematica iAmbiental Matematica i
Ambiental Matematica ifigempa uce
 
Minas Geologia del ecuador
Minas Geologia del ecuadorMinas Geologia del ecuador
Minas Geologia del ecuadorfigempa uce
 
Petsil estadistica
Petsil estadisticaPetsil estadistica
Petsil estadisticafigempa uce
 
Petsil estadisticaaplicada
Petsil estadisticaaplicadaPetsil estadisticaaplicada
Petsil estadisticaaplicadafigempa uce
 
Petsil fisquimtermo
Petsil fisquimtermoPetsil fisquimtermo
Petsil fisquimtermofigempa uce
 
Geología general
Geología generalGeología general
Geología generalfigempa uce
 
Minas Mecánica de rocas 2
Minas Mecánica de rocas 2Minas Mecánica de rocas 2
Minas Mecánica de rocas 2figempa uce
 
บทคัดย่อรายงานการพัฒนาคู่มือการนิเทศการพัฒนาสถานศึกษาสู่สถานศึกษาพอเพียง
บทคัดย่อรายงานการพัฒนาคู่มือการนิเทศการพัฒนาสถานศึกษาสู่สถานศึกษาพอเพียงบทคัดย่อรายงานการพัฒนาคู่มือการนิเทศการพัฒนาสถานศึกษาสู่สถานศึกษาพอเพียง
บทคัดย่อรายงานการพัฒนาคู่มือการนิเทศการพัฒนาสถานศึกษาสู่สถานศึกษาพอเพียงNirut Uthatip
 

Destacado (12)

Petsil petrofisica
Petsil petrofisicaPetsil petrofisica
Petsil petrofisica
 
Ambiental Matematica i
Ambiental Matematica iAmbiental Matematica i
Ambiental Matematica i
 
Coplas de ciencias
Coplas de cienciasCoplas de ciencias
Coplas de ciencias
 
Petsil quimica1
Petsil quimica1Petsil quimica1
Petsil quimica1
 
Minas Geologia del ecuador
Minas Geologia del ecuadorMinas Geologia del ecuador
Minas Geologia del ecuador
 
Petsil estadistica
Petsil estadisticaPetsil estadistica
Petsil estadistica
 
Petsil estadisticaaplicada
Petsil estadisticaaplicadaPetsil estadisticaaplicada
Petsil estadisticaaplicada
 
Petsil fisquimtermo
Petsil fisquimtermoPetsil fisquimtermo
Petsil fisquimtermo
 
Geología general
Geología generalGeología general
Geología general
 
Minas Mecánica de rocas 2
Minas Mecánica de rocas 2Minas Mecánica de rocas 2
Minas Mecánica de rocas 2
 
บทคัดย่อรายงานการพัฒนาคู่มือการนิเทศการพัฒนาสถานศึกษาสู่สถานศึกษาพอเพียง
บทคัดย่อรายงานการพัฒนาคู่มือการนิเทศการพัฒนาสถานศึกษาสู่สถานศึกษาพอเพียงบทคัดย่อรายงานการพัฒนาคู่มือการนิเทศการพัฒนาสถานศึกษาสู่สถานศึกษาพอเพียง
บทคัดย่อรายงานการพัฒนาคู่มือการนิเทศการพัฒนาสถานศึกษาสู่สถานศึกษาพอเพียง
 
Smart work
Smart workSmart work
Smart work
 

Último

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
[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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
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
 

Último (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.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
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
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
 

Unix Basic Commands and Fundamentals

  • 1. Day 2 Unix Fundamental & Name of Commands presentation Ananthi Murugasen • Company name
  • 2. Module 1 Module 1 Unix Basic Commands www.ananthim.wordpress.com Author :- Ananthi Murugasen 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen 9
  • 10. The clear Command Syntax: clear Clears terminal screen www.ananthim.wordpress.com Author :- Ananthi Murugasen 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 Murugasen 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 Murugasen 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 Murugasen 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 Murugasen 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 Murugasen 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 Murugasen 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 Murugasen
  • 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 Murugasen
  • 21. Files & Directories - Objectives File Permissions Directory Related Commands File Related Commands Introduction to editors www.ananthim.wordpress.com Author :- Ananthi Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 31. Commands – rm Used to remove a file Syntax rm file www.ananthim.wordpress.com Author :- Ananthi Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 Murugasen
  • 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 35
  • 36. Catch me @ www.ananthim.wordpress.com