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

Practical – 1: Basic Linux/Unix Commands

Linux Commands

1. Alias:
Alias command instructs the shell to replace one string with another string while executing
the commands.
When we often have to use a single big command multiple times, in those cases, we create
something called as alias for that command. Alias is like a shortcut command which will have
the same functionality as if we are writing the whole command.

Syntax:-
alias [-p] [name="value"]

Example:-

2. apt-get:
The apt-get utility is a powerful and free package management command line program that is
used to work with Ubuntu’s APT (Advanced Packaging Tool) library to perform installation
of new software packages, removing existing software packages, upgrading of existing
software packages and even used to upgrading the entire operating system.

1
Example:

3. 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.

Example:

4. Cd:
Cd command in Linux known as Change Directory command. It is used to change current
working directory and can toggle between directories conveniently.

Example:

5. Chmod:
In the linux operating system, the Chmod command is used to change the access mode
of a file. The name is an abbreviation of Change Mode.
2
Syntax:
chmod [reference][operator][mode] file...

3
Example:

6. Cmp:
cmp command in Linux is used to compare the two files byte by byte and helps you to find
out whether the two files are identical or not.
When cmp is used for comparison between two files, it reports the location of the first
mismatch to the screen if a difference is found. cmp displays no message and simply returns
the prompt if the files compared are identical.

Example:

7. Cp:
Cp stands for copy. This command is used to copy files or groups of files or directory. It

4
creates an exact image of a file on a disk with a different name. Cp command requires at least
two filenames in its arguments.

Example:

8. Date:
Date sets a system's date and time. This is also a useful way to output/print current
information when working in a script file.

Example:

9. Df:
The DF(disk free) command is used to display information related to file system about to
total space and available space. If no file name is given, it displays the space available on all
currently mounted file system.

Example:

10. Echo:
Echo command in Linux is used to display line 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.

5
Example:

11. Grep:
Grep is a command in Linux which is used to search for a string of characters in a specified
file. The text search pattern is called a regular expression. When it finds a match, it prints the
line with the result.

Example:

12. Ls:
The Linux Ls command allows you to view a list of the files and folders in a given directory.
You can also use this command to display details of a file, such as the owner of the file and
the permissions assigned to the file.

Example:

13. Move:
Mv stands for move. Mv is used to move one or more files or directories from one place to
another in a file system

Example:

6
14. Rm:
Rm stands for Remove. Rm is used to remove files you no longer need.
Example:

15. mkdir:
mkdir stands for make directory. mkdir command in linux allows the user to create
directories. This command can create multiple directories at once as well as set permissions
for the directories.

Example:

16. rmdir:
rmdir command is used remove empty directories from the file system 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.

7
Example:

17. Nslookup:
Nslookup Stand for “Name Server Lookup”. It is a network administration tool for querying
the Domain Name System to obtain domain name and IP address.

Example:

18. Ping:
The packet Internet groper (Ping) command sends an Internet Control Message Protocol
(ICMP) Echo Request to a host, gateway, or router with the expectation of receiving a reply.

Example:

19. Sudo:
The Sudo command allows you to run programs with the security privileges of another

8
Superuser.

20. Less:
Less command is a Linux utility that can be used to read the contents of a text file one page at
a time. It has faster access because if a file is large it doesn’t access the complete file, but
accesses it page by page.

Example:

9
21. Clear:
Clear is a standard Linux computer operating system command that is used to clear the
terminal screen.

Example:
BEFORE

AFTER

22. DU:
DU stands for Disk Usage. Du allows a user to gain disk usage information quickly.
Example:

23. Touch:
The Touch command is a standard command used in Linux operating system which is used to

10
create, change and modify timestamps of a file. Basically, there are two different commands to
create a file in the Linux system which is as follows:

1. Cat Command: It is used to create the file with content.

2. Touch Command: It is used to create a file without content. The file created using touch
command is empty. This command can be used when the user doesn’t have data to store at the
time of file creation.

Example:

24. Who:
Who command display login name of User, Terminal line number and Login time of the users
in system

Example:

Sign: _________________

11

You might also like