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

LINUX LAB (CC3231)

LAB RECORD
Name: Priyanshi Dhar | CCE-A | Reg. No: 199303046 | Batch: CCE A2

S.NO COMMANDS DESCRIPTION OPTIONS


.
1. pwd Print working directory -L, -P
2. man used to display the user manual of any
command that we can run on the
terminal
3. ls list directory contents
4. history
5. clear
6. Script
7. Mkdir
8. cd
9. cal
10. date
11. who
Date: 27th January 2022

1. Pwd: Print working directory. It gives us the


absolute path, which means the path that starts
from the root.
The user directory is something like
“/home/username”.
 pwd -L (Logical): contains symbolic links or
prints the symbolic path.
 pwd -P (physical): avoid all symbolic links or
prints the actual path.
2. man: used to display the user manual of any
command that we can run on the terminal.

3. ls: list directory contents.


 ls -a:  display all files and subdirectories in the
current directory, including hidden “.” And
“..” etc.
 ls -A: show all files and subdirectories in the
current directory, including hidden files, but
excluding . And ..
 ls -l: display detailed information of non-
hidden files and directories.
 ls -al: display all files and subdirectories in the
current directory, including hidden “.” And
“..” etc. details.
4. history: history command is used to view the
previously executed command.
 history | grep A: globally search for a regular
expression and print matching lines. It filter
searches a file for a particular pattern of characters,
and display all lines that contain that pattern. Here
A is any character you want to filter.

 history | tail -n N: to see the last N commands in


the history.

5. clear: clears the terminal screen.


 clear -T: Indicate the type of terminal.
 clear -V: reports the version of ncurses which was
used in the program and exits.
 clear -x: do not do not attempt to clear the
terminal’s rollback buffer using the extended “E3”
capability.
6. script: This command is used to make typescript
or record all the terminal activities.
7.

 script -a: append the output of the file.


 script -c: This option is used when we want to run a
particular command rather than interactive shell
and get terminal information in the file given as
argument or typescript by default. The script will
automatically exit after successful execution.

 Script -e: This option simply returns exit code of


the child process.
 Script -f: This option is used to run flush output
after each write. It’s useful for tele cooperation.
8. mkdir: used to create directories.
9.

 mkdir --version: It displays the version number,


some information regarding the license and exits.
 mkdir --help: It displays the help related
information and exits.
 mkdir -p: A flag which enables the command to
create parent directories as necessary. If the
directories exist, no error is specified.
 mkdir -v [directories]: It displays a message for
every directory created.
10. cd: This command is used to change the
current working directory.
 cd {directory name}: To move inside a
subdirectory: to move inside a subdirectory in
Linux we use.
 cd /: this command is used to change directory to
the root directory, The root directory is the first
directory in your filesystem hierarchy.
 cd ~: this command is used to change directory to
the home directory.
 cd ..: this command is used to move to the parent
directory of current directory, or the directory one
level up from the current directory. “..” represents
parent directory.
11. cal: This command is a calendar command. It
is used to see the calendar of a specific month or a
whole year.
12.
 cal -y: Shows the calendar of the complete current
year with the current date highlighted.

 cal 10 2001: Shows calendar of selected month and

year.
 cal 2001: Shows the whole calendar of the year.

 cal -3: Shows calendar of previous, current and


next month.
13. date: The date command displays the current
date and time, including the abbreviated day name,
abbreviated month name, day of the month, the
time separated by colons, the time zone name, and
the year.
14.

 date -u: Displays the time in GMT(Greenwich


Mean Time)/UTC(Coordinated Universal
Time )time zone.
 date --date = “3 years ago”: Displays the given date
string in the format of date. But this will not affect
the system’s actual date and time value. Rather it
uses the date and time given in the form of string.
15. who: This command is used to get
information about currently logged in user on to
system.
16.
 who -m -H: To display host name and user
associated with standard input such as keyboard.
 who -p -H: To show all active processes which are
spawned by INIT process.
 who -T -H: To show status of the user’s message as
+, – or ?

17. whoami: This command is used to find


