0% found this document useful (0 votes)
10 views13 pages

Netaji Subhash Engineering College: Uni. Roll-10931121046 Name - OS Lab Sub. - PCC-CSBS602 (6959) Dep. - CSBS Sem. - 6th

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

Netaji Subhash Engineering College: Uni. Roll-10931121046 Name - OS Lab Sub. - PCC-CSBS602 (6959) Dep. - CSBS Sem. - 6th

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

Netaji Subhash Engineering College

-----------------------

Uni. Roll- 10931121046


Name - OS Lab
Sub. - PCC-CSBS602(6959)
Dep. - CSBS
Sem. - 6th
$ who

The who command displays information about users who


are currently logged into the system .

$ whoami
The whoami command in Unix is used to display the
username of the current user who is logged in to the
system. It's handy for quickly determining the identity of
the user we're logged in .
$ pwd
The pwd command stands for "print working directory".
When we run it in a Unix terminal, it will display the full
pathname of the current working directory, showing us
where we are within the file system.

$ touch
The touch command is used to create an empty file. In this
case, we've created a file named "f" in the current directory.
If we want to verify that the file was created, we can use
the ls command to list the files in the current directory.
$ ls
Running the `ls` command lists the files and directories in
the current directory. If we've just created a file named "f"
using the `touch` command, we should see it listed when
we run `ls`.

$ ls -l
The `ls -l` command provides a detailed listing of files and
directories in the current directory. It displays additional
information such as file permissions, owner, group, file size,
and modification time. If werun `ls -l`, we'll see a detailed
listing of all files and directories in the current directory.
$cat > a
The command `cat > a` is used to create or modify a file
named "a" and allows to enter text into that file directly
from the terminal. After executeing this command, we can
start typing the text we want to add to the file. When
we're done, we can press Ctrl+D to save the changes and
exit.

$cat a
By useing the `cat a` command, it will display the contents
of the file named "a" in the terminal.
$ wc a
The `wc` command is used to display the number of lines,
words, and bytes contained in a file. If we run `wc a`, it will
provide the line count, word count, and byte count of the
file named "a".

$ wc -c a
The `wc -c a` command will provide with the byte count of
the file named "a". It counts the number of bytes in the file.

$ wc -l a
The `wc -l a` command will provide with the line count of
the file named "a". It counts the number of lines in the file.

$ Word count using wc


- `wc -w a`: Displays the word count of the file "a". In this
case, there are 4 words in the file "a".
- `wc -lw a`: Displays both the line count and word count
of the file "a". In this case, there are 4 lines and 4 words in
the file "a".
- `wc -cw a`: Displays both the byte count and word count
of the file "a". In this case, there are 4 words and 27 bytes
in the file "a".
- `wc -cl a`: Displays both the line count and byte count of
the file "a". In this case, there are 4 lines and 27 bytes in
the file "a".

The output indicates there are 5 lines, 8 words, and 43


bytes based on the provided input.
$ Moving a file using mv
- `mv a b`: Renames the file "a" to "b".
- `1s`: we intended to list the contents of the directory. The
correct command for listing contents is `ls`, not `1s`. After
renaming "a" to "b", we have files "b", "c", "d", "di", and "e"
in the current directory.
- `mkdir d1`: Creates a new directory named "d1".
- `1s`: Again, we intended to list the contents of the
directory. The correct command is `ls`. After creating the
directory "d1", we have directories "b", "c", "d", "di", "e",
and "d1" in the current directory.
- `mv b d1`: Moves the file "b" into the directory "d1".
- `1s`: Lists the contents of the directory. After moving "b"
into "d1", the file "b" is no longer in the current directory,
so it's not listed.
- `cd d1`: Changes the current directory to "d1".
- `1s`: Lists the contents of the directory "d1". After moving
"b" into "d1", we have only the file "b" in the directory "d1".

$ cp

The `cp` command is used to copy files or directories in


Unix. If we need help with a specific usage or option of the
`cp` command.
$ date
The `date` command displays the current date and time
according to the system clock. It's a simple way to check
the current date and time in Unix.

$ Date revisited
The `date` command with various format specifiers:
- `%A`: Displays the full name of the day of the week
(Wednesday).
- `%a`: Displays the abbreviated name of the day of the
week (Wed).
- `%Y`: Displays the current year (2024).
- `%y`: Displays the last two digits of the year (24).
- `%m`: Displays the current month (01, which represents
January).
- `%M`: Displays the current minute (46).
- `%S`: Displays the current second (29).
- `%s`: Displays the number of seconds since the Unix
Epoch (January 1, 1970).
- `%H`: Displays the current hour in 24-hour format (17,
which represents 5 PM).
$ Date contd.

The `date` command with various format specifiers:

$ bc
The bc command is a calculator that allows us to perform
arithmetic calculations in the Unix terminal.
In this case we are usign 3+6 to demonstrate its
functionality

You might also like