0% found this document useful (0 votes)
96 views12 pages

Dhruv Pandit: Name: Class:Cba Enrolment No: Batch: Cse - 21

This document provides instructions and examples for various Linux commands used in shell scripting and operating systems. It lists 26 commands - ls, cat, mkdir, rmdir, history, chmod, touch, mv, link, grep, wc, echo, rm, cal, info, pwd, clear, cp, paste, sort, exit, cmp, diff, locate, head, and tail - and provides the syntax and examples of common options for each command. It was written by Dhruv Pandit for a class assignment on operating systems and shell scripting basics.

Uploaded by

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

Dhruv Pandit: Name: Class:Cba Enrolment No: Batch: Cse - 21

This document provides instructions and examples for various Linux commands used in shell scripting and operating systems. It lists 26 commands - ls, cat, mkdir, rmdir, history, chmod, touch, mv, link, grep, wc, echo, rm, cal, info, pwd, clear, cp, paste, sort, exit, cmp, diff, locate, head, and tail - and provides the syntax and examples of common options for each command. It was written by Dhruv Pandit for a class assignment on operating systems and shell scripting basics.

Uploaded by

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

U.V.

Patel College of Engineering


B. Tech Computer Science and Engineering
Sub: Basics of Operating System and Shell Scripting
(2CSE204)

NAME :DHRUV PANDIT

CLASS :CBA

ENROLMENT NO :16012101007

BATCH : CSE - 21

PRACTICAL 2:
1. Ls: list directory contents

List information about the FILEs (the current directory by default).


Sort entries alphabetically if none of -cftuvSUX nor --sort is speci
fied.

Syntax: ls [OPTION]... [FILE]...

-a, --all
do not ignore entries starting with .

-A, --almost-all
do not list implied . And ..

2.cat
concatenate files and print on the standard output
Concatenate FILE(s), or standard input, to standard output.

Syntax: cat [OPTION]... [FILE]...

-A, --show-all
equivalent to -vET

-b, --number-nonblank
number nonempty output lines, overrides -n

3.mkdir
Create the DIRECTORY(ies), if they do not already exist.

Mandatory arguments to long options are mandatory for short options


too.

Syntax: mkdir [OPTION]... DIRECTORY...

-m, --mode=MODE
set file mode (as in chmod), not a=rwx - umask

-p, --parents
no error if existing, make parent directories as needed

4.rmdir:remove empty directories


Remove the DIRECTORY(ies), if they are empty.

Syntax: rmdir [OPTION]... DIRECTORY...

--ignore-fail-on-non-empty

ignore each failure that is solely because a directory

is non-empty

-p, --parents
remove DIRECTORY and its ancestors; e.g., 'rmdir -p a/b/c' is
similar to 'rmdir a/b/c a/b a'

5.history
Many programs read input from the user a line at a time. The GNU His
tory library is able to keep track of those lines, associate arbitrary
data with each line, and utilize information from previous lines in
composing new ones.

6.chmod: change file mode bits


chmod changes the file mode bits of each given file according to mode, which can be
either a symbolic representation of changes to make, or an octal num
ber representing the bit pattern for the new mode bits.

Syntax:
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...

-c, --changes
like verbose but report only when a change is made

-f, --silent, --quiet


suppress most error messages

7.touch: change file timestamps


Update the access and modification times of each FILE to the current
time.

Syntax: touch [OPTION]... FILE...


-a change only the access time

-c, --no-create
do not create any files

8.mv - move (rename) files


Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Syntax:
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...

-b like --backup but does not accept an argument

-f, --force
do not prompt before overwriting

9.link - call the link function to create a link to a file


Call the link function to create a link named FILE2 to an existing
FILE1.

Syntax:
link FILE1 FILE2
link OPTION

--help display this help and exit

--version
output version information and exit

10.grep, egrep, fgrep, rgrep - print lines matching a pattern

grep searches the named input FILEs (or standard input if no files are
named, or if a single hyphen-minus (-) is given as file name) for
lines containing a match to the given PATTERN. By default, grep
prints the matching lines.

Syntax:
grep [OPTIONS] PATTERN [FILE...]
grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]

-E, --extended-regexp
Interpret PATTERN as an extended regular expression (ERE, see
below). (-E is specified by POSIX.)
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by
newlines, any of which is to be matched. (-F is specified by
POSIX.)