username associated with current effective user id.
18.

 whoami --help: It gives the help message and exit.


 whoami -version: It gives the version information
and exit.
Date: 3rd February 2022

1. cat: The cat (short for “concatenate”)


command is one of the most frequently used
commands in Linux/Unix-like operating systems.
 cat > {filename}: This command is use to type
content in the file.
 cat >> filename.txt: To append a file.
 cat filename: Display the data of the text file.
 cat -n {filename}: This command is used to show
the numbering of lines in a file (including empty
lines).
 cat -b {filename}: This command is used to show
the numbering of lines in a file (Not including
empty lines).
2. cp: This command is used to copy files or
groups of files or directories.
 cp -u {source} {destination}: This command is
used to update, i.e., copy when source is newer
than destination.
 cp -a {source} {destination}: This command is
used to archive file.
 cp -l {source} {destination}: This command is used
to link files.
 cp --version: This command is used to display the
version information.

3. wc: wc command in UNIX is a command


line utility for printing newline, word and byte
counts for files.
 wc -c {filename}: This command is used to display
the count of bytes in a file.
 wc -m {filename}: This command is used to
display the count of characters in a file
 wc -l {filename}: This command is used to display
the number of lines in a file.
 wc -w {filename}: This command is used to
display the number of words in a file.

4. rm filename.txt: to remove a file.


5.

 rm -i {filename}: This command is used to display


the long listing.
 rm -v {filename}: This command shows directories
starting with . as well.
 rm --version: Shows the version information.
 rm --help: Shows help for rm command.

6. rmdir: Remove a directory.


 rmdir -p {parent/child}: In this option each of the
directory argument is treated as a pathname of
which all components will be removed, if they are
already empty, starting from the last component.
 rmdir -v {directory name}: This option displays
verbose information for every directory being
processed.
 rmdir --version: This option is used to display the
version information and exit.
 rmdir –help: Show help for rmdir command.

7. ls: The ls command is used to list files or


directories in Linux.
8.

 ls -l: This command is used to display the long


listing.
 ls -a: This command shows directories starting with

. as well.
 ls -al: This command is use list down all the files +
directories including hidden files/directories in the
current directory along with the files starting with .
in their names. ls means listing of the directories
along with files in the current directory.
 ls --author: This command is used to print the
author of each file.

9. mv: mv or move is used to move one or more


files or directories from one place to another in a
file system.
10.

 mv -v {source} {destination}: Shows verbose


while moving file.
 mv --help: Shows help for mv command.
 mv --version: This option is used to display the
version of mv which is currently running on your
system.
 mv -b {source} {destination}: If you use the -b or
--backup options, mv renames the destination file if
it exists, appending a suffix to its file name.
Date: 10th February 2022
Created file feb10.txt with permissions as shown
below:

1. chmod: the chmod command is used to


change the access mode of a file.
 chmod 753: changing permission using chmod
753 aa.txt
 chmod 532: changing permission using chmod
532 aa.txt
Date: 17th February 2022

1. ls -i: Gives inode number

Created file g1.txt


2. g1.txt hardlink17022022: for hardlink
i.e., file contents can be accessed even after
deleting the file.

3. ln -s g1.txt softlink17022022: for


softlink, file contents cannot be accessed after
removing the file.

Created file ls -l > g1.txt


4. head g1.txt: prints first 10 lines of the
text file

 head -n 2 g1.txt: print specific number of


lines from the top.

 head -q g1.txt: never prints headers


giving file name.
 head -v g1.txt: always prints header
giving file name.

5. tail ml.txt: prints last 10 lines of the


text file.

 tail -n 2 g1.txt: print specific number


of lines from the bottom.
 tail -q ml.txt: never output headers
giving file names.
 tail -v ml.txt: always outputs headers
of the given file.
6. ls -l |more: file perusal filter for crt
viewing

 ls -l | more -f: count logical lines,


rather than screen lines
7. ls -l |less: opposite of more.

Created a shell scripted file cat > 1.sh


8. 1.sh: echo calendar, date, o/p.
Using gedit: text editor for the GNOME
desktop

You might also like