0% found this document useful (0 votes)
36 views25 pages

UNIT I Commands

This document provides an overview of Linux and system administration commands. It categorizes commands as general purpose, file system commands, filters, or system administration commands. It then discusses command syntax and provides examples. The document also covers topics like processes, text processing commands, and regular expressions. Key commands discussed include ls, cat, cp, mv, pwd, mkdir, rmdir, rm, ln, cal, who, more, grep, sort, comm, head, tail, wc, and diff.

Uploaded by

pooja0100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views25 pages

UNIT I Commands

This document provides an overview of Linux and system administration commands. It categorizes commands as general purpose, file system commands, filters, or system administration commands. It then discusses command syntax and provides examples. The document also covers topics like processes, text processing commands, and regular expressions. Key commands discussed include ls, cat, cp, mv, pwd, mkdir, rmdir, rm, ln, cal, who, more, grep, sort, comm, head, tail, wc, and diff.

Uploaded by

pooja0100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Linux and System Administration

CA304

BCA-V Semester

28/07/2023 CA304 Linux and System Administration 1


Learning Objectives
– Getting familiar with commands
– Handling directories and files
Commands of
UNIX/Linux
Categorized as follows-
General purpose
date, uname, more, echo, cal , who, cat
File system commands
wc, rm , rmdir, lp, diff, comm, cmp, file, mv, cp, mkdir,
Filters
grep
System administration commands
useradd, usermod, userdel, passwd, df , du, fdisk

28/07/2023 CA304 Linux and System Administration 3


Command Syntax
<Command name> <space> <options> <space> <arguments>
All commands in lower case
Space is used as a separator
Options are switches beginning with hyphen (-) and followed by one or two
letters.
Arguments are file(s). If more than one file, then separate using space.
Example

$ls [with no option and arg.]


$ls -l [with only option]
$ls -l -u [with two options]

28/07/2023 CA304 Linux and System Administration 4


Some commands would require to enter only the command name.
$> pwd
/home/ajit
 
Some commands have options which allow a detailed display.
$> ls -l
ls is a command in Unix to display the contents of the current directory.
Attaching an option l , displays in detail the contents.
 
Some commands have arguments which allow a display, as per user
requirement.
$> cal 01 2004
cal is a command to display the calendar information. The above statement
would display the calendar for January 2004. Here 01 and 2004 represents
arguments and are not options.
 

28/07/2023 CA304 Linux and System Administration 5


General LINUX
commands

28/07/2023 CA304 Linux and System Administration 6


General Unix Commands
• ls - List contents of a directory
• ls [option] [filenames] Microsoft Word
Document

• cat - Concatenate(s) and display files


• cat [option...] [file ...]
Microsoft Word
Document
General Unix Commands
• cp - Copy files
• cp [option...] [file1] [file2] Microsoft Word
Document

• mv - Move or rename files


• mv [option...] [file1] [file2] Microsoft Word
Document
General Unix Commands
• pwd - Display Working directory
Microsoft Word
• pwd Document

• cd - Change Working directory


• cd [Directory] Microsoft Word
Document
General Unix Commands
Microsoft Word
Document
• mkdir - Make Directories
• mkdir [options] DirectoryName
Microsoft Word
Document

• rmdir - Remove Directories


• rmdir [options] DirectoryName
General Unix Commands
Microsoft Word
Document
• rm - Remove files or directories
• rm [option...] file ...

Microsoft Word
• ln - Make link to files Document

• ln file1 [file2 ...] target


• Hard Link

• Soft Link

For Self Study: Understand the usage of Hard Link & Soft Link
General Unix Commands
Microsoft Word

• cal – Calendar
Document

• cal [options] [arguments]

Microsoft Word

• who – Displays the users logged on to the system


Document

• who [options]
General Unix Commands
Microsoft Word
Document
• more – Allows page wise display
• more [files]

Microsoft Word
Document
• whoami – Displays username
• whoami
Regular Expressions
What is it?
• String of ordinary and metacharacter which can be used to match more than
one type of pattern.
• Uses character set
• * , [], ^, $, {}, etc.

Microsoft Word
Document
The Shell Metacharacters.

• * - Matches all filenames in current directory.

• ? - Matches a single character.

• [abc] - Matches a single character – either a, b or


c.

• [!abc] - Matches a single character – which is not a,


b or c.

• [a-c] – Matches a single character which is within


Processes in Unix
Microsoft Word
Document
• Process:
• Instance of a program in execution (memory)
• Process related commands
• ps command
Text Processing
Commands

28/07/2023 CA304 Linux and System Administration 17


Text Processing Commands
• tr - Translate characters Microsoft Word
Document

• Translates character/characters.
• tr [option...] string1 [string2]

• cmp
• Compare 2 files. Microsoft Word
• cmp file1 file2 Document
Text Processing Commands
Microsoft Word
• cut Document

• Cuts selected fields of each line of a file.


• cut –flist [-d char] [file1 file2 ...]

Microsoft Word
Document

• paste
• Merging the corresponding lines of given files.
• paste file..
Text Processing Commands
• sort Microsoft Word
Document

• Ordered arrangement.
• sort [option] file

• comm
• Compares 2 sorted files. Microsoft Word
Document

• comm file1 file2


Text Processing Commands
• head
Microsoft Word
Document
• Display the first count lines of files.

• head [-count] [file ...]

• tail Microsoft Word


Document

• Display the last count lines of a file.

• tail [+/-[number] [lbc]] [option] file


Text Processing Commands
• wc
• Counts and displays the number of lines, words Microsoft Word
and characters in a file. Document

• wc [option...] filename...

• grep
Microsoft Word
• Pattern searching in a file. Document

• grep [option...] pattern [file...]


Text Processing Commands
• diff
• Reports the differences between files
• diff [option...] file1 file2 Microsoft Word
Document

Microsoft Word
Document
• uniq
• To remove adjacent repeated lines
• uniq [option] [file]
Can you answer these questions?
• Write a command-line to
• Count the number of files in the current directory

• Count the number of blank lines (lines without text) in a


file
• Display the first 10 lines in a file

• Display only the 4th line in a file

• What is the difference between


cat file1 file2 file3
&
paste file1 file2 file3
Thank you

28/07/2023 CA304 Linux and System Administration 25

You might also like