SlideShare uma empresa 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

Mais conteúdo relacionado

Destaque

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
 

Destaque (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

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
 
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
 
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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
[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
 
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
 
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
 
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
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Último (20)

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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech 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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
[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
 
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
 
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
 
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
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

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