Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

1 | OS PRACTICAL FILE

OPERATING
1 | OS PRACTICAL FILE

NAME : ANIKA CHAUHAN


ROLL NO. : 9
COURSE : MCA
SEMESTER : I
SUBJECT : Operating System
SUBMITTED TO : Mrs. Kavita
Mittal
2 | OS PRACTICAL FILE

INDEX
Basic commands ------------------------------------------------------- 1
echo ---------------------------------------------------------------------------3
date ---------------------------------------------------------------------------6
hostname ----------------------------------------------------------------13
arch -------------------------------------------------------------------------13
uname ----------------------------------------------------------------------14
uptime ----------------------------------------------------------------------14
who ---------------------------------------------------------------------------14
whoami---------------------------------------------------------------------17
Directory Commands ----------------------------------------------18
pwd ---------------------------------------------------------------------------18
cd ------------------------------------------------------------------------------18
ls -------------------------------------------------------------------------------21
mkdir -----------------------------------------------------------------------24
rmdir -------------------------------------------------------------------------25
rm -r --------------------------------------------------------------------------25
File Commands --------------------------------------------------------26
cat ----------------------------------------------------------------------------26
rm ----------------------------------------------------------------------------27
mv ----------------------------------------------------------------------------28
cp -----------------------------------------------------------------------------28
wc -----------------------------------------------------------------------------31
touch -----------------------------------------------------------------------33
paste ------------------------------------------------------------------------35
sort ---------------------------------------------------------------------------35
cut ----------------------------------------------------------------------------38
wild cards ----------------------------------------------------------------41
1 | OS PRACTICAL FILE

BASIC COMMANDS
➢ echo : echo is a built-in
command in the bash and C shells that
writes its arguments to standard
output.

o \b : it removes all the spaces in


between the text.

o \c : suppress trailing new line with


backspace interpreter ‘-e‘ to continue
without emitting new line.
2 | OS PRACTICAL FILE

o \n : this option creates a new line from


where it is used.

o \t : this option is used to create


horizontal tab spaces.

o \r : carriage return with backspace


interpreter ‘-e‘ to have specified
carriage return in output.

o \v : this option is used to create


vertical tab spaces.
3 | OS PRACTICAL FILE

o \a : alert return with backspace


interpreter ‘-e‘ to have sound alert.

o echo * : this command will print all


files/folders, similar to ls command.

o -n : this option is used to omit echoing


trailing newline.
4 | OS PRACTICAL FILE

o Redirecting `echo` Output


5 | OS PRACTICAL FILE

➢ date : to display date (shows


current system date and time to the
nearest second).
o %a : locale's abbreviated weekday
name (e.g., Sun)
o %A : locale's full weekday name
(e.g., Sunday)
o %b : locale's abbreviated month
name (e.g., Jan)
o %B : locale's full month name (e.g.,
January)
o %c : locale's date and time (e.g., Thu
Mar 3 23:05:25 2005)
o %C : century; like %Y, except omit
last two digits (e.g., 20)
o %d : day of month (e.g., 01)
o %D : date; same as %m/%d/%y
o %e : day of month, space padded;
same as %_d
o %F : full date; same as %Y-%m-%d
o %g : last two digits of year of ISO
week number (see %G)
6 | OS PRACTICAL FILE

o %G : year of ISO week number (see


%V); normally useful only with %V
o %h : same as %b
o %j : day of year (001..366)
o %k : hour, space padded ( 0..23); same
as %_H
o %m : month (01..12)
o %M : minute (00..59)
o %p : locale's equivalent of either AM or
PM; blank if not known
o %P : like %p, but lower case
o %q : quarter of year (1..4)
o %r : locale's 12-hour clock time (e.g.,
11:11:04 PM)
o %R : 24-hour hour and minute; same as
%H:%M
o %s : seconds since 1970-01-01 00:00:00
UTC
o %S : second (00..60)
o %T : time; same as %H:%M:%S
o %u : day of week (1..7); 1 is Monday
o %U : week number of year, with Sunday
as first day of week (00..53)
o %V : ISO week number, with Monday as
first day of week (01..53)
7 | OS PRACTICAL FILE

o %w : day of week (0..6); 0 is Sunday


o %W : week number of year, with
Monday as first day of week (00..53)
o %x : locale's date representation (e.g.,
12/31/99)
o %X : locale's time representation (e.g.,
23:13:48)
o %y : last two digits of year (00..99)
o %Y : year
o %z : +hhmm numeric time zone (e.g., -
0400)
o %::z : +hh:mm:ss numeric time zone
(e.g., -04:00:00)
8 | OS PRACTICAL FILE
9 | OS PRACTICAL FILE
10 | O S P R A C T I C A L F I L E
11 | O S P R A C T I C A L F I L E
12 | O S P R A C T I C A L F I L E

➢ hostname : used to either set


or display the current host, domain or
node name of the system.

➢ arch : Prints the type of


computer you are using.
13 | O S P R A C T I C A L F I L E

➢ uname – Prints name of


current system.

➢ who - who command is used to


find time of last system boot, current
run level of the system, list of logged
in user and more.

o To show list of users logged in to


system
14 | O S P R A C T I C A L F I L E

o To display host name and user


associated with standard input such as
keyboard.

o To show all active processes which are


spawned by INIT process.

o To show status of the users message


as +, – or ?

