Os Record
Os Record
Date:
EXPERIMENT NO. 01
AIM
1.pwd
The pwd command in linux translates to “Print working directory” and is used to display the
path of the current working directory inside the terminal.
2.ls
The ls command is used to display a directory’s files and folders.
(a)ls-t :sorts the files by modification time,showing last edited file first.head-1 picks up this
first file.
(b)ls-1: command used to display one file per time.
(c)ls-l :to display detailed version of every file.
(d)ls-lh:to display files in human readable format
(e)ls-a :to display hidden files in a directory.
(f)ls-lol:to display directory information.
3.cd
The cd command expands to “change directory”,which is used to change the current working
directory.
(a)cd /: this command is used to change directory to the root directory.
(b)cd dir_1/dir_2/dir_3: This command is used to move inside a directory from a directory.
(c)cd ~ : this command is used to change directory to the home directory.
(d)cd : this command also work same as cd ~ command.
(e)cd .. : this command is used to move to the parent directory of current directory, or the
directory one level up from the current directory.
(f)cd “dir name”: This command is used to navigate to a directory with white spaces.Instead
of using double quotes we can use single quotes also.
4.mkdir
The mkdir command in Linux allows the user to create directories (also referred to as folders
in some operating systems ). This command can create multiple directories at once as well as
set the permissions for the directories.
Syntax : mkdir [options..] [directories..]
(a)mkdir --version: It displays the version number, some information regarding the licence
and exits.
7|Page
(b)mkdir--help:It displays the help related information and exits.
(c)mkdir-v :it displays a message for every directory created.
8|Page
Date:
Syntax:mkdir -v [directories]
(d)mkdir-p:a flag which enables the command to create parent directories as necessary.
Syntax:mkdir – p [directories]
5.rmdir
remove a particular directory right from the terminal.
(a)rmdir- help :displays the general syntax of the command with various options.
(b)rmdir-p: This option removes The rmdir command is useful when you want to remove the
empty directories from the filesystem in Linux. This command lets you specify the
terminal to the directory, including all its ancestors.
(c)rmdir-v: Displays verbose information for every directory.
(d)rmdir-version: This option displays the version information and exit.
6.rm
Rm stands for “remove”.The rm command is used to remove objects such as files,directories
and symbolic links.
Syntax:rm[option]..file..
7.man
The man command in Linux is used to display the user manual of any command that we can
run on the terminal.
Syntax:man [option] [command name]
(a)No option : It displays the whole manual of the command.
(b)Section-num:Since a manual is divided into multiple sections so this option is used to
display only a specific section of a manual.
(c)man-f : One may not be able to remember the sections in which a command is present. So
this option gives the section in which the given command is present.
(d)man-a: This option helps us to display all the available intro manual pages in succession.
(e)man-k : This option searches the given command as a regular expression in all the
manuals
and it returns the manual pages with the section number in which it is found.
(f)man-w: This option returns the location in which the manual page of a given command is
present.
8.cp
cp stands for “copy”.This commans copies files or group of files.it creates an exact image of a
file on the disk with a different file name.
Syntax: cp [OPTION] Source Destination
cp [OPTION] Source Directory
cp [OPTION] Source-1 Source-2 Source-3 Source-n Directory
cp command works on three principal modes of operations based on the number and type
of argument passed;
9|Page
1. Two file names : If the command contains two file names, then it copy the contents
of 1st file to the 2nd file. If the 2nd file doesn’t exist, then first it creates one and content
is copied to it. But if it existed then it is simply overwritten without any warning.
Syntax:cp source_file destination_file
2. One or more arguments : If the command has one or more arguments, specifying file
names and following those arguments, an argument specifying directory name then
this command copies each source file to the destination directory with the same name,
10 | P a g e
Date:
created if not existed but if already existed then it will be overwritten.
Syntax:cp source_file1 source_file2 destination_directory.
3. Two directory names : If the command contains two directory names, cp copies all
files of the source directory to the destination directory, creating any files or directories
needed. This mode of operation requires an additional option, typically R, to indicate
the recursive copying of directories.
Syntax:cp -R source_directory destination_directory
9.mv
The mv command translates to “move”.it can be used to rename files as well as to move files
from one location to another.
Syntax: to move files; mv<filename><directory path>
to rename files; mv<old file name><new file name>
10.cat
The cat command is used to read the contents of one or more files and display their contents
inside the terminal.It helps us to create, view, concatenate files.
Syntax:cat [option] [file]
To create a file; cat<filename> (a file named filename is created)
To display a file; cat<filename>
To display multiple files; cat<file1><file2>
11.Echo
The echo command in linux is used to display line of text/string that are passed as an
argument . This is a built in command that is mostly used in shell scripts and batch files to
output status text to the screen or a file.
Syntax: echo [option] [string]
12.chmod
The chmod command is used to change the access mode of a file. The name is an
abbreviation of “change mode”.It states that every file and directory have three categories of
permissions; read ,write and execute represented by ‘r’,’w’ and ‘x’;that control the permissions
like who can read, write or execute the file.The `chmod` command is used to modify these
permissions.
13.ping
PING (Packet Internet Groper) command is used to check the network connectivity between
host and server/host. This command takes as input the IP address or the URL and sends a
data packet to the specified address and get a response from the server/host. This time is
recorded and is called latency. Fast ping low latency means faster connection.
11 | P a g e
14.grep
grep stands for “global search for regular expression and print out”.The grep filter searches a
file for a particular pattern of characters, and displays all lines that contain that pattern. The
pattern that is searched in the file is referred to as the regular expression.
Syntax: grep [options]pattern [files]
(a) grep-c : Prints only a count of the lines that match a pattern
(b) grep-h : Display the matched lines, but do not display the filenames.
(c) grep-i : Ignores, case for matching
(d) grep-l : Displays list of a filenames only.
(e)grep -n : Display the matched lines and their line numbers.
(f) grep -v : This prints out all the lines that do not matches the pattern
12 | P a g e
Date:
(g)grep -e exp : Specifies expression with this option. Can use multiple times.
(h)grep -f file : Takes patterns from file, one per line.
(i )grep -E : Treats pattern as an extended regular expression (ERE)
(j) grep -w : Match whole word
(k)grep -o : Print only the matched parts of a matching line, with each such part on a separate
output line.
(l) grep -A n : Prints searched line and n lines after the result.
(m)grep-B n : Prints searched line and n lines before the result.
(n)grep -C n : Prints searched line and n lines after and before the result.
15.cut
command for cutting out the sections from each line of files and writing the result to standard
output. It can be used to cut parts of a line by byte position, character and field.
Syntax: cut [option] [file]
(a)cut-b: To extract the specific bytes. Range of bytes can be specified using the hyphen(-). It
is necessary to specify list of byte numbers otherwise it gives error.
Tabs and backspaces are treated like as a character of 1 byte.
(b)cut-
13 | P a g e
14 | P a g e
Date:
15 | P a g e