SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Destaque

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
 

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

Último

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Último (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

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