11. wc - print newline, word, and byte counts for each file

Print newline, word, and byte counts for each FILE, and a total line
if more than one FILE is specified. With no FILE, or when FILE is -,
read standard input. A word is a non-zero-length sequence of charac
ters delimited by white space. The options below may be used to
select which counts are printed, always in the following order: new
line, word, character, byte, maximum line length.

Syntax:
wc [OPTION]... [FILE]...
wc [OPTION]... --files0-from=F

-c, --bytes
print the byte counts

-m, --chars
print the character counts

12.echo - display a line of text

Echo the STRING(s) to standard output.

Syntax:
echo [SHORT-OPTION]... [STRING]...
echo LONG-OPTION

-n do not output the trailing newline

-e enable interpretation of backslash escapes

13. rm - remove files or directories

This manual page documents the GNU version of rm. rm removes each
specified file. By default, it does not remove directories.

Syntax:
rm [OPTION]... FILE...

-f, --force
ignore nonexistent files and arguments, never prompt
-i prompt before every removal

14.cal, ncal displays a calendar and the date of Easter

The cal utility displays a simple calendar in traditional format and


ncal offers an alternative layout, more options and the date of Easter.
The new format is a little cramped but it makes a year fit on a 25x80
terminal. If arguments are not specified, the current month is dis
played.

Syntax:
cal [-3hjy] [-A number] [-B number] [[month] year]
cal [-3hj] [-A number] [-B number] -m month [year]
ncal [-3bhjJpwySM] [-A number] [-B number] [-s country_code] [[month]
year]
ncal [-3bhJeoSM] [-A number] [-B number] [year]
ncal [-CN] [-H yyyy-mm-dd] [-d yyyy-mm]

-h Turns off highlighting of today.

-J Display Julian Calendar, if combined with the -o option, display


date of Orthodox Easter according to the Julian Calendar.

15. info - read Info documents

Read documentation in Info format.

Syntax:
info [OPTION]... [MENU-ITEM...]

-a, --all
use all matching manuals.

-k, --apropos=STRING
look up STRING in all indices of all manuals.

16. pwd - print name of current/working directory

Print the full filename of the current working directory.

Syntax:
pwd [OPTION]...

-L, --logical
use PWD from environment, even if it contains symlinks

-P, --physical
avoid all symlinks

17. clear - clear the terminal screen

clear clears your screen if this is possible, including its scrollback


buffer (if the extended "E3" capability is defined). clear looks in
the environment for the terminal type and then in the terminfo database
to determine how to clear the screen.

clear ignores any command-line parameters that may be present.


Syntax:
clear

18. cp - copy files and directories

Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

Syntax:
cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...

-a, --archive
same as -dR --preserve=all

--attributes-only
don't copy the file data, just the attributes

19. paste - merge lines of files

Write lines consisting of the sequentially corresponding lines from


each FILE, separated by TABs, to standard output. With no FILE, or
when FILE is -, read standard input.

Syntax:
paste [OPTION]... [FILE]...

-d, --delimiters=LIST
reuse characters from LIST instead of TABs

-s, --serial
paste one file at a time instead of in parallel

20.sort - sort lines of text files

Write sorted concatenation of all FILE(s) to standard output.


Syntax:
sort [OPTION]... [FILE]...
sort [OPTION]... --files0-from=F

-b, --ignore-leading-blanks
ignore leading blanks

-d, --dictionary-order
consider only blanks and alphanumeric characters

21. exit - cause normal process termination


The exit() function causes normal process termination and the value of
status& 0377 is returned to the parent

Syntax:
#include <stdlib.h>

void exit(int status);

22.cmp - compare two files byte by byte

Compare two files byte by byte.

The optional SKIP1 and SKIP2 specify the number of bytes to skip at the
beginning of each file (zero by default).

Syntax:
cmp [OPTION]... FILE1 [FILE2 [SKIP1 [SKIP2]]]

-b, --print-bytes
print differing bytes

-i, --ignore-initial=SKIP
skip first SKIP bytes of both inputs

23.diff - compare files line by line

Compare FILES line by line.

Syntax:
diff [OPTION]... FILES

--normal
output a normal diff (the default)

-q, --brief
report only when files differ
24.locate - find files by name

locate reads one or more databases prepared by updatedb(8) and writes


