Uploaded by Keshvi Chovatiya

Pr1

advertisement
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 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.
Example:
3
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 linux operating system Chmod command is used to change the access mode of a file.
The name is an abbreviation of Change Mode.
Syntax:
chmod [reference][operator][mode] file...
4
The references are used to distinguish the users to whom the permissions a pply
Reference
Ls Output
Class
Description
u
-rwx------
Owner
File’s Owner
g
----rwx---
Group
Users who are member of the file’s
group
o
-------rwx
Others
Users who are neither the file’s
owner nor members of group of the
file’s group
a
-rwxrwxrwx
All
All three of the above, same as ugo
The operator is used to specify how the modes of a file should be adjusted. The following
operators are accepted:
Operator
Description
+
Adds the specified modes to the specified classes.
-
Removes the specified modes from the specified classes.
=
The modes specified are to be made the exact modes for the
specified classes.
Note: Putting blank space(s) around operator would make the command fail.
The modes indicate which permissions are to be granted or removed fr om the specified
classes. There are three basic modes which correspond to the basic permissions:
Modes
Description
r
Permission to read the file.
w
Permission to write (or delete) the file.
x
Permission to execute the file or in the case of a directory search it.
Example:
5
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 difference is found. cmp displays no message and simply returns
the prompt if the files compared are identical.
Example:
6
7. Cp:
Cp stands for copy. This command is used to copy files or group of files or
directory. It creates an exact image of a file on a disk with different name. Cp command
require at least two filename 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:
7
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.
Example:
8
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:
9
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:
14. Rm:
Rm stands for Remove. Rm is used to remove files you no longer need.
Example:
10
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.
Example:
11
17. Nslookup:
Nslookup Stand for “Name Server Lookup”. It is 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 Superuser.
12
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 file is large it doesn’t access the complete
file, but accesses it page by page.
Example:
21. Clear:
Clear is a standard Linux computer operating system command that is used to clear
the terminal screen.
Example:
13
Before
After
22. DU:
DU stands for Disk Usage. Du allows a user to gain disk usage information quickly.
Example:
14
23. Touch:
The Touch command is a standard command used in Linux operating system which
is used to 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: _________________
15
Download