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
Di...
Getting help about commands
The Unix manual, usually called man pages, is available on-line
to explain the usage of the Un...
Id command

Syntax:
id
Displays effective user and
group identification for session

Example:
$id
uid =303 (user3) gid=300...
Who & whoami
Syntax:
who

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

Examples:
$ who
root
tt...
The cal command

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

Example:
$ cal 8 2005 for Aug 2005
$ c...
The Finger command
Finger: Displays information about the users
currently logged on

Eg:
$ finger user1

Login name: user1...
The password Command

Syntax:
passwd Assigns a login password

Example:
$ passwd
Changing password for user1
Old password:...
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 a...
File Types
Common File Types
Ordinary files: regular files

Directory files: table of contents, that stores a list of
file...
Ordinary Files

A regular file simply holds data.
Regular files can hold ASCII text, binary data, image data,
databases, a...
Directory Files

Directory
name inum
d1 4
f1 10

Inode Table
# type mode links user group
4 dir 755 2
user1 group1
10 file...
Symbolic Links
contains the path of the file to which it links
Exists even after the source file is removed and is exactly...
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 s...
Listing the directory contents

ls
Syntax
ls [options] [file….]
Options
-l
list in long format
-a
list all file includi...
Meta characters
• 0 or more characters
?

1 character

[-]

matches any one character between the brackets

[^ ]

not matc...
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 e...
File access permissions

• Refers to the permissions associated with a
file with respect to the following
• Permission Lev...
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...
$ 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

1237...
Changing permissions - Calculation

In case we need to set the full access for the owner and read
and Execute for the user...
Directory creation

Command Syntax
mkdir [OPTION] DIRECTORY
$mkdir <path>/<directory>
$mkdir –m <directory>
$mkdir –p <dir...
Directory Removal

rmdir command removes directory
Syntax
– rmdir <directory name>
Example
Removes project1 directory in t...
File Related Commands
File operation

Commands

Copying File

cp

Moving a file

mv

Removing a file

rm

Displaying a fil...
Commands - cp
Used to copy files across directories
Syntax
cp <source file> <new file name>
Example
cp file1 file2
Note:
c...
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...
Commands – head/tail
head:
-n -> n lines from top
head -23 file -> 23 lines from top
head –n -23 -> prints total – 23 line...
Commands – more/less
More:
More is a filter for paging through text one
screenful at a time.

EX: more filename
less:
Oppo...
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
seco...
Catch me @ www.ananthim.wordpress.com
Upcoming SlideShare
Loading in …5
×

Unix Basic Commands and Fundamentals

839 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
839
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Unix Basic Commands and Fundamentals

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

×