file names matching at least one of the PATTERNs to standard output,
one per line.

If --regex is not specified, PATTERNs can contain globbing characters.


If any PATTERN contains no globbing characters, locate behaves as if
the pattern were *PATTERN*.

By default, locate does not check whether files found in database still
exist (but it does require all parent directories to exist if the data
base was built with --require-visibility no). locate can never report
files created after the most recent update of the relevant database.

Syntax:
locate [OPTION]... PATTERN...

-A, --all
Print only entries that match all PATTERNs instead of requiring
only one of them to match.

-b, --basename
Match only the base name against the specified patterns. This
is the opposite of wholename.

25. head - output the first part of files

Print the first 10 lines of each FILE to standard output. With more
than one FILE, precede each with a header giving the file name. With
no FILE, or when FILE is -, read standard input.

Syntax:
head [OPTION]... [FILE]...

-c, --bytes=[-]K
print the first K bytes of each file; with the leading '-',
print all but the last K bytes of each file

-n, --lines=[-]K
print the first K lines instead of the first 10; with the lead
ing '-', print all but the last K lines of each file

26.tail - output the last part of files

Print the last 10 lines of each FILE to standard output. With more
than one FILE, precede each with a header giving the file name. With
no FILE, or when FILE is -, read standard input.

Syntax:
tail [OPTION]... [FILE]...

-c, --bytes=K
output the last K bytes; alternatively, use -c +K to output
bytes starting with the Kth of each file

-f, --follow[={name|descriptor}]
output appended data as the file grows; -f, --follow, and --fol
low=descriptor are equivalent
27. find - search for files in a directory hierarchy

This manual page documents the GNU version of find. GNU find searches
the directory tree rooted at each given file name by evaluating the
given expression from left to right, according to the rules of prece
dence (see section OPERATORS), until the outcome is known (the left
hand side is false for and operations, true for or), at which point
find moves on to the next file name.

Syntax:
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]

-P Never follow symbolic links. This is the default behaviour.


When find examines or prints information a file, and the file is
a symbolic link, the information used shall be taken from the
properties of the symbolic link itself.

-L Follow symbolic links. When find examines or prints information


about files, the information used shall be taken from the prop
erties of the file to which the link points, not from the link
itself (unless it is a broken symbolic link or find is unable to
examine the file to which the link points). Use of this option
implies -noleaf. If you later use the -P option, -noleaf will
still be in effect. If -L is in effect and find discovers a
symbolic link to a subdirectory during its search, the subdirec
tory pointed to by the symbolic link will be searched.

28.tr - translate or delete characters

Translate, squeeze, and/or delete characters from standard input, writ


ing to standard output.

Syntax:
tr [OPTION]... SET1 [SET2]
-c, -C, --complement
use the complement of SET1

-d, --delete
delete characters in SET1, do not translate

29. nl - number lines of files

Write each FILE to standard output, with line numbers added. With no
FILE, or when FILE is -, read standard input.

Syntax:
nl [OPTION]... [FILE]...

-b, --body-numbering=STYLE
use STYLE for numbering body lines

-d, --section-delimiter=CC
use CC for separating logical pages

30.man - an interface to the on-line reference manuals

man is the system's manual pager. Each page argument given to man is
normally the name of a program, utility or function. The manual page
associated with each of these arguments is then found and displayed. A
section, if provided, will direct man to look only in that section of
the manual. The default action is to search in all of the available
sections following a pre-defined order ("1 n l 8 3 2 3posix 3pm 3perl 5
4 9 6 7" by default, unless overridden by the SECTION directive in
/etc/manpath.config), and to show only the first page found, even if
page exists in several sections.

Syntax:
man [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L
locale] [-m system[,...]] [-M path] [-S list] [-e extension] [-i|-I]
[--regex|--wildcard] [--names-only] [-a] [-u] [--no-subpages] [-P
pager] [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justifi
cation] [-p string] [-t] [-T[device]] [-H[browser]] [-X[dpi]] [-Z]
[[section] page ...] ...
man -k [apropos options] regexp ...
man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...
man -f [whatis options] page ...
man -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L
locale] [-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t]
[-T[device]] [-H[browser]] [-X[dpi]] [-Z] file ...
man -w|-W [-C file] [-d] [-D] page ...
man -c [-C file] [-d] [-D] page ...
man [-?V]

You might also like