You are on page 1of 31

ASSIGNMENT 2

NAME : Salim Tadvi


REG NO: 201070042
COURSE : OSC

AIM : Perform the following: Basic commands of Linux, File permission


commands, String processing commands

COMMANDS AND OUTPUTS:


1. Date : date command is used to display the system date and time. date
command is also used to set date and time of the system. By default the
date command displays the date in the time zone on which the
unix/linux operating system is configured.You must be the super-user
(root) to change the date and time.
2. Cal : cal command is a calendar command in Linux which is used to
see the calendar of a specific month or a whole year.

3. Whoami : whoami command is used both in Unix Operating System


and as well as in Windows Operating System.
● It is basically the concatenation of the strings “who”,”am”,”i” as whoami.
● It displays the username of the current user when this command is
invoked.
● It is similar to running the id command with the options -un

4. Id : id command in Linux is used to find out user and group names and
numeric ID’s (UID or group ID) of the current user or any other user in
the server. This command is useful to find out the following information
as listed below:
● User name and real user id.
● Find out the specific Users UID.
● Show the UID and all groups associated with a user.
● List out all the groups a user belongs to.
● Display security context of the current user.

5. Pwd : pwd stands for Print Working Directory. It prints the path of
the working directory, starting from the root.
6. Cd command : cd command in linux known as change
directory command. It is used to change the current working

directory.
7. Ls : ls is a Linux shell command that lists directory contents of files
and directories

8. Mkdir : mkdir command in Linux allows the user to create directories


(also referred to as folders in some operating systems ). This command
can create multiple directories at once as well as set the permissions for
the directories.
9. Rmdir : rmdir command is used to remove empty directories from the
filesystem in Linux. The rmdir command removes each and every
directory specified in the command line only if these directories are empty.
So if the specified directory has some directories or files in it then this
cannot be removed by rmdir command.
10. Cp : cp stands for copy. This command is used to copy files or
groups of files or directory. It creates an exact image of a file on a disk
with a different file name. cp command requires at least two filenames in
its arguments.
11. Mv : mv stands for move. mv is used to move one or more files or
directories from one place to another in a file system like UNIX. It has two
distinct functions:
(i) It renames a file or folder.
(ii) It moves a group of files to a different directory.
12. Tree : In UNIX/LINUX systems, as well as MS-DOS and Microsoft
Windows, tree is a recursive directory listing program that produces a
depth-indented listing of files. With no arguments, the tree lists the files in
the current directory. When directory arguments are given, the tree lists all
the files or directories found in the given directories each in turn. Upon
completion of listing all files and directories found, the tree returns the
total number of files and directories listed.
13. Wc : wc stands for word count. As the name implies, it is mainly
used for counting purposes.
● It is used to find out the number of lines, word count, byte and
characters count in the files specified in the file arguments.
● By default it displays four-columnar output.
● First column shows number of lines present in a file specified, second
column shows number of words present in the file, third column
shows number of characters present in file and fourth column itself is
the file name which is given as argument.
14. Echo : echo command in linux is used to display lines of text/string that
are passed as an argument . This is a built-in command that is mostly
used in shell scripts and batch files to output status text to the screen or a
file.
15. Cat : Cat(concatenate) command is very frequently used in Linux. It
reads data from the file and gives their content as output. It helps us to
create, view, and concatenate files. So let us see some frequently used
cat commands.
16. W : w command in Linux is used to show who is logged on and what
they are doing. This command shows the information about the users
currently on the machine and their processes. The header shows, in this
order, the current time, how long the system has been running, how
many users are currently logged on, and the system load averages for
the past 1, 5, and 15 minutes. The following entries are displayed for
each user: login name, the tty name, the remote host, login time, idle
time, JCPU, PCPU, and the command line of their current process. The
JCPU time is the time used by all processes attached to the tty. It does
not include past background jobs but does include currently running
background jobs. The PCPU time is the time used by the current process,
named in the “what” field.

17. Redirection : Redirection here simply means diverting the output


or input.
18. Man : man command in Linux is used to display the user manual of any
command that we can run on the terminal. It provides a detailed view of the
command which includes NAME, SYNOPSIS, DESCRIPTION, OPTIONS,
EXIT STATUS, RETURN VALUES, ERRORS, FILES, VERSIONS,
EXAMPLES, AUTHORS and SEE ALSO.
$ man printf

19. Tty : The tty command of terminal basically prints the file name of the
terminal connected to standard input. tty is short of teletype, but popularly
known as a terminal it allows you to interact with the system by passing
on the data (you input) to the system, and displaying the output produced
by the system.
20. Tail : It is the complement of head command.The tail command, as
the name implies, prints the last N number of data of the given input. By
default it prints the last 10 lines of the specified files. If more than one file
name is provided then data from each file is preceded by its file name.
21. Creating soft link : A soft link is similar to the file shortcut feature
which is used in Windows Operating systems. Each soft linked file
contains a separate Inode value that points to the original file. As similar to
hard links, any changes to the data in either file is reflected in the other.
Soft links can be linked across different file systems, although if the
original file is deleted or moved, the soft linked file will not work correctly
(called hanging link).
ls -l command shows all links with first column value l? and the link points
to the original file.

