0% found this document useful (0 votes)
48 views33 pages

Os Practical

This document provides instructions for common Linux commands like opening the terminal, navigating directories, viewing file contents, manipulating files and directories, monitoring running processes, and more. It also includes some basic Windows commands like navigating folders, viewing files and system information, and initiating a shutdown. The key Linux commands covered are ls, cd, cat, mkdir, rmdir, rm, kill, top, less, touch, chmod, and their various options and uses.

Uploaded by

Harrison Babu
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)
48 views33 pages

Os Practical

This document provides instructions for common Linux commands like opening the terminal, navigating directories, viewing file contents, manipulating files and directories, monitoring running processes, and more. It also includes some basic Windows commands like navigating folders, viewing files and system information, and initiating a shutdown. The key Linux commands covered are ls, cd, cat, mkdir, rmdir, rm, kill, top, less, touch, chmod, and their various options and uses.

Uploaded by

Harrison Babu
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/ 33

Practical of operating system

Name- Shubhendu Ravi

Standard – B.sc 3rd Year


how to open the terminal
 ctrl + Alt + t
To create directory
 mkdir dir_ name

To remove directory
 Rmdir dir_name

Present working directory


 Pwd
 Bydefault it will show home
directory
ls - linux shell
 It lists all the directory content
such as file or subdirectories

Cd (change directory)
 To go from one directory to another

Cat
 This function is used for
# displaying text files
# compiling copies of text files
# creating new text files
Syntax cat –[option] file_name
cat
ctrl + d
 Used to stop cat command
 If we write this command
then whatever we write it will
echo
Cat file_name
 It will display all the thing present
in the given file
 Eg cat list.txt

 Cat file_name1 file_name2


It will display all the content of both
the files combined
cat -b file_name
 It will add line no to all non
blank lines

Cat -n file_name
 It will add line no to all the lines
either blank or written

cat -E file_name
 It will add dollar symbol at the
end of every line

cat -s file_name
 If there are too many line breaks in
b/w two lines then option will
reduce blank to only one blank line

creation using cat


cat > test.txt
hello ,how are you?
I am fine
ctrl + d the above line will
be written after creating
test.txt cat >test.txt
what is your name
ctrl + d
the above line written before will
get deleted and this new line will
get wrote in test.txt(override)
this command is used to upend the
data in text.txt

cat filename1 filename2 >filename3


eg
cat list1.txt list2.txt>list3.txt
this will combine the content of both
the files and write it into the 3rd file
this will uppend the content of file1 to
file2
ls command
syntax ls –[option] file /directory_name
ls
 Simple ls command will show the contents
of home directory

ls [directory_name]
eg ls documents
 this command will display the content
inside the given directory name like here
it will show the content of all the files and
sub directories stored inside documents

ls /
 this will show all the content of root
folder
 / it is representing root
ls..
 this will give the directory structure of the
immediate parent directory of the
current directory
 .. it is representing backward flow

Ls../..
 It will give the content of two
directories back and then the current
directory
ls -l
 it will give complete information about
the files and directories present in the
working directory

ls -a
it gives content of all the directory
along with the all the hidden files and
directory present in the working
directory
ls -al
this is combination of above two
option - a and -l it will give all the
contents of the hidden and normal
files in Lang and list format with the
complete information
ls -lS
here ‘s’ denotes sorting on the basis of
size or -l for list or complete
information
ls -ls > out.txt
here - ls means it will sort the content
of directory on the basis of size
,angular bracket denotes output
stream and then given filename out.txt
the angular bracket >out.txt along with
ls will make new file named as out.txt
which stores the output of ls -ls

ls -d*/
it will list all the directories

cd stands for change directory


cd/
this alone will lend you to the current
Home directory

cd~
it will take you to the home directory

cd..
will take you to the immediate parent
directory

cd[dir_name] /dir_name/
multiple directories can also be given like
this and you will directly reach inside
directory name to the folder
foldername – my book
cd my book
there are three ways to solve this problem
cd my\ book
cd ”my book”
cd ’my book’