o To show time of the system when it


booted last time.
15 | O S P R A C T I C A L F I L E

o To show system login process details

o To count number of users logged on to


system

o To display current run level of the


system

o To display all details of current logged


in user
16 | O S P R A C T I C A L F I L E

➢ whoami : whoami prints the


user name associated with the
current effective user ID.
17 | O S P R A C T I C A L F I L E

DIRECTORY COMMANDS
➢ pwd - For printing the current
directory.

o -L : print the value of $PWD if it names


the current working directory
o -P : print the physical directory, without
any symbolic links

➢ cd - Changing directories
18 | O S P R A C T I C A L F I L E

o cd : go to home directory

o cd ~/papers : go to home/user/papers

o cd dir : go to directory (relative)

o cd /dir1/dir2/dir3… : go to directory
(absolute)
19 | O S P R A C T I C A L F I L E

o cd - : go to last directory you were in

o cd .. : to navigate up one directory


level
20 | O S P R A C T I C A L F I L E

➢ ls - Shows full list or content of


directory
o ls -x: Multicolumnar output
o ls -F : Marks executables with *,
directories with / and symbolic links
with @
o ls -a : Shows all filenames beginning
with a dot including . and ..
o ls -r : Sorts filenames in reverse order
(ASCII collating sequence by default)
o ls -R : Recursive list
o ls -l : Long listing in ASCII collating
sequence showing seven attributes of a
file
o ls -d dirname : Lists only dirname if
dirname is a directory
o ls -t : Sorts filenames with last
modification time
o ls -lt : Sorts listing by last modification
time
21 | O S P R A C T I C A L F I L E

o ls -u : Sorts filenames by last access


time
o ls -lu : Sorts by ASCII collating
sequence but listing shows last access
time
o ls -lut : As above but sorted by last
access time
22 | O S P R A C T I C A L F I L E
23 | O S P R A C T I C A L F I L E

➢ mkdir - Makes directory with the


specified name.
24 | O S P R A C T I C A L F I L E

➢ rmdir
o rmdir dirname : deletes the directory
if empty else interrupts to delete files
first

o rmdir ms/d1 ms/d2 ms : to remove


multiple directories
25 | O S P R A C T I C A L F I L E

FILE COMMANDS
➢ cat
o cat > filename – Creates new file
( insert content in file)
▪ ctrl+d – to signify end of file
o cat f1 – to display contet of file
o cat f1 f2 – to displays content of
multiple files
o cat -n f1 – to displays with line numbers
26 | O S P R A C T I C A L F I L E

➢ rm – Deletes the specified file.


o rm file : Removes the file.

o rm -i abc* : Prompts to remove each file


in current directory starting with ‘abc’.
27 | O S P R A C T I C A L F I L E

o rm abc* : Remove all files in current


directory starting with ‘abc’.

➢ mv – Used to rename a file.

➢ cp – copy file
28 | O S P R A C T I C A L F I L E

o cp file1 file2: Copy file1 to file2

o cp file1 directory: Copy file1 into


directory.
29 | O S P R A C T I C A L F I L E

o cp file1 file2 file3 dir1: Copy files into


directory.

o cp – R dir1 dir2: Copy dir1 into dir2


including subdirectories.
30 | O S P R A C T I C A L F I L E

➢ wc – Count the number of lines or


characters.

o -c : Number of characters

o -w : Number of words

o -l : prints the number of lines present


in a file.
31 | O S P R A C T I C A L F I L E

o -m : displays count of characters from


a file

o -L : used to print out the length of


longest (number of characters) line in a
file

o --version : used to display the version


of wc which is currently running on
your system.
32 | O S P R A C T I C A L F I L E

➢ touch - Used to create a file. It


can change file access and
modification time. It is also used to
change the timestamps (i.e., dates and
times of the most recent access and
modification) on existing files and
directories.
33 | O S P R A C T I C A L F I L E

-a : change only the access time

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


34 | O S P R A C T I C A L F I L E

➢ paste – Merge corresponding or


subsequent lines of files.

➢ sort – The sort command sorts


a file according to fields.
35 | O S P R A C T I C A L F I L E

o -r : Sorting In Reverse Order

o -n : To sort a file numerically

o -nr : To sort a file with numeric data in


reverse order

o -k : Sort a table on the basis of any


column number by using -k option.
36 | O S P R A C T I C A L F I L E

o -u : To sort and remove duplicates.

o -M : To sort by month pass.


37 | O S P R A C T I C A L F I L E

➢ cut – The cut command takes a


vertical slice of a file, printing only
the specified columns or fields.
o -b(byte) : To extract the specific bytes

o -c (column) : To cut by character


38 | O S P R A C T I C A L F I L E

o -f (field) : To extract the useful


information you need to cut by fields
rather than columns
39 | O S P R A C T I C A L F I L E

o –complement : It complement the


output.
40 | O S P R A C T I C A L F I L E

o --version : Display the version of cut


which is currently running on your
system.

➢ wild cards (*,?,[])


o * : asterisk symbol is used to represent
anycharacter(s)
o ? : question mark is used to represent
any single character
o [from-to] : Values entered within
square brackets represent a range
(from-to) for a single character
o [!from-to] : Values entered within
square brackets represent a range
41 | O S P R A C T I C A L F I L E

(from-to) to exclude for a single


character

You might also like