Syntax : $ ln -s [filename] [link]

22. Env : env is used to either print environment variables. It is also used
to run a utility or command in a custom environment. In practice, env has
another common use. It is often used by shell scripts to launch the correct
interpreter. In this usage, the environment is typically not changed.
23. Creating and extracting tar files: The Linux ‘tar’ stands for tape
archive, is used to create Archive and extract the Archive files. tar
command in Linux is one of the important commands which provides
archiving functionality in Linux. We can use Linux tar command to create
compressed or uncompressed Archive files and also maintain and modify
them.
24. Vim editor : Vim is an advanced and highly configurable text editor
built to enable efficient text editing. Vim text editor is developed by
Bram Moolenaar. It supports most file types and vim editor is also
known as a programmer’s editor.
25. Chmod : the chmod command is used to change the access mode of
a file.The name is an abbreviation of change mode.

26. Path variable : $PATH: Gives search path for commands.

27. Bash history : The Linux bash has a very powerful command called
“history”. This command is a built-in bash command that is used to
extract
history information about commands that have been executed by Linux
users in all previous sessions.

28. Which : which command in Linux is a command which is used to


locate the executable file associated with the given command by
searching it in the path environment variable. It has 3 return status as
follows:
● 0 : If all specified commands are found and executable.
● 1 : If one or more specified commands is nonexistent or not executable.
● 2 : If an invalid option is specified.
29. Grep : The grep filter searches a file for a particular pattern of
characters, and displays all lines that contain that pattern. The pattern
that is searched in the file is referred to as the regular expression (grep
stands for global search for regular expression and print out).
30. Kill : kill command in Linux (located in /bin/kill), is a built-in
command which is used to terminate processes manually. kill command
sends a signal to a process which terminates the process. If the user
doesn’t specify any signal which is to be sent along with the kill
command then a default TERM signal is sent that terminates the

process.

31. Ping : PING (Packet Internet Groper) command is used to check the
network connectivity between host and server/host. This command
takes as input the IP address or the URL and sends a data packet to the
specified address with the message “PING” and get a response from the
server/host this time is recorded which is called latency. Fast ping low
latency means faster connection.
32. Sort : SORT command is used to sort a file, arranging the records in
a particular order. By default, the sort command sorts file assuming the
contents are ASCII. Using options in the sort command can also be used
to sort numerically.

33. Uniq : The uniq command in Linux is a command-line utility


that reports or filters out the repeated lines in a file.
34. Comm : comm compare two sorted files line by line and write to
standard output; the lines that are common and the lines that are

unique.
35. Cmp : cmp command in Linux/UNIX is used to compare the two files
byte by byte and helps you to find out whether the two files are identical
or not.

36. Diff : diff stands for difference. This command is used to display the
differences in the files by comparing the files line by line. Unlike its
fellow members, cmp and comm, it tells us which lines in one file have
to be changed to make the two files identical.

37. Tr : The tr command in UNIX is a command line utility for translating


or deleting characters. It supports a range of transformations including
uppercase to lowercase, squeezing repeating characters, deleting specific
characters and basic find and replace. It can be used with UNIX pipes to
support more complex translation. tr stands for translate.
38. Pstree : Pstree command in Linux that shows the running
processes as a tree which is a more convenient way to display the
processes hierarchy and makes the output more visually appealing. The
root of the tree is either init or the process with the given pid. Pstree can
also be installed in other Unix systems.
39. Du : du command, short for disk usage, is used to estimate file space
usage. The du command can be used to track the files and directories
which are consuming excessive amounts of space on the hard disk

drive.

40. Df : The df command (short for disk free), is used to display information
related to file systems about total space and available space.
41. Find : The find command in UNIX is a command line utility for walking
a file hierarchy. It can be used to find files and directories and perform
subsequent operations on them. It supports searching by file, folder,
name, creation date, modification date, owner and permissions. By using
the
‘-exec’ other UNIX commands can be executed on files or folders found.

42. Fdisk : fdisk also known as format disk is a dialog-driven command


in Linux used for creating and manipulating disk partition table. It is used
for the view, create, delete, change, resize, copy and move partitions on
a hard drive using the dialog-driven interface.
43. Sudo : sudo (Super User DO) command in Linux is generally used as
a prefix of some command that only super users are allowed to run. If you
prefix “sudo” with any command, it will run that command with elevated
privileges or in other words allow a user with proper permissions to
execute a command as another user, such as the superuser. This is the
equivalent of the “run as administrator” option in Windows. The option of
sudo lets us have multiple administrators.
These users who can use the sudo command need to have an entry in the
sudoers file located at “/etc/sudoers”. Remember that to edit or view the
sudoers file you have to use the sudo command. To edit the sudoers file it
is recommended to use the “visudo” command.
By default, sudo requires that users authenticate themselves with a
password which is the user’s password, not the root password itself.
44. Scp : scp (secure copy) command in Linux systems is used to copy
file(s) between servers in a secure way. The SCP command or secure
copy allows secure transferring of files in between the local host and the
remote host or between two remote hosts. It uses the same authentication
and security as it is used in the Secure Shell (SSH) protocol. SCP is
known for its simplicity, security and pre-installed availability.

You might also like