cp
cp file1.txt file2.txt
this command will copy all the
contents of file1.txt to file2.txt it will
create a new file named as file2.txt
if it is not already created

cp file1.txt directory
it will copy file1.txt to the given
directory name
cp -i file1.txt file2.txt dir1
here I stands for interactive control
this command will copy file1.txt and
and file2.txt in the given directory
but but if file1.txt and file2.txt is
already present then it will ask user
whether he wants to overwrite it
or not

 mv file1.txt dir

 mv file1.txt file2.txt

mkdir
it is the command used for making
directory
syntax : mkdir Image
mkdir images/pics
it will create pics directory inside
images directory

mkdir -p images/pics
it will create both the parent
and child directory in the single
shot mkdir -p
images/{pics1,pics2} will create
parent directory and
inside it will create two directories
named as pics1 and pics2
mkdir image images/pics1 images/pics2

rmdir
it stands for remove directory
rmdir –[option] directory_name
rmdir dir_name
it will remove the directory

rmdir a/b/c/d/e

rmdir -p a/b/c/d/e
here p for parent
 it will delete all the directories
in single

rmdir -pv a/b/c/d/e


it will delete whole directory
structure and -v will show how this
is happening
for understanding:
a/b/c/d/e
rmdir cda
-p a/b/c/d/e cdb

cat > test1.txt


hello
ctrl +D
if we want to delete the directory
firstly we have to remove all the
files from the directory as because
rmdir command will only delete
directories and not files

rm to remove
rm file_name

rm -r a
it will delete the whole directory
including file
 r for recursive and a for directory
name

kill
it is used to kill the process in order to
delete a process we need to know the
process ID of that process
pid process_name
kill pid

kill – KILL pid


 it will forcefully kill the process

top
it shows real-time dynamic view of
computer meaning which process is
running and which process is taking
most part of your computer memory in
general it shows which process is
taking most part of CPU and RAM
top after pressing enter
it will give all information about
process and refreshes in every 3
seconds after giving top command
 if we press S then we can change the
time of refreshing which is by default 3
second
 if we press i after top it will filterout
idle processes and only show the
process which are running
 if we press K after top then it will ask
for PID and when we press enter It will
kill the process
echo
 it prints what is written after echo
 it is somewhat like print statement
eg
 echo “hello world”

 myvar = “hello”
echo $ myvar
less command
this command is used to read the files
and help in searching Something any
type of pattern or some words
less file_name1
this command will help you in reading
big files because using cat command if
we open a file then it doesn't display
the whole content
the file displayed using less command
can be navigated line by line using
Arrow keys, page by page using space
bar
if we want to go back page by page b is
used and G will lead you to go to the
end of the file and g will take you to
the top of the text file
Touch
this command is used to create empty
file in Linux and also used to change
time instance of a file
touch file1.txt
if the file is not created this command
will create the file but if it is already
created it will only change the time
stamp of the file to the current time

file permission
r w x r w x r w x
* 1st three owner
* 2nd three group
* others
- denoting file
chmod
chmod o+ x permission grant
o for owner and x means executable
chmod g -r taking permission
chmod ug =rwx
 u for other
chmod a -rwx
a for all
d r w x r w x r w x

owner =r w x
4 21
Group =r w x
421
Other =r w x
421
Window’s Command
 Windows + R
 Then write cmd

Help command_name
Eg – help date
if we will try help then it will give list of all
commands in windows
exit
to close cmd

cd/
go to root directory

dir
show all file and folder

mkdir
to create directory

rename
 ren “foldername” “new name”
to rename folder name
copy file
 copy file1.txt science/

 copy file1.txt + file2.txt science/test.txt

 color
eg - color 84 here 4 denotes font color and 8
denotes background colour
 date display date and time

 Time
Above both command will work in
administration mode
We open this by write click then
administration mode

Shutdown
Shutdown /s
Initiate shutdown
 Ipconfig
Gives ip address mac address(media access
control)

 Ping google.com
It is used to check whether your
computer/network is connected or not
 Netstat
it will tell all the connection made from the
PC and pc’s

 Cd..
Level before current directory

 Cd.
Current directory

You might also like