NATIONAL FORENSIC SCIENCES
UNIVERSITY
OPERATING SYSTEM
Practical Assignment on COMMANDS
Submitted by: ANMOL MALHOTRA
Enrolment No.: 012201000001002
Commands
There are different types of commands used on a command prompt in the Linux operating
system. As Linux is a Command line interface rather than a Graphical User Interface, various
commands are used to operate on the operating system to get the desired result. There are 5
types of commands for different purposes.
1) To display the file contents on the terminal:
• cat: This command is generally used to concatenate the files present scattered in
different memory locations and present in a standard output form.
• more: This command is used to view the result in a single display.
• less: This command helps in viewing limited results at a time on the display and
allows back-and-forth movement.
• head : This command is used to print the first N lines of a file. It accepts N as input
and the default value of N is 10.
• tail : This command is used to print the last N-1 lines of a file. It accepts N as input
and the default value of N is 10.
2). File and Directory Manipulation Commands:
• mkdir : This mkdir command allows you to create fresh directories in the terminal
itself.
The default syntax is mkdir <directory name> and the new directory will be created.
• cp : The cp command of Linux is equivalent to copy-paste and cut-paste in Windows.
Cp dbpool.go Linux/ copies the file dbpool.go into the directory Linux. Cp -R is used to
copy the file into another file of different name in the same directory as the parent file.
• mv : The mv command moves files and directories from one directory to another or
renames a file or directory.
• rm : The rm command lets you delete a file or directory passing its name: "rm
filename" or "rm -d directory." You can include a directory path, too. If there are files in
the directory, use the -r option "rm -r directory" to delete files and folders recursively.
• touch : The touch command is used to create or update the timestamp of a file.
3). Extract, sort, and filter data Commands:
• grep : This command is used to search for the specified text in a file.
• sort : This command is used to sort the contents of files. You can perform a reverse-
order sort using the -r flag and -R flag is used to sort the data randomly.
• wc : This command is used to count the number of characters, words in a file.
• cut : It is used to find out number of lines, word count, byte and characters count in
the files specified in the file arguments.
-l: This option prints the number of lines present in a file.
-w: This option prints the number of words present in a file.
-m: This option displays count of characters from a file.
4). Basic Terminal Navigation Commands:
• cd: This command modifies the directory.
• du: Display disk utilization can be done with the help of di command
• pwd: The pwd command is mostly used to print the current working directory on your
terminal. It is also one of the commonly used commands.
• man: This command displays the manual for any command that exists in Linux.
• Rmdir: If a directory is empty, it can be deleted with this command.
• file1 file2: Establishes a physical connection.
ln -s file1 file2: Establishes a symbolic connection.
• locate: In the Linux System, it is used to locate a file.
• echo: This command facilitates the movement of data into a file, often text.
• df: This utility shows the amount of disk space that is available in each of your
system's partitions.
• tar: A program used to work with tarballs, or compressed files stored in tarball
archives.
5. File Permissions Commands: In Linux and UNIX systems, the chown and chmod and
chgrp commands are used to manage file access.
• chown: This command modifies the file's owner.
• chgrp: This command modifies the file's group owner.
• chmod: Used to change a user's permissions or